Commit af60f9aa authored by Anatoly Mihalchenko's avatar Anatoly Mihalchenko

Merge branch 'master' of github.com:Sankore/Sankore-3.1

parents 548f8f4a 5952e03b
...@@ -8,23 +8,27 @@ ...@@ -8,23 +8,27 @@
AppId={{E63D17F8-D9DA-479D-B9B5-0D101A03703B} AppId={{E63D17F8-D9DA-479D-B9B5-0D101A03703B}
AppName=Sankore 3.1 AppName=Sankore 3.1
AppVerName=Sankore 3.1 AppVerName=Sankore 3.1
AppPublisher=Mnemis AppPublisher=Sankore
AppPublisherURL=http://www.getuniboard.com AppPublisherURL=http://dev.open-sankore.org
AppSupportURL=http://support.getuniboard.com AppSupportURL=http://dev.open-sankore.org
AppUpdatesURL=http://www.getuniboard.com AppUpdatesURL=http://dev.open-sankore.org
DefaultDirName={pf}\Sankore 3.1 DefaultDirName={pf}\Sankore 3.1
DefaultGroupName=Sankore 3.1 DefaultGroupName=Sankore 3.1
OutputDir=.\install\win32\ OutputDir=.\install\win32\
OutputBaseFilename=Sankore 3.1 setup OutputBaseFilename=Sankore 3.1
SetupIconFile=.\resources\win\uniboard.ico SetupIconFile=.\resources\win\uniboard.ico
Compression=lzma Compression=lzma
SolidCompression=yes SolidCompression=yes
[Languages] [Languages]
Name: "english"; MessagesFile: "compiler:Default.isl" Name: "en"; MessagesFile: "compiler:Default.isl"
Name: "fr"; MessagesFile: "compiler:Languages\French.isl"
Name: "gr"; MessagesFile: "compiler:Languages\German.isl"
Name: "it"; MessagesFile: "compiler:Languages\Italian.isl"
Name: "sp"; MessagesFile: "compiler:Languages\Spanish.isl"
[Tasks] [Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
...@@ -40,18 +44,30 @@ Type: filesandordirs ; Name: "{app}\i18n" ...@@ -40,18 +44,30 @@ Type: filesandordirs ; Name: "{app}\i18n"
Type: files ; Name: "{app}\*.dll" Type: files ; Name: "{app}\*.dll"
[Files] [Files]
Source: "..\Sankore-ThirdParty\microsoft\vcredist_x86.exe"; DestDir:"{tmp}"
Source: ".\build\win32\release\product\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs Source: ".\build\win32\release\product\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: ".\runtime\windows\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs;
Source: ".\resources\win\plugins\*"; DestDir: "{app}"; Flags: recursesubdirs createallsubdirs ;Qt base dll
Source: "..\Qt-sankore3.1\lib\QtScript4.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\Qt-sankore3.1\lib\QtGui4.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\Qt-sankore3.1\lib\QtXml4.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\Qt-sankore3.1\lib\QtCore4.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\Qt-sankore3.1\lib\QtWebKit4.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\Qt-sankore3.1\lib\phonon4.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\Qt-sankore3.1\lib\QtNetwork4.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\Qt-sankore3.1\lib\QtSvg4.dll"; DestDir: "{app}"; Flags: ignoreversion
;Qt plugins
Source: "..\Qt-sankore3.1\plugins\imageformats\qjpeg4.dll"; DestDir: "{app}\imageformats"; Flags: ignoreversion
Source: "..\Qt-sankore3.1\plugins\imageformats\qsvg4.dll"; DestDir: "{app}\imageformats"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons] [Icons]
Name: "{group}\Sankore 3.1"; Filename: "{app}\Sankore 3.1.exe" Name: "{group}\Sankore 3.1"; Filename: "{app}\Sankore 3.1.exe"
;Name: "{group}\{cm:ProgramOnTheWeb,Sankore 3.1}"; Filename: "http://www.getuniboard.com/"
Name: "{group}\{cm:UninstallProgram,Sankore 3.1}"; Filename: "{uninstallexe}" Name: "{group}\{cm:UninstallProgram,Sankore 3.1}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\Sankore 3.1"; Filename: "{app}\Sankore 3.1.exe"; Tasks: desktopicon Name: "{commondesktop}\Sankore 3.1"; Filename: "{app}\Sankore 3.1.exe"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\Sankore 3.1"; Filename: "{app}\Sankore 3.1.exe"; Tasks: quicklaunchicon Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\Sankore 3.1"; Filename: "{app}\Sankore 3.1.exe"; Tasks: quicklaunchicon
Name: "{group}\Printing Preferences"; Filename: "{app}\properties.exe"; WorkingDir: {app} ;Name: "{group}\Printing Preferences"; Filename: "{app}\properties.exe"; WorkingDir: {app}
[Registry] [Registry]
Root: HKCR; Subkey: ".ubz"; ValueType: string; ValueName: ""; ValueData: "SankoreFile"; Flags: uninsdeletevalue Root: HKCR; Subkey: ".ubz"; ValueType: string; ValueName: ""; ValueData: "SankoreFile"; Flags: uninsdeletevalue
...@@ -70,6 +86,7 @@ Root: HKLM64; Subkey: "SOFTWARE\Sankore 3.1"; ValueType: dword; ValueName: "EMF: ...@@ -70,6 +86,7 @@ Root: HKLM64; Subkey: "SOFTWARE\Sankore 3.1"; ValueType: dword; ValueName: "EMF:
Root: HKLM64; Subkey: "SOFTWARE\Sankore 3.1\Defaults"; ValueType: dword; ValueName: "PDF: Enabled"; ValueData: "1"; Flags: uninsdeletevalue; Check: isProcessorX64 Root: HKLM64; Subkey: "SOFTWARE\Sankore 3.1\Defaults"; ValueType: dword; ValueName: "PDF: Enabled"; ValueData: "1"; Flags: uninsdeletevalue; Check: isProcessorX64
[Run] [Run]
Filename: "{tmp}\vcredist_x86.exe";WorkingDir:"{tmp}"
Filename: "{app}\Sankore 3.1.exe"; Description: "{cm:LaunchProgram,Sankore 3.1}"; Flags: nowait postinstall Filename: "{app}\Sankore 3.1.exe"; Description: "{cm:LaunchProgram,Sankore 3.1}"; Flags: nowait postinstall
[UninstallDelete] [UninstallDelete]
...@@ -85,4 +102,4 @@ end; ...@@ -85,4 +102,4 @@ end;
function isProcessorNotX64: Boolean; function isProcessorNotX64: Boolean;
begin begin
Result := not isProcessorX64; Result := not isProcessorX64;
end; end;
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Executables # Executables
QMAKE="/usr/local/Trolltech/Qt-4.7.3/bin/qmake" QMAKE="/usr/local/Trolltech/Qt-4.7.3/bin/qmake"
MACDEPLOYQT="/usr/bin/macdeployqt" MACDEPLOYQT="`pwd`/../Qt-sankore3.1/bin/macdeployqt"
DMGUTIL="`pwd`/../Sankore-ThirdParty/refnum/dmgutil/dmgutil.pl" DMGUTIL="`pwd`/../Sankore-ThirdParty/refnum/dmgutil/dmgutil.pl"
DSYMUTIL=/usr/bin/dsymutil DSYMUTIL=/usr/bin/dsymutil
STRIP=/usr/bin/strip STRIP=/usr/bin/strip
......
...@@ -5,12 +5,16 @@ set VS_BIN="C:\Program Files\Microsoft Visual Studio 9.0\VC\bin" ...@@ -5,12 +5,16 @@ set VS_BIN="C:\Program Files\Microsoft Visual Studio 9.0\VC\bin"
set WIN_SDK_BIN="C:\Program Files\Microsoft SDKs\Windows\v6.1\Bin" set WIN_SDK_BIN="C:\Program Files\Microsoft SDKs\Windows\v6.1\Bin"
set INNO_EXE="C:\Program Files\Inno Setup 5\iscc.exe " set INNO_EXE="C:\Program Files\Inno Setup 5\iscc.exe "
set BUILD_DIR=build\win32\release set BUILD_DIR=build\win32\release
set UB_DATA_DIR="D:\"
set PATH=%QT_BIN%;%PATH%;%WIN_SDK_BIN% set PATH=%QT_BIN%;%PATH%;%WIN_SDK_BIN%
call %VS_BIN%\vcvars32.bat call %VS_BIN%\vcvars32.bat
REM this checks if the custom qt directory path
REM is correct. This is important because installer
REM pick up dll from this directory
IF NOT EXIST "..\Qt-sankore3.1\lib\QtCore4.dll" GOTO EXIT_WITH_ERROR
rmdir /S /Q %BUILD_DIR% rmdir /S /Q %BUILD_DIR%
set EDITION=MNEMIS_EDITION set EDITION=MNEMIS_EDITION
...@@ -30,11 +34,8 @@ echo %LAST_TAG_VERSION% ...@@ -30,11 +34,8 @@ echo %LAST_TAG_VERSION%
if not v%VERSION%==%LAST_TAG_VERSION% GOTO EXIT_WITH_ERROR if not v%VERSION%==%LAST_TAG_VERSION% GOTO EXIT_WITH_ERROR
nmake release-install nmake release-install
.\thirdparty\google-breakpad\r318\bin\win32\dump_syms.exe .\build\win32\release\product\Sankore 3.1.pdb > "%UB_DATA_DIR%\releases\uniboard\sym\win32\Sankore 3.1.exe\%LONG_VERSION%%EDITION%.sym"
del .\build\win32\release\product\Sankore 3.1.pdb del .\build\win32\release\product\Sankore 3.1.pdb
set INSTALLER_NAME=Sankore 3.1 set INSTALLER_NAME=Sankore 3.1
...@@ -44,5 +45,4 @@ set INSTALLER_PATH=.\install\win32\%INSTALLER_NAME%.exe ...@@ -44,5 +45,4 @@ set INSTALLER_PATH=.\install\win32\%INSTALLER_NAME%.exe
call %INNO_EXE% "Sankore 3.1.iss" /F"%INSTALLER_NAME%" call %INNO_EXE% "Sankore 3.1.iss" /F"%INSTALLER_NAME%"
:EXIT_WITH_ERROR :EXIT_WITH_ERROR
echo version %VERSION% echo ERROR
echo last tag version %LAST_TAG_VERSION%
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<noInheritable></noInheritable>
<assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
<file name="msvcr90.dll" hashalg="SHA1" hash="9785b1c493deb5b2134dc4aef3719cee207001bc"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>VF5ECUAHPV7EnUf+/UIXMPizPvs=</dsig:DigestValue></asmv2:hash></file>
<file name="msvcp90.dll" hashalg="SHA1" hash="0f6bbf7fe4fb3fca2cb5b542eca1a1cad051f01c"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>3Wg+StVMq2uhx7POnAkl2w4dDmY=</dsig:DigestValue></asmv2:hash></file>
<file name="msvcm90.dll" hashalg="SHA1" hash="7f3290ab2b7444c2b4a9b1fedfdb16466d7a21bb"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>/YfRn7UQENzdMeoMHxTgdRMiObA=</dsig:DigestValue></asmv2:hash></file>
</assembly>
\ No newline at end of file
...@@ -175,11 +175,15 @@ UBDocumentProxy* UBImportDocument::importFile(const QFile& pFile, const QString& ...@@ -175,11 +175,15 @@ UBDocumentProxy* UBImportDocument::importFile(const QFile& pFile, const QString&
QString documentRootFolder = expandFileToDir(pFile, path); QString documentRootFolder = expandFileToDir(pFile, path);
UBDocumentProxy* newDocument = UBPersistenceManager::persistenceManager()->createDocumentFromDir(documentRootFolder); if(!documentRootFolder.length()){
UBApplication::showMessage(tr("Import of file %1 failed.").arg(fi.baseName()));
UBApplication::showMessage(tr("Import successful.")); return 0;
}
return newDocument; else{
UBDocumentProxy* newDocument = UBPersistenceManager::persistenceManager()->createDocumentFromDir(documentRootFolder);
UBApplication::showMessage(tr("Import successful."));
return newDocument;
}
} }
......
...@@ -38,7 +38,7 @@ UBDocumentPublisher::UBDocumentPublisher(UBDocumentProxy* pDocument, QObject *pa ...@@ -38,7 +38,7 @@ UBDocumentPublisher::UBDocumentPublisher(UBDocumentProxy* pDocument, QObject *pa
, mPublishingDocument(0) , mPublishingDocument(0)
, mUsername("") , mUsername("")
, mPassword("") , mPassword("")
, bLoginCookieSet(false) , bLoginCookieSet(false)
{ {
mpWebView = new QWebView(0); mpWebView = new QWebView(0);
UBApplication::mainWindow->addSankoreWebDocumentWidget(mpWebView); UBApplication::mainWindow->addSankoreWebDocumentWidget(mpWebView);
...@@ -63,17 +63,23 @@ UBDocumentPublisher::~UBDocumentPublisher() ...@@ -63,17 +63,23 @@ UBDocumentPublisher::~UBDocumentPublisher()
void UBDocumentPublisher::publish() void UBDocumentPublisher::publish()
{ {
//check that the username and password are stored on preferences UBPublicationDlg dlg;
UBSettings* settings = UBSettings::settings(); if(QDialog::Accepted == dlg.exec())
{
mDocInfos.title = dlg.title();
mDocInfos.description = dlg.description();
mUsername = settings->communityUsername(); //check that the username and password are stored on preferences
mPassword = settings->communityPassword(); UBSettings* settings = UBSettings::settings();
buildUbwFile();
UBApplication::showMessage(tr("Uploading Sankore File on Web."));
login(mUsername, mPassword); mUsername = settings->communityUsername();
//sendUbw(); mPassword = settings->communityPassword();
buildUbwFile();
UBApplication::showMessage(tr("Uploading Sankore File on Web."));
login(mUsername, mPassword);
//sendUbw();
}
} }
void UBDocumentPublisher::onLoginDone() void UBDocumentPublisher::onLoginDone()
...@@ -573,39 +579,44 @@ void UBDocumentPublisher::init() ...@@ -573,39 +579,44 @@ void UBDocumentPublisher::init()
{ {
mCrlf=0x0d; mCrlf=0x0d;
mCrlf+=0x0a; mCrlf+=0x0a;
mDocInfos.title = "";
mDocInfos.description = "";
mpNetworkMgr = new QNetworkAccessManager(this); mpNetworkMgr = new QNetworkAccessManager(this);
//mpCache = new QNetworkDiskCache(this);
//mpCache->setCacheDirectory("cache");
//mpNetworkMgr->setCache(mpCache);
mpCookieJar = new QNetworkCookieJar(); mpCookieJar = new QNetworkCookieJar();
// QNetworkProxy* pProxy = UBSettings::settings()->httpProxy();
// if(NULL != pProxy)
// {
// mpNetworkMgr->setProxy(*pProxy);
// qDebug() << "Proxy set!";
// }
connect(mpNetworkMgr, SIGNAL(finished(QNetworkReply*)), this, SLOT(onFinished(QNetworkReply*))); connect(mpNetworkMgr, SIGNAL(finished(QNetworkReply*)), this, SLOT(onFinished(QNetworkReply*)));
connect(mpNetworkMgr, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), this, SLOT(onProxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
} }
void UBDocumentPublisher::onFinished(QNetworkReply *reply) void UBDocumentPublisher::onFinished(QNetworkReply *reply)
{ {
qDebug() << "[-[ Request finished! ]-]";
QByteArray response = reply->readAll(); QByteArray response = reply->readAll();
if (!bLoginCookieSet) QVariant cookieHeader = reply->rawHeader("Set-Cookie");
{ // First we concatenate all the Set-Cookie values (the packet can contains many of them)
QVariant cookieHeader = reply->rawHeader("Set-Cookie"); QStringList qslCookie = cookieHeader.toString().split("\n");
// First we concatenate all the Set-Cookie values (the packet can contains many of them) QString qsCookieValue = qslCookie.at(0);
QStringList qslCookie = cookieHeader.toString().split("\n"); for (int i = 1; i < qslCookie.size(); i++) {
QString qsCookieValue = qslCookie.at(0); qsCookieValue += "; " +qslCookie.at(i);
for (int i = 1; i < qslCookie.size(); i++) { }
qsCookieValue += "; " +qslCookie.at(i);
}
// Now we isolate every cookie value // Now we isolate every cookie value
QStringList qslCookieVals = qsCookieValue.split("; "); QStringList qslCookieVals = qsCookieValue.split("; ");
if (!bLoginCookieSet)
{
// Finally we create the cookies // Finally we create the cookies
for (int i = 0; i < qslCookieVals.size(); i++) for (int i = 0; i < qslCookieVals.size(); i++)
{ {
QString cookieString = qslCookieVals.at(i); QString cookieString = qslCookieVals.at(i);
//qDebug() << "qslCookieVals.at(i): " << cookieString.replace("\"", "");
QStringList qslCrntCookie = cookieString.split("="); QStringList qslCrntCookie = cookieString.split("=");
QNetworkCookie crntCookie; QNetworkCookie crntCookie;
if (qslCrntCookie.length() == 2) if (qslCrntCookie.length() == 2)
...@@ -630,11 +641,6 @@ void UBDocumentPublisher::onFinished(QNetworkReply *reply) ...@@ -630,11 +641,6 @@ void UBDocumentPublisher::onFinished(QNetworkReply *reply)
} }
QNetworkCookie langCookie("language", "en"); QNetworkCookie langCookie("language", "en");
mCookies << langCookie; mCookies << langCookie;
// DEBUG : Verify
for(int i = 0; i < mCookies.size(); i++)
{
qDebug() << mCookies.at(i).name() << "=" << mCookies.at(i).value();
}
// Set the cookiejar : it set the cookies that will be sent with every packet. // Set the cookiejar : it set the cookies that will be sent with every packet.
mpCookieJar->setCookiesFromUrl(mCookies, QUrl(DOCPUBLICATION_URL)/*reply->url()*/); mpCookieJar->setCookiesFromUrl(mCookies, QUrl(DOCPUBLICATION_URL)/*reply->url()*/);
...@@ -645,19 +651,30 @@ void UBDocumentPublisher::onFinished(QNetworkReply *reply) ...@@ -645,19 +651,30 @@ void UBDocumentPublisher::onFinished(QNetworkReply *reply)
} }
else else
{ {
if (!response.isEmpty()){ if (response.isEmpty())
// Display the iframe
mpWebView->setHtml(response, reply->url());
UBApplication::applicationController->showSankoreWebDocument();
}
else
{ {
// Redirect // Verify that the UBW file has been sent correctly
QVariant locationHeader = reply->rawHeader("Location"); bool bTransferOk = false;
for(int j = 0; j <= qslCookieVals.size(); j++)
QNetworkRequest req(QUrl(locationHeader.toString())); {
mpNetworkMgr->get(req); if(qslCookieVals.at(j).startsWith("assetStatus"))
qDebug() << mpWebView->url().toString(); {
QStringList qslAsset = qslCookieVals.at(j).split("=");
if(qslAsset.at(1) == "UPLOADED")
{
bTransferOk = true;
break;
}
}
}
if(bTransferOk)
{
UBApplication::showMessage(tr("Document uploaded correctly on the web."));
}
else
{
UBApplication::showMessage(tr("Failed to upload document on the web."));
}
} }
} }
reply->deleteLater(); reply->deleteLater();
...@@ -693,6 +710,15 @@ void UBDocumentPublisher::sendUbw() ...@@ -693,6 +710,15 @@ void UBDocumentPublisher::sendUbw()
request.setRawHeader("Accept-Language", "en-US,*"); request.setRawHeader("Accept-Language", "en-US,*");
request.setRawHeader("Referer", DOCPUBLICATION_URL); request.setRawHeader("Referer", DOCPUBLICATION_URL);
QNetworkCookie titleCookie("title", mDocInfos.title.toAscii().constData());
QNetworkCookie descCookie("description", mDocInfos.description.remove("\n").toAscii().constData());
mCookies << titleCookie;
mCookies << descCookie;
mpCookieJar->setCookiesFromUrl(mCookies, QUrl(DOCPUBLICATION_URL));
mpNetworkMgr->setCookieJar(mpCookieJar);
// Send the file // Send the file
mpNetworkMgr->post(request,datatoSend); mpNetworkMgr->post(request,datatoSend);
} }
...@@ -719,10 +745,189 @@ void UBDocumentPublisher::onLoadFinished(bool result) ...@@ -719,10 +745,189 @@ void UBDocumentPublisher::onLoadFinished(bool result)
Q_UNUSED(result); Q_UNUSED(result);
// [Basic Auth] This line says: if the user click on a link, do not interpret it. // [Basic Auth] This line says: if the user click on a link, do not interpret it.
//mpWebView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); //mpWebView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
mpWebView->page()->setNetworkAccessManager(mpNetworkMgr); mpWebView->page()->setNetworkAccessManager(mpNetworkMgr);
} }
void UBDocumentPublisher::onProxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator)
{
Q_UNUSED(proxy);
UBProxyLoginDlg dlg;
if(QDialog::Accepted == dlg.exec())
{
authenticator->setUser(dlg.username());
authenticator->setPassword(dlg.password());
}
}
// ---------------------------------------------------------
UBProxyLoginDlg::UBProxyLoginDlg(QWidget *parent, const char *name):QDialog(parent)
, mpLayout(NULL)
, mpUserLayout(NULL)
, mpPasswordLayout(NULL)
, mpButtons(NULL)
, mpUserLabel(NULL)
, mpPasswordLabel(NULL)
, mpUsername(NULL)
, mpPassword(NULL)
{
setObjectName(name);
setFixedSize(400, 150);
setWindowTitle(tr("Proxy Login"));
mpLayout = new QVBoxLayout();
setLayout(mpLayout);
mpUserLayout = new QHBoxLayout();
mpLayout->addLayout(mpUserLayout);
mpPasswordLayout = new QHBoxLayout();
mpLayout->addLayout(mpPasswordLayout);
mpUserLabel = new QLabel(tr("Username:"), this);
mpUsername = new QLineEdit(this);
mpUserLayout->addWidget(mpUserLabel, 0);
mpUserLayout->addWidget(mpUsername, 1);
mpPasswordLabel = new QLabel(tr("Password:"), this);
mpPassword = new QLineEdit(this);
mpPasswordLayout->addWidget(mpPasswordLabel, 0);
mpPasswordLayout->addWidget(mpPassword, 1);
mpButtons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
mpLayout->addWidget(mpButtons);
connect(mpButtons, SIGNAL(accepted()), this, SLOT(accept()));
connect(mpButtons, SIGNAL(rejected()), this, SLOT(reject()));
}
UBProxyLoginDlg::~UBProxyLoginDlg()
{
if(NULL != mpLayout)
{
delete mpLayout;
mpLayout = NULL;
}
if(NULL != mpButtons)
{
delete mpButtons;
mpButtons = NULL;
}
if(NULL != mpUserLabel)
{
delete mpUserLabel;
mpUserLabel = NULL;
}
if(NULL != mpPasswordLabel)
{
delete mpPasswordLabel;
mpPasswordLabel = NULL;
}
if(NULL != mpUsername)
{
delete mpUsername;
mpUsername = NULL;
}
if(NULL != mpPassword)
{
delete mpPassword;
mpPassword = NULL;
}
}
// ---------------------------------------------------------
UBPublicationDlg::UBPublicationDlg(QWidget *parent, const char *name):QDialog(parent)
, mpLayout(NULL)
, mpTitleLayout(NULL)
, mpTitleLabel(NULL)
, mpTitle(NULL)
, mpDescLabel(NULL)
, mpDescription(NULL)
, mpButtons(NULL)
{
setObjectName(name);
setWindowTitle(tr("Publish document on the web"));
resize(500, 300);
mpLayout = new QVBoxLayout();
setLayout(mpLayout);
mpTitleLabel = new QLabel(tr("Title:"), this);
mpTitle = new QLineEdit(this);
mpTitleLayout = new QHBoxLayout();
mpTitleLayout->addWidget(mpTitleLabel, 0);
mpTitleLayout->addWidget(mpTitle, 1);
mpLayout->addLayout(mpTitleLayout, 0);
mpDescLabel = new QLabel(tr("Description:"), this);
mpLayout->addWidget(mpDescLabel, 0);
mpDescription = new QTextEdit(this);
mpLayout->addWidget(mpDescription, 1);
mpButtons = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Ok, Qt::Horizontal, this);
mpButtons->button(QDialogButtonBox::Ok)->setText(tr("Publish"));
mpLayout->addWidget(mpButtons);
mpButtons->button(QDialogButtonBox::Ok)->setEnabled(false);
connect(mpButtons, SIGNAL(accepted()), this, SLOT(accept()));
connect(mpButtons, SIGNAL(rejected()), this, SLOT(reject()));
connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onTextChanged()));
connect(mpDescription, SIGNAL(textChanged()), this, SLOT(onTextChanged()));
}
UBPublicationDlg::~UBPublicationDlg()
{
if(NULL != mpTitleLabel)
{
delete mpTitleLabel;
mpTitleLabel = NULL;
}
if(NULL != mpTitle)
{
delete mpTitle;
mpTitle = NULL;
}
if(NULL != mpDescLabel)
{
delete mpDescLabel;
mpDescLabel = NULL;
}
if(NULL != mpDescription)
{
delete mpDescription;
mpDescription = NULL;
}
if(NULL != mpButtons)
{
delete mpButtons;
mpButtons = NULL;
}
if(NULL != mpTitleLayout)
{
delete mpTitleLayout;
mpTitleLayout = NULL;
}
if(NULL != mpLayout)
{
delete mpLayout;
mpLayout = NULL;
}
}
void UBPublicationDlg::onTextChanged()
{
bool bPublishButtonState = false;
if(mpTitle->text() != "" && mpDescription->document()->toPlainText() != "")
{
bPublishButtonState = true;
}
else
{
bPublishButtonState = false;
}
mpButtons->button(QDialogButtonBox::Ok)->setEnabled(bPublishButtonState);
}
...@@ -10,11 +10,62 @@ ...@@ -10,11 +10,62 @@
#define DOCPUBLICATION_URL "http://sankore.devxwiki.com/xwiki/bin/view/CreateResources/UniboardUpload" #define DOCPUBLICATION_URL "http://sankore.devxwiki.com/xwiki/bin/view/CreateResources/UniboardUpload"
#define XWIKI_ORIGIN_HEADER "http://sankore.devxwiki.com" #define XWIKI_ORIGIN_HEADER "http://sankore.devxwiki.com"
typedef struct
{
QString title;
QString description;
} sDocumentInfos;
class UBDocumentProxy; class UBDocumentProxy;
class UBServerXMLHttpRequest; class UBServerXMLHttpRequest;
class UBGraphicsW3CWidgetItem; class UBGraphicsW3CWidgetItem;
class QWebView; class QWebView;
class UBProxyLoginDlg : public QDialog
{
Q_OBJECT
public:
UBProxyLoginDlg(QWidget* parent=0, const char* name="ProxyLoginDlg");
~UBProxyLoginDlg();
QString username(){return mpUsername->text();}
QString password(){return mpPassword->text();}
private:
QVBoxLayout* mpLayout;
QHBoxLayout* mpUserLayout;
QHBoxLayout* mpPasswordLayout;
QDialogButtonBox* mpButtons;
QLabel* mpUserLabel;
QLabel* mpPasswordLabel;
QLineEdit* mpUsername;
QLineEdit* mpPassword;
};
class UBPublicationDlg : public QDialog
{
Q_OBJECT
public:
UBPublicationDlg(QWidget* parent=0, const char* name="UBPublicationDlg");
~UBPublicationDlg();
QString title(){return mpTitle->text();}
QString description(){return mpDescription->document()->toPlainText();}
private slots:
void onTextChanged();
private:
QVBoxLayout* mpLayout;
QHBoxLayout* mpTitleLayout;
QLabel* mpTitleLabel;
QLineEdit* mpTitle;
QLabel* mpDescLabel;
QTextEdit* mpDescription;
QDialogButtonBox* mpButtons;
};
class UBDocumentPublisher : public UBAbstractPublisher class UBDocumentPublisher : public UBAbstractPublisher
{ {
Q_OBJECT; Q_OBJECT;
...@@ -42,6 +93,7 @@ private slots: ...@@ -42,6 +93,7 @@ private slots:
void onLinkClicked(const QUrl& url); void onLinkClicked(const QUrl& url);
void onLoadFinished(bool result); void onLoadFinished(bool result);
void onLoginDone(); void onLoginDone();
void onProxyAuthenticationRequired(const QNetworkProxy & proxy, QAuthenticator * authenticator);
private: private:
...@@ -65,6 +117,7 @@ private: ...@@ -65,6 +117,7 @@ private:
void login(QString username, QString password); void login(QString username, QString password);
QString mTmpZipFile; QString mTmpZipFile;
QList<QNetworkCookie> mCookies; QList<QNetworkCookie> mCookies;
sDocumentInfos mDocInfos;
}; };
#endif // UBDOCUMENTPUBLISHER_H #endif // UBDOCUMENTPUBLISHER_H
...@@ -50,6 +50,8 @@ UBLibraryController::UBLibraryController(QWidget *pParentWidget, UBBoardControll ...@@ -50,6 +50,8 @@ UBLibraryController::UBLibraryController(QWidget *pParentWidget, UBBoardControll
mInteractiveUserDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->uniboardInteractiveUserDirectory()); mInteractiveUserDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->uniboardInteractiveUserDirectory());
mAnimationUserDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->animationUserDirectory());
createInternalWidgetItems(); createInternalWidgetItems();
} }
...@@ -103,8 +105,12 @@ void UBLibraryController::routeItem(QString& pItem, QString pMiddleDirectory) ...@@ -103,8 +105,12 @@ void UBLibraryController::routeItem(QString& pItem, QString pMiddleDirectory)
destination = mVideoStandardDirectoryPath.toLocalFile(); destination = mVideoStandardDirectoryPath.toLocalFile();
else if (mimetype.contains("image")) else if (mimetype.contains("image"))
destination = mPicturesStandardDirectoryPath.toLocalFile(); destination = mPicturesStandardDirectoryPath.toLocalFile();
else if (mimetype.contains("application")) else if (mimetype.contains("application")){
destination = UBSettings::settings()->uniboardInteractiveUserDirectory(); if (mimetype.contains("x-shockwave-flash"))
destination = mAnimationUserDirectoryPath.toLocalFile();
else
destination = mInteractiveUserDirectoryPath.toLocalFile();
}
else{ else{
return; return;
} }
...@@ -225,6 +231,13 @@ QList<UBLibElement*> UBLibraryController::rootCategoriesList() ...@@ -225,6 +231,13 @@ QList<UBLibElement*> UBLibraryController::rootCategoriesList()
element->setMoveable(false); element->setMoveable(false);
categories << element; categories << element;
categoryImage = new QImage(":images/libpalette/InteractivesCategory.svg");
element = new UBLibElement(eUBLibElementType_Folder, mAnimationUserDirectoryPath, tr("Animations", "Animations category element"));
element->setThumbnail(categoryImage);
element->setMoveable(false);
categories << element;
categories << UBLibElement::trashElement(); categories << UBLibElement::trashElement();
......
...@@ -139,6 +139,7 @@ class UBLibraryController : public QObject ...@@ -139,6 +139,7 @@ class UBLibraryController : public QObject
QUrl mPicturesStandardDirectoryPath; QUrl mPicturesStandardDirectoryPath;
QUrl mInteractiveUserDirectoryPath; QUrl mInteractiveUserDirectoryPath;
QUrl mInteractiveCategoryPath; QUrl mInteractiveCategoryPath;
QUrl mAnimationUserDirectoryPath;
QStringList addItemsToCurrentLibrary(const QDir& pSelectedFolder, const QStringList& pExtensions); QStringList addItemsToCurrentLibrary(const QDir& pSelectedFolder, const QStringList& pExtensions);
......
...@@ -203,7 +203,10 @@ void UBApplicationController::adjustDisplayView() ...@@ -203,7 +203,10 @@ void UBApplicationController::adjustDisplayView()
QRect rect = mControlView->rect(); QRect rect = mControlView->rect();
QPoint center(rect.x() + rect.width() / 2, rect.y() + rect.height() / 2); QPoint center(rect.x() + rect.width() / 2, rect.y() + rect.height() / 2);
mDisplayView->setTransform(tr); QTransform recentTransform = mDisplayView->transform();
if (recentTransform != tr)
mDisplayView->setTransform(tr);
mDisplayView->centerOn(mControlView->mapToScene(center)); mDisplayView->centerOn(mControlView->mapToScene(center));
} }
......
...@@ -1052,6 +1052,15 @@ QString UBSettings::uniboardDefaultUserImageLibraryDirectory() ...@@ -1052,6 +1052,15 @@ QString UBSettings::uniboardDefaultUserImageLibraryDirectory()
} }
QString UBSettings::animationUserDirectory()
{
QString animationDirectory = uniboardDataDirectory() + "/animationUserDirectory";
if (!QDir(animationDirectory).exists())
QDir().mkpath(animationDirectory);
return animationDirectory;
}
QString UBSettings::uniboardInteractiveUserDirectory() QString UBSettings::uniboardInteractiveUserDirectory()
{ {
QString valideUserInteractiveDirectory = uniboardDataDirectory() + "/interactive content"; QString valideUserInteractiveDirectory = uniboardDataDirectory() + "/interactive content";
......
...@@ -112,9 +112,10 @@ class UBSettings : public QObject ...@@ -112,9 +112,10 @@ class UBSettings : public QObject
QString uniboardDefaultUserImageLibraryDirectory(); QString uniboardDefaultUserImageLibraryDirectory();
QString uniboardInteractiveUserDirectory(); QString uniboardInteractiveUserDirectory();
QString animationUserDirectory();
QString uniboardInteractiveLibraryDirectory(); QString uniboardInteractiveLibraryDirectory();
QString uniboardInteractiveFavoritesDirectory(); QString uniboardInteractiveFavoritesDirectory();
QString sankoreDistributedInteractiveDirectory(); QString sankoreDistributedInteractiveDirectory();
QString podcastRecordingDirectory(); QString podcastRecordingDirectory();
......
...@@ -73,10 +73,16 @@ int main(int argc, char *argv[]) ...@@ -73,10 +73,16 @@ int main(int argc, char *argv[])
#endif #endif
UBApplication app("Sankore 3.1", argc, argv); UBApplication app("Sankore 3.1", argc, argv);
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); //BUGFIX:
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); //when importing a sankore file that contains a non standard character
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); //the codecForLocale or the codecForCString is used to convert the file path
//into a const char*. This is why in french windows setup the codec name shouldn't be
//set to UTF-8. For example, setting UTF-8, will convert "Hati" into "Ha-ti.
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
//QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
QStringList args = app.arguments(); QStringList args = app.arguments();
......
...@@ -32,21 +32,21 @@ UBLibraryWidget::UBLibraryWidget(QWidget *parent, const char *name):UBThumbnailW ...@@ -32,21 +32,21 @@ UBLibraryWidget::UBLibraryWidget(QWidget *parent, const char *name):UBThumbnailW
*/ */
UBLibraryWidget::~UBLibraryWidget() UBLibraryWidget::~UBLibraryWidget()
{ {
//if(NULL != chainedElements) // if(NULL != chainedElements)
//{ // {
// delete chainedElements; // delete chainedElements;
// chainedElements = NULL; // chainedElements = NULL;
//} // }
//if(NULL != mpCrntDir) // if(NULL != mpCrntDir)
//{ // {
// delete mpCrntDir; // delete mpCrntDir;
// mpCrntDir = NULL; // mpCrntDir = NULL;
//} // }
//if(NULL != mpCrntElem) // if(NULL != mpCrntElem)
//{ // {
// delete mpCrntElem; // delete mpCrntElem;
// mpCrntElem = NULL; // mpCrntElem = NULL;
//} // }
} }
/** /**
......
...@@ -6,62 +6,167 @@ ...@@ -6,62 +6,167 @@
#include "core/memcheck.h" #include "core/memcheck.h"
UBUpdateDlg::UBUpdateDlg(QWidget *parent, int nbFiles, const QString& bkpPath) UBUpdateDlg::UBUpdateDlg(QWidget *parent, int nbFiles, const QString& bkpPath)
: QDialog(parent) : QDialog(parent)
, mpDlgBttn(NULL) , mMainLayout(NULL)
, mNbFilesLabel(NULL)
, mBkpLabel(NULL)
, mBkpPath(NULL)
, mBrowseBttn(NULL)
, mpDlgBttn(NULL)
, mLayout(NULL)
, mHLayout(NULL)
, mStackedWidget(NULL)
, mDialogWidget(NULL)
, mProgressWidget(NULL)
, mProgressLayout(NULL)
, mProgressLabel(NULL)
{ {
setFixedSize(400, 110); mDialogWidget = new QWidget(this);
mProgressWidget = new QWidget(this);
mStackedWidget = new QStackedWidget(this);
mStackedWidget->addWidget(mDialogWidget);
mStackedWidget->addWidget(mProgressWidget);
setFixedSize(450, 110);
setModal(true); setModal(true);
setWindowTitle(tr("Document updater")); setWindowTitle(tr("Document updater"));
setLayout(&mLayout); mLayout = new QVBoxLayout();
setLayout(mLayout);
QString str = QString::number(nbFiles); QString str = QString::number(nbFiles);
str.append(tr(" files require an update.")); str.append(tr(" files require an update."));
mNbFilesLabel.setText(str); mNbFilesLabel = new QLabel(mDialogWidget);
mLayout.addWidget(&mNbFilesLabel); mNbFilesLabel->setText(str);
mBkpLabel.setText(tr("Backup path: "));
mBkpPath.setText(bkpPath); mLayout->addWidget(mNbFilesLabel);
mBrowseBttn.setText(tr("Browse"));
mHLayout.addWidget(&mBkpLabel); mBkpLabel = new QLabel(mDialogWidget);
mHLayout.addWidget(&mBkpPath, 1); mBkpLabel->setText(tr("Backup path: "));
mHLayout.addWidget(&mBrowseBttn);
mLayout.addLayout(&mHLayout); mBkpPath = new QLineEdit(mDialogWidget);
mBkpPath->setText(bkpPath);
mpDlgBttn = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
mLayout.addWidget(mpDlgBttn); mBrowseBttn = new QPushButton(mDialogWidget);
mBrowseBttn->setText(tr("Browse"));
mHLayout = new QHBoxLayout();
mHLayout->addWidget(mBkpLabel);
mHLayout->addWidget(mBkpPath, 1);
mHLayout->addWidget(mBrowseBttn);
mLayout->addLayout(mHLayout);
mpDlgBttn = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, mDialogWidget);
mLayout->addWidget(mpDlgBttn);
mpDlgBttn->button(QDialogButtonBox::Ok)->setText(tr("Update")); mpDlgBttn->button(QDialogButtonBox::Ok)->setText(tr("Update"));
mpDlgBttn->button(QDialogButtonBox::Cancel)->setText("Remind me later"); mpDlgBttn->button(QDialogButtonBox::Cancel)->setText("Remind me later");
QObject::connect(&mBrowseBttn, SIGNAL(clicked()), this, SLOT(onBrowse())); QObject::connect(mBrowseBttn, SIGNAL(clicked()), this, SLOT(onBrowse()));
QObject::connect(mpDlgBttn, SIGNAL(accepted()), this, SLOT(onUpdate())); QObject::connect(mpDlgBttn, SIGNAL(accepted()), this, SLOT(onUpdate()));
QObject::connect(mpDlgBttn, SIGNAL(rejected()), this, SLOT(reject())); QObject::connect(mpDlgBttn, SIGNAL(rejected()), this, SLOT(reject()));
mDialogWidget->setLayout(mLayout);
mStackedWidget->setCurrentWidget(mDialogWidget);
mMainLayout = new QVBoxLayout();
this->setLayout(mMainLayout);
mMainLayout->addWidget(mStackedWidget);
} }
UBUpdateDlg::~UBUpdateDlg() UBUpdateDlg::~UBUpdateDlg()
{ {
if(NULL != mpDlgBttn) if (NULL != mpDlgBttn)
{ {
delete mpDlgBttn; delete mpDlgBttn;
mpDlgBttn = NULL; mpDlgBttn = NULL;
} }
if (mNbFilesLabel) {
delete mNbFilesLabel;
mNbFilesLabel = NULL;
}
if (mBkpLabel) {
delete mBkpLabel;
mBkpLabel = NULL;
}
if (mBkpPath) {
delete mBkpPath;
mBkpPath = NULL;
}
if (mBrowseBttn) {
delete mBrowseBttn;
mBrowseBttn = NULL;
}
if (mProgressLabel) {
delete mProgressLabel;
mProgressLabel = NULL;
}
if (mHLayout) {
delete mHLayout;
mHLayout = NULL;
}
if (mLayout) {
delete mLayout;
mLayout = NULL;
}
if (mProgressLayout) {
delete mProgressLayout;
mProgressLayout = NULL;
}
if (mDialogWidget) {
delete mDialogWidget;
mDialogWidget = NULL;
}
if (mProgressWidget) {
delete mProgressWidget;
mProgressWidget = NULL;
}
if (mStackedWidget) {
delete mStackedWidget;
mStackedWidget = NULL;
}
if (mMainLayout) {
delete mMainLayout;
mMainLayout = NULL;
}
} }
void UBUpdateDlg::onBrowse() void UBUpdateDlg::onBrowse()
{ {
QString qsSelectedDir; QString qsSelectedDir;
qsSelectedDir = QFileDialog::getExistingDirectory(this, tr("Select a backup folder"), mBkpPath.text()); qsSelectedDir = QFileDialog::getExistingDirectory(this, tr("Select a backup folder"), mBkpPath->text());
mBkpPath.setText(qsSelectedDir); mBkpPath->setText(qsSelectedDir);
} }
void UBUpdateDlg::onUpdate() void UBUpdateDlg::onUpdate()
{ {
mProgressLabel = new QLabel(mProgressWidget);
mProgressLayout = new QHBoxLayout();
mProgressLayout->addWidget(mProgressLabel);
mProgressWidget->setLayout(mProgressLayout);
mStackedWidget->setCurrentWidget(mProgressWidget);
emit updateFiles(); emit updateFiles();
} }
void UBUpdateDlg::onFilesUpdated(bool bResult) void UBUpdateDlg::onFilesUpdated(bool bResult)
{ {
this->hide();
QString qsMsg; QString qsMsg;
if(bResult) if (bResult)
{ {
qsMsg = tr("Files update successful!\nPlease reboot the application to access the updated documents."); qsMsg = tr("Files update successful!\nPlease reboot the application to access the updated documents.");
} }
...@@ -74,5 +179,11 @@ void UBUpdateDlg::onFilesUpdated(bool bResult) ...@@ -74,5 +179,11 @@ void UBUpdateDlg::onFilesUpdated(bool bResult)
QString UBUpdateDlg::backupPath() QString UBUpdateDlg::backupPath()
{ {
return mBkpPath.text(); return mBkpPath->text();
} }
void UBUpdateDlg::transitioningFile(QString fileName)
{
mProgressLabel->setText(tr("Updating file ") + fileName);
}
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QStackedWidget>
class UBUpdateDlg : public QDialog class UBUpdateDlg : public QDialog
{ {
...@@ -27,15 +28,25 @@ signals: ...@@ -27,15 +28,25 @@ signals:
private slots: private slots:
void onBrowse(); void onBrowse();
void onUpdate(); void onUpdate();
void transitioningFile(QString fileName);
private: private:
QLabel mNbFilesLabel; QVBoxLayout* mMainLayout;
QLabel mBkpLabel;
QLineEdit mBkpPath; QLabel* mNbFilesLabel;
QPushButton mBrowseBttn; QLabel* mBkpLabel;
QLineEdit* mBkpPath;
QPushButton* mBrowseBttn;
QDialogButtonBox* mpDlgBttn; QDialogButtonBox* mpDlgBttn;
QVBoxLayout mLayout; QVBoxLayout* mLayout;
QHBoxLayout mHLayout; QHBoxLayout* mHLayout;
QStackedWidget* mStackedWidget;
QWidget* mDialogWidget;
QWidget* mProgressWidget;
QHBoxLayout* mProgressLayout;
QLabel* mProgressLabel;
}; };
#endif // UBUPDATEDLG_H #endif // UBUPDATEDLG_H
...@@ -7,10 +7,10 @@ ...@@ -7,10 +7,10 @@
UniboardSankoreTransition::UniboardSankoreTransition(QObject *parent) : UniboardSankoreTransition::UniboardSankoreTransition(QObject *parent) :
QObject(parent) QObject(parent)
, mTransitionDlg(NULL) , mTransitionDlg(NULL)
, mThread(NULL)
{ {
mOldSankoreDirectory = UBFileSystemUtils::normalizeFilePath(UBDesktopServices::storageLocation(QDesktopServices::DataLocation)); mOldSankoreDirectory = UBFileSystemUtils::normalizeFilePath(UBDesktopServices::storageLocation(QDesktopServices::DataLocation));
qDebug() << mOldSankoreDirectory;
mUniboardSourceDirectory = UBFileSystemUtils::normalizeFilePath(UBDesktopServices::storageLocation(QDesktopServices::DataLocation)); mUniboardSourceDirectory = UBFileSystemUtils::normalizeFilePath(UBDesktopServices::storageLocation(QDesktopServices::DataLocation));
#if defined(Q_WS_MACX) #if defined(Q_WS_MACX)
...@@ -28,6 +28,11 @@ UniboardSankoreTransition::~UniboardSankoreTransition() ...@@ -28,6 +28,11 @@ UniboardSankoreTransition::~UniboardSankoreTransition()
delete mTransitionDlg; delete mTransitionDlg;
mTransitionDlg = NULL; mTransitionDlg = NULL;
} }
if(mThread){
delete mThread;
mThread = NULL;
}
} }
void UniboardSankoreTransition::rollbackDocumentsTransition(QFileInfoList& fileInfoList) void UniboardSankoreTransition::rollbackDocumentsTransition(QFileInfoList& fileInfoList)
...@@ -56,7 +61,7 @@ void UniboardSankoreTransition::documentTransition() ...@@ -56,7 +61,7 @@ void UniboardSankoreTransition::documentTransition()
QString backupDirectoryPath = UBFileSystemUtils::normalizeFilePath(UBDesktopServices::storageLocation(QDesktopServices::DesktopLocation)); QString backupDirectoryPath = UBFileSystemUtils::normalizeFilePath(UBDesktopServices::storageLocation(QDesktopServices::DesktopLocation));
if (fileInfoList.count() != 0){ if (fileInfoList.count() != 0){
mTransitionDlg = new UBUpdateDlg(0, fileInfoList.count(), backupDirectoryPath); mTransitionDlg = new UBUpdateDlg(NULL, fileInfoList.count(), backupDirectoryPath);
connect(mTransitionDlg, SIGNAL(updateFiles()), this, SLOT(startDocumentTransition())); connect(mTransitionDlg, SIGNAL(updateFiles()), this, SLOT(startDocumentTransition()));
connect(this, SIGNAL(transitionFinished(bool)), mTransitionDlg, SLOT(onFilesUpdated(bool))); connect(this, SIGNAL(transitionFinished(bool)), mTransitionDlg, SLOT(onFilesUpdated(bool)));
mTransitionDlg->show(); mTransitionDlg->show();
...@@ -65,6 +70,13 @@ void UniboardSankoreTransition::documentTransition() ...@@ -65,6 +70,13 @@ void UniboardSankoreTransition::documentTransition()
} }
void UniboardSankoreTransition::startDocumentTransition() void UniboardSankoreTransition::startDocumentTransition()
{
mThread = new UniboardSankoreThread(this);
mThread->start();
connect(this,SIGNAL(transitioningFile(QString)),mTransitionDlg,SLOT(transitioningFile(QString)));
}
void UniboardSankoreTransition::executeTransition()
{ {
bool result = false; bool result = false;
QString backupDestinationPath = mTransitionDlg->backupPath() + "/OldSankoreAndUniboardVersionsBackup"; QString backupDestinationPath = mTransitionDlg->backupPath() + "/OldSankoreAndUniboardVersionsBackup";
...@@ -78,14 +90,12 @@ void UniboardSankoreTransition::startDocumentTransition() ...@@ -78,14 +90,12 @@ void UniboardSankoreTransition::startDocumentTransition()
QFileInfoList::iterator fileInfo; QFileInfoList::iterator fileInfo;
QString sankoreDocumentDirectory = UBSettings::uniboardDocumentDirectory(); QString sankoreDocumentDirectory = UBSettings::uniboardDocumentDirectory();
QStringList qslNewDocs;
for (fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end() && result; fileInfo += 1) { for (fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end() && result; fileInfo += 1) {
if (fileInfo->isDir() && (fileInfo->fileName().startsWith("Uniboard Document ") || fileInfo->fileName().startsWith("Sankore Document "))){ if (fileInfo->isDir() && (fileInfo->fileName().startsWith("Uniboard Document ") || fileInfo->fileName().startsWith("Sankore Document "))){
QString sankoreDocumentName = fileInfo->fileName(); QString sankoreDocumentName = fileInfo->fileName();
emit transitioningFile(sankoreDocumentName);
sankoreDocumentName.replace("Uniboard","Sankore"); sankoreDocumentName.replace("Uniboard","Sankore");
result = UBFileSystemUtils::copyDir(fileInfo->filePath(),sankoreDocumentDirectory + "/" + sankoreDocumentName); result = UBFileSystemUtils::copyDir(fileInfo->filePath(),sankoreDocumentDirectory + "/" + sankoreDocumentName);
qslNewDocs << sankoreDocumentName;
} }
} }
...@@ -100,6 +110,23 @@ void UniboardSankoreTransition::startDocumentTransition() ...@@ -100,6 +110,23 @@ void UniboardSankoreTransition::startDocumentTransition()
} }
emit transitionFinished(result); emit transitionFinished(result);
}
UniboardSankoreThread::UniboardSankoreThread(QObject* parent):QThread(parent)
{
mTransitionDlg->hide();
} }
UniboardSankoreThread::~UniboardSankoreThread()
{
}
void UniboardSankoreThread::run()
{
UniboardSankoreTransition* pTransition = dynamic_cast<UniboardSankoreTransition*>(parent());
pTransition->executeTransition();
}
...@@ -3,9 +3,21 @@ ...@@ -3,9 +3,21 @@
#include <QObject> #include <QObject>
#include <QFileInfo> #include <QFileInfo>
#include <QThread>
#include "gui/UBUpdateDlg.h" #include "gui/UBUpdateDlg.h"
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
class UniboardSankoreThread : public QThread
{
Q_OBJECT
public:
UniboardSankoreThread(QObject* parent = 0);
~UniboardSankoreThread();
void run();
};
class UniboardSankoreTransition : public QObject class UniboardSankoreTransition : public QObject
{ {
Q_OBJECT Q_OBJECT
...@@ -13,6 +25,7 @@ public: ...@@ -13,6 +25,7 @@ public:
explicit UniboardSankoreTransition(QObject *parent = 0); explicit UniboardSankoreTransition(QObject *parent = 0);
~UniboardSankoreTransition(); ~UniboardSankoreTransition();
void documentTransition(); void documentTransition();
void executeTransition();
private: private:
...@@ -22,10 +35,12 @@ private: ...@@ -22,10 +35,12 @@ private:
protected: protected:
QString mUniboardSourceDirectory; QString mUniboardSourceDirectory;
QString mOldSankoreDirectory; QString mOldSankoreDirectory;
UniboardSankoreThread* mThread;
signals: signals:
void transitionFinished(bool result); void transitionFinished(bool result);
void docAdded(UBDocumentProxy* doc); void docAdded(UBDocumentProxy* doc);
void transitioningFile(QString documentName);
private slots: private slots:
void startDocumentTransition(); void startDocumentTransition();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment