Exemplo n.º 1
0
int CWizSettings::GetInt(const QString& strSection, const QString& strKey, int nDef /*= 0*/)
{
    QString str = GetString(strSection, strKey, WizIntToStr(nDef));
    int n = _ttoi(str);
    if (WizIntToStr(n) != str)
        return nDef;

    return n;
}
Exemplo n.º 2
0
BOOL CWizKMAccountsServer::GetMessages(__int64 nVersion, CWizUserMessageDataArray& arrayRet)
{
    int nCountPerPage = 100;
    //
    __int64 nNextVersion = nVersion + 1;
    //
    while (1)
    {
        CWizUserMessageDataArray arrayPageData;
        //
        if (!accounts_getMessages(nCountPerPage, nNextVersion, arrayPageData))
        {
            TOLOG2(_T("Failed to get message list: CountPerPage=%1, Version=%2"), WizIntToStr(nCountPerPage), WizInt64ToStr(nVersion));
            return FALSE;
        }
        //
        arrayRet.insert(arrayRet.end(), arrayPageData.begin(), arrayPageData.end());
        //
        for (CWizUserMessageDataArray::const_iterator it = arrayPageData.begin();
            it != arrayPageData.end();
            it++)
        {
            nNextVersion = std::max<__int64>(nNextVersion, it->nVersion);
        }
        //
        if (int(arrayPageData.size()) < nCountPerPage)
            break;
        //
        nNextVersion++;
    }
    //
    return TRUE;
}
Exemplo n.º 3
0
void CWizActions::buildMenu(QMenu* pMenu, CWizSettings& settings, const QString& strSection)
{
    int index = 0;
    while (true)
    {
        QString strKey = WizIntToStr(index);
        QString strAction = settings.GetString(strSection, strKey);

        if (strAction.isEmpty())
            break;

        if (strAction.startsWith("-"))
        {
            pMenu->addSeparator();
        }
        else if (strAction.startsWith("+"))
        {
            strAction.remove(0, 1);
            pMenu->addMenu(toMenu(pMenu, settings, strAction));
        }
        else
        {
            pMenu->addAction(actionFromName(strAction));
        }

        index++;
    }
}
Exemplo n.º 4
0
void CWizActions::buildMenuBar(QMenuBar* menuBar, const QString& strFileName)
{
    CWizSettings settings(strFileName);

    int index = 0;
    while (true)
    {
        QString strKey = WizIntToStr(index);
        QString strAction = settings.GetString("MainMenu", strKey);

        if (strAction.isEmpty())
            break;

        if (strAction.startsWith("-"))
        {
            continue;
        }
        else if (strAction.startsWith("+"))
        {
            strAction.remove(0, 1);
            QString strLocalText = QObject::tr(strAction.toUtf8());
            QMenu* pMenu = menuBar->addMenu(strLocalText);

            buildMenu(pMenu, settings, strAction);
        }
        else
        {
            menuBar->addAction(actionFromName(strAction));
        }

        index++;
    }
}
Exemplo n.º 5
0
    void updateInformation(CWizDatabase& db, const WIZDOCUMENTDATA& doc)
    {
        // retrieve document info and reset
        WIZDOCUMENTDATA data;
        if (!db.DocumentFromGUID(doc.strGUID, data)) {
            return;
        }

        //title
        if (m_titleEdit->text() != data.strTitle) {
            m_titleEdit->setText(data.strTitle);
        }

        //tags
        CWizStdStringArray arrayTagGUID;
        db.GetDocumentTags(data.strGUID, arrayTagGUID);

        QString strTagText = arrayTagGUID.empty() ? QString() : QString::number(arrayTagGUID.size());
        m_tagsButton->setText(strTagText);

        QString tagsShortcut = ::WizGetShortcut("EditNoteTags", "Alt+2");
        QString strTagsToolTip = QObject::tr("Tags (%1)").arg(tagsShortcut);
        m_tagsButton->setToolTip(strTagsToolTip);
        m_tagsButton->setShortcut(QKeySequence::fromString(tagsShortcut));

        //attachments
        int nAttachmentCount = db.GetDocumentAttachmentCount(data.strGUID);
        CString strAttachmentText = nAttachmentCount ? WizIntToStr(nAttachmentCount) : CString();
        m_attachmentButton->setText(strAttachmentText);
        QString attachmentShortcut = ::WizGetShortcut("EditNoteAttachments", "Alt+3");
        m_attachmentButton->setToolTip(QObject::tr("Attachments (%1)").arg(attachmentShortcut));
        m_attachmentButton->setShortcut(QKeySequence::fromString(attachmentShortcut));
    }
Exemplo n.º 6
0
CString CWizIndexBase::FormatModifiedQuerySQL2(const CString& strTableName,
                                               const CString& strFieldList,
                                               int nCount)
{
    return WizFormatString3(_T("select %1 from %2 where WIZ_VERSION = -1 limit 0, %3"),
                            strFieldList,
                            strTableName,
                            WizIntToStr(nCount));
}
Exemplo n.º 7
0
bool WizHtml2Zip(const QString& strHtml, const CWizStdStringArray& arrayResource, \
                 const QString& strMetaText, const QString& strZipFileName)
{
    CWizZipFile zip;
    if (!zip.open(strZipFileName))
        return false;

    QString strHtmlText = strHtml;
    if (strHtmlText.left(2) != " <!")
    {
        strHtmlText = "<!DOCTYPE html>" + strHtmlText;
    }
    CString strIndexFileName = Utils::PathResolve::tempPath() + WizIntToStr(GetTickCount()) + ".html";
    //if (!::WizSaveUnicodeTextToUnicodeFile(strIndexFileName, strHtml))
    if (!::WizSaveUnicodeTextToUtf8File(strIndexFileName, strHtmlText))
        return false;

    CString strMetaFileName = Utils::PathResolve::tempPath() + WizIntToStr(GetTickCount()) + ".xml";
    if (!::WizSaveUnicodeTextToUtf8File(strMetaFileName, strMetaText))
        return false;

    if (!zip.compressFile(strIndexFileName, "index.html"))
        return false;

    int failed = 0;

    if (!zip.compressFile(strMetaFileName, "meta.xml"))
        failed++;

    for (CWizStdStringArray::const_iterator it = arrayResource.begin();
        it != arrayResource.end();
        it++)
    {
        CString strFileName = *it;
        CString strNameInZip = "index_files/" + Utils::Misc::extractFileName(strFileName);
        if (!zip.compressFile(strFileName, strNameInZip))
        {
            failed++;
        }
    }

    return zip.close();
}
Exemplo n.º 8
0
bool CWizXmlRpcStructValue::GetString(const QString& strName, QString& str) const
{
    if (CWizXmlRpcIntValue* p = GetValue<CWizXmlRpcIntValue>(strName))
	{
		str = WizIntToStr(*p);
		return TRUE;
	}
    if (CWizXmlRpcStringValue* p = GetValue<CWizXmlRpcStringValue>(strName))
	{
		str = *p;
		return TRUE;
    }

	return FALSE;
}
Exemplo n.º 9
0
QString WIZOBJECTDATA::ObjectTypeToTypeString(WizObjectType eType)
{
    switch (eType) {
    case wizobjectTag:
        return "tag";
    case wizobjectStyle:
        return "style";
    case wizobjectDocumentAttachment:
        return "attachment";
    case wizobjectDocument:
        return "document";
    default:
        TOLOG1("Unknown guid type value: %1", WizIntToStr(eType));
        Q_ASSERT(0);
        return QString();
    }
}
Exemplo n.º 10
0
bool CppSQLite3DB::repair(const CString& strDBFileName, const CString& strRetFileName)
{
	try
	{
		CString strTempFileName = ::WizGlobal()->GetTempPath() + WizIntToStr(GetTickCount()) + _T(".tmp");
		//
		CppSQLite3DB dbSrc;
        dbSrc.open(strDBFileName);
		//
		if (!dbSrc.dump(strTempFileName))
		{
			throw CppSQLite3Exception(-1, "Failed to dump database!");
		}
		//
		dbSrc.close();
		//
        if (PathFileExists(strRetFileName))
		{
            DeleteFile(strRetFileName);
		}
		//
		CppSQLite3DB dbDest;
        dbDest.open(strRetFileName);
		//
		if (!dbDest.read(strTempFileName))
		{
			throw CppSQLite3Exception(-1, "Failed to rebuild database form index!");
		}
		//
		dbDest.close();
		//
#ifdef Q_OS_WIN32
                _flushall();
#endif
		//
		return true;
	}
	catch (CppSQLite3Exception& e)
	{
                TOLOG(e.errorMessage());
		return false;
	}
	//
	return false;
}
Exemplo n.º 11
0
CString WIZOBJECTDATA::ObjectTypeToTypeString(WizObjectType eType)
{
    switch (eType)
    {
    case wizobjectTag:
        return CString(_T("tag"));
    case wizobjectStyle:
        return CString(_T("style"));
    case wizobjectDocumentAttachment:
        return CString(_T("attachment"));
    case wizobjectDocument:
        return CString(_T("document"));
    default:
        TOLOG1(_T("Unknown guid type value: %1"), WizIntToStr(eType));
        ATLASSERT(FALSE);
        return CString();
    }
}
Exemplo n.º 12
0
void CWizActions::buildMenu(QMenu* pMenu, CWizSettings& settings, const QString& strSection)
{
    int index = 0;
    while (true)
    {
        QString strKey = WizIntToStr(index);
        QString strAction = settings.GetString(strSection, strKey);

        if (strAction.isEmpty())
            break;

        // no fullscreen mode menu
#ifndef Q_OS_MAC
        if (strAction == WIZACTION_GLOBAL_TOGGLE_FULLSCREEN) {
            index++;
            continue;
        }
#endif

#ifndef QT_DEBUG
        if (strAction == "actionAboutPlugins") {
            index++;
            continue;
        }
#endif

        if (strAction.startsWith("-"))
        {
            pMenu->addSeparator();
        }
        else if (strAction.startsWith("+"))
        {
            strAction.remove(0, 1);
            pMenu->addMenu(toMenu(pMenu, settings, strAction));
        }
        else
        {
            pMenu->addAction(actionFromName(strAction));
        }

        index++;
    }
}
Exemplo n.º 13
0
BOOL CWizKMDatabaseServer::data_upload(const QString& strObjectGUID, const QString& strObjectType, const QString& strObjectMD5, int allSize, int partCount, int partIndex, int partSize, const QByteArray& stream)
{
    __int64 nStreamSize = stream.size();
    if (partSize != (int)nStreamSize)
    {
        TOLOG2(_T("Fault error: stream_size=%1, part_size=%2"), WizIntToStr(int(nStreamSize)), WizIntToStr(partSize));
        return FALSE;
    }
    //
    CWizKMDataUploadParam param(m_kbInfo.strToken, m_kbInfo.strKbGUID, strObjectGUID, strObjectType, strObjectMD5, allSize, partCount, partIndex, stream);
    //
    if (!Call(_T("data.upload"), &param))
    {
        TOLOG(_T("Can not upload object part data!"));
        return FALSE;
    }
    //
    return TRUE;
}
Exemplo n.º 14
0
void CWizActions::buildMenu(QMenu* menu, const QString& strFileName)
{
    CWizSettings settings(strFileName);

    int index = 0;
    while (true)
    {
        QString strKey = WizIntToStr(index);
        QString strAction = settings.GetString("MainMenu", strKey);

        if (strAction.isEmpty())
            break;

        if (strAction.startsWith("-"))
        {
            continue;
        }
        else if (strAction.startsWith("+"))
        {
            strAction.remove(0, 1);
            QString strLocalText = QObject::tr(strAction.toUtf8());
            QMenu* pMenu = menu->addMenu(strLocalText);

            buildMenu(pMenu, settings, strAction);
        }
        else
        {
            menu->addAction(actionFromName(strAction));
        }

        index++;
    }

    QAction * actionQuit = actionFromName("actionExit");
    QAction* actionOptions = actionFromName("actionPreference");

    menu->addSeparator();
    menu->addAction(actionOptions);
    menu->addSeparator();
    menu->addAction(actionQuit);
}
Exemplo n.º 15
0
ProxyDialog::ProxyDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ProxyDialog)
{
    ui->setupUi(this);

    CWizSettings settings(Utils::PathResolve::globalSettingsFile());
    ui->editAddress->setText(settings.GetProxyHost());
    ui->editPort->setText(WizIntToStr(settings.GetProxyPort()));
    ui->editUserName->setText(settings.GetProxyUserName());
    ui->editPassword->setText(settings.GetProxyPassword());
    ui->editPassword->setEchoMode(QLineEdit::Password);
    ui->comboBox->setCurrentIndex((int)settings.GetProxyType());

    bool proxyStatus = settings.GetProxyStatus();
    ui->checkProxyStatus->setChecked(proxyStatus);

    enableControl(proxyStatus);

    connect(ui->checkProxyStatus, SIGNAL(stateChanged(int)), SLOT(proxyStatusChanged(int)));
}
Exemplo n.º 16
0
void WizXmlRpcResult::setResult(const QString& strMethodName, WizXmlRpcValue* pRet)
{
    m_pResult = pRet;
    if (!m_pResult)
    {
        TOLOG1("Can not execute xml-rpc: %1", strMethodName);
        m_bXmlRpcSucceeded = FALSE;
        m_bFault = FALSE;
        return;
    }
    //
    m_bXmlRpcSucceeded = TRUE;
    //
    if (WizXmlRpcFaultValue* pFault = getResultValue<WizXmlRpcFaultValue>())
    {
        m_bFault = TRUE;
        //
        m_nFaultCode = pFault->getFaultCode();
        m_strFaultString = pFault->getFaultString();
        TOLOG3("Failed to call xml rpc %1: %2, %3", strMethodName, WizIntToStr(m_nFaultCode), m_strFaultString);
    }
}
Exemplo n.º 17
0
bool WizFolder2Zip(const QString &strFolder, const QString &strMetaText,    \
                   const QString &strZipFileName, const QString &indexFile /*= "index.html"*/, \
                   const QString &strResourceFolder /*= "index_files"*/)
{
    CWizZipFile zip;
    if (!zip.open(strZipFileName))
        return false;

    CString strIndexFileName = strFolder + indexFile;

    CString strMetaFileName = Utils::PathResolve::tempPath() + WizIntToStr(GetTickCount()) + ".xml";
    if (!::WizSaveUnicodeTextToUtf8File(strMetaFileName, strMetaText))
        return false;

    if (!zip.compressFile(strIndexFileName, "index.html"))
        return false;

    int failed = 0;

    if (!zip.compressFile(strMetaFileName, "meta.xml"))
        failed++;

    QDir dir(strFolder + strResourceFolder);
    QStringList strResourceList = dir.entryList(QDir::Files, QDir::NoSort);
    for (QStringList::const_iterator it = strResourceList.begin(); it != strResourceList.end(); it++)
    {
        QString strFileName =dir.path() +"/" + *it;
        QString strNameInZip = "index_files/" + WizExtractFileName(strFileName);
        if (!zip.compressFile(strFileName, strNameInZip))
        {
            failed++;
        }
    }

    return zip.close();
}
Exemplo n.º 18
0
bool CWizDatabase::SetPasswordFalgs(UINT nFlags)
{
    return SetMeta(g_strAccountSection, "PasswordFlags", WizIntToStr(int(nFlags)));
}
Exemplo n.º 19
0
QString WizXmlRpcFaultValue::toString() const
{
    return WizFormatString2("Fault error: %1, %2", WizIntToStr(getFaultCode()), getFaultString());
}
Exemplo n.º 20
0
BOOL CWizXmlRpcBoolValue::Write(CWizXMLNode& nodeValue)
{
	nodeValue.SetChildNodeText(_T("boolean"), WizIntToStr(m_b ? 1 : 0));
	return TRUE;
}
Exemplo n.º 21
0
CString CWizXmlRpcIntValue::ToString() const
{
	return WizIntToStr(m_n);
}
Exemplo n.º 22
0
bool CWizXmlRpcIntValue::Write(CWizXMLNode& nodeValue)
{
    nodeValue.SetChildNodeText("int", WizIntToStr(m_n));
    return true;
}
Exemplo n.º 23
0
	virtual CString ToString() const { return WizFormatString2(_T("Fault error: %1, %2"), WizIntToStr(GetFaultCode()), GetFaultString()); }
Exemplo n.º 24
0
BOOL CWizSettings::SetInt(const QString& strSection, const QString& strKey, int val)
{
    return SetString(strSection, strKey, WizIntToStr(val));
}
Exemplo n.º 25
0
CString CWizXmlRpcBoolValue::ToString() const
{
	return WizIntToStr(m_b ? 1 : 0);
}
Exemplo n.º 26
0
void WizAnimateAction::setSingleIcons(const QString& strIconBaseName)
{
    int index = 1;
    while (1)
    {
        CString strFileName = ::WizGetSkinResourceFileName(Utils::WizStyleHelper::themeName(), strIconBaseName + WizIntToStr(index));
        if (strFileName.isEmpty())
            return;
        QIcon icon(strFileName);
        if (icon.isNull())
            return;

        m_icons.push_back(icon);

        index++;
    }
}
Exemplo n.º 27
0
CppSQLite3Exception::CppSQLite3Exception(const int nErrCode, const CString& errMessage)
    : mnErrCode(nErrCode)
{
    msErrMessage = WizFormatString3("%1[%2]: %3", errorCodeAsString(nErrCode), WizIntToStr(nErrCode), errMessage);
}
Exemplo n.º 28
0
QString CWizXmlRpcFaultValue::ToString() const
{
    return WizFormatString2(_T("Fault error: %1, %2"), WizIntToStr(GetFaultCode()), GetFaultString());
}