コード例 #1
0
ファイル: importdata.cpp プロジェクト: rodrigoccurvo/nixnote2
//***********************************************************
//* This will take a <tag> node and parse out the values.
//***********************************************************
void ImportData::processTagNode() {
    QLOG_DEBUG() << "Processing Tag Node";

    Tag tag;
    bool tagIsDirty = false;
    bool atEnd = false;

    // Loop through until we are at the end of the </tag>
    while(!atEnd) {
        if (backup || importTags) {
            if (reader->isStartElement()) {
                QString name = reader->name().toString().toLower();
                if (name == "guid") {
                    tag.guid = textValue();
                }
                if (name == "name") {
                    tag.name = textValue();
                }
                if (name == "updatesequencenumber") {
                    tag.updateSequenceNum = intValue();
                }
                if (name == "parentguid") {
                    tag.parentGuid = textValue();
                }
                if (name == "Dirty") {
                    if (booleanValue())
                        tagIsDirty = true;
                    else
                        tagIsDirty = false;
                }
            }
        }
        reader->readNext();
        QString endName = reader->name().toString().toLower();
        if (endName == "tag" && reader->isEndElement())
            atEnd = true;
    }

    // We have a good tag, now let's save it to the database
    TagTable tagTable(global.db);
    QString name(tag.name);

    // Check if we have a tag by this name already.  If we
    // do then we treat this as an update.
    qint32 lid = tagTable.findByName(name,0);
    if (lid <= 0) {
        lid = tagTable.getLid(tag.guid);
    }
    if (lid <= 0) {
        tagTable.add(0, tag,tagIsDirty, 0);
    } else {
//        qint32 oldLid = tagTable.getLid(tag.guid);
//        if (oldLid != lid)
//            tagTable.merge(oldLid, lid);
        tagTable.sync(lid, tag, 0);
//        notebookTable.updateGuid(lid, notebook.guid);
        tagTable.setDirty(lid, tagIsDirty);
    }
    return;
}
コード例 #2
0
ファイル: CConfig.cpp プロジェクト: badboy/p-twit
int Config::load()
{
	loaded = FALSE;
	if(file.size() <= 0) return 0;
	if(!doc.LoadFile(file.c_str())) return 0;
	TiXmlElement* root = doc.RootElement();
	if(!root)
		return 0;
	if (strcmp(root->Value( ), "psptwitter") != 0)
		return 0;
	for(TiXmlElement* elem = root->FirstChildElement( ); elem; elem = elem->NextSiblingElement())
	{
		if(strcmp(elem->Value(), "account") == 0)
		{
			TiXmlElement *_nick = elem->FirstChildElement("username");
			TiXmlElement *_pw = elem->FirstChildElement("password");

			if(_nick != NULL) user_nick = textValue(_nick);
			if(_pw != NULL) user_password = textValue(_pw);
			set_base64_code();
		}

		if(strcmp(elem->Value(), "config") == 0)
		{
			TiXmlElement *_wlan = elem->FirstChildElement("wlan_connection");
			if(_wlan != NULL) wlan_connection = atoi(textValue(_wlan));
		}
	}
	loaded = TRUE;
	return 1;
}
コード例 #3
0
//***********************************************************
//* Process any type of data node
//***********************************************************
void ImportData::processData(QString nodeName, Data &data) {
    nodeName.toLower();
    bool atEnd = false;
    while(!atEnd) {
        if (reader->isStartElement()) {
            QString name = reader->name().toString().toLower();
            if (name == "size") {
                data.size = intValue();
                data.__isset.size = true;
            }
            if (name == "body") {
                QString x = textValue();
                QByteArray bin = QByteArray::fromHex(x.toLocal8Bit());
                data.body.clear();
                data.body.append(bin.data(), bin.size());
                data.__isset.body = true;
            }
            if (name == "bodyhash") {
               QByteArray hexData = textValue().toLocal8Bit();
                QByteArray binData = QByteArray::fromHex(hexData);
                data.bodyHash.clear();
                data.bodyHash.append(binData.data(), binData.size());
                data.__isset.bodyHash = true;
            }
        }
        reader->readNext();
        QString nName = reader->name().toString().toLower();
        if (nName == nodeName.toLower() && reader->isEndElement())
            atEnd = true;
    }
}
コード例 #4
0
void InputDialog::setSelection(int offset, int length)
{
   offset = std::min(offset, textValue().size());
   length = std::min(length,
                     textValue().size() - offset);

   ui->lineEdit->setSelection(offset, length);
}
コード例 #5
0
//***********************************************************
//* Process a node that has the <noteresourceattribute>
//***********************************************************
void ImportData::processResourceAttributes(ResourceAttributes &attributes) {
    bool atEnd = false;
    while(!atEnd) {
        if (reader->isStartElement()) {
            QString name = reader->name().toString().toLower();
            if (name == "cameramake") {
                attributes.cameraMake = textValue().toStdString();
                attributes.__isset.cameraMake = true;
            }
            if (name == "cameramodel") {
                attributes.cameraModel = textValue().toStdString();
                attributes.__isset.cameraModel =true;
            }
            if (name == "filename") {
                attributes.fileName = textValue().toStdString();
                attributes.__isset.fileName = true;
            }
            if (name == "recotype") {
                attributes.recoType = textValue().toStdString();
                attributes.__isset.fileName = true;
            }
            if (name  == "sourceurl") {
                attributes.sourceURL = textValue().toStdString();
                attributes.__isset.sourceURL = true;
            }
            if (name == "altitude") {
                attributes.altitude = doubleValue();
                attributes.__isset.altitude = true;
            }
            if (name == "longitude") {
                attributes.longitude = doubleValue();
                attributes.__isset.longitude = true;
            }
            if (name == "altitude") {
                attributes.latitude = doubleValue();
                attributes.__isset.latitude = true;
            }
            if (name == "timestamp") {
                attributes.timestamp = longValue();
                attributes.__isset.timestamp = true;
            }
            if (name == "attachment") {
                attributes.attachment = booleanValue();
                attributes.__isset.attachment = true;
            }
            if (name == "clientwillindex") {
                attributes.clientWillIndex = booleanValue();
                attributes.__isset.clientWillIndex =true;
            }
        }
        reader->readNext();
        QString endName = reader->name().toString().toLower();
        if (endName == "noteresourceattribute" && reader->isEndElement())
            atEnd = true;
    }
}
コード例 #6
0
//***********************************************************
//* Import a shared notebook
//***********************************************************
void ImportData::processSharedNotebookNode() {

    SharedNotebook sharedNotebook;
    bool sharedNotebookIsDirty = false;

    QLOG_ERROR() << "Shared notebook database support not implemented yet";

    bool atEnd = false;
    while(!atEnd) {
        if (reader->isStartElement()) {
            QString name = reader->name().toString().toLower();
            if (name == "id") {
                sharedNotebook.id = intValue();
                sharedNotebook.__isset.id = true;
            }
            if (name == "userid") {
                sharedNotebook.userId = intValue();
                sharedNotebook.__isset.userId = true;
            }
            if (name == "email") {
                sharedNotebook.email = textValue().toStdString();
                sharedNotebook.__isset.email =true;
            }
            if (name == "notebookguid") {
                sharedNotebook.notebookGuid = textValue().toStdString();
                sharedNotebook.__isset.notebookGuid = true;
            }
            if (name == "sharekey") {
                sharedNotebook.shareKey = textValue().toStdString();
                sharedNotebook.__isset.shareKey = true;
            }
            if (name == "username") {
                sharedNotebook.username = textValue().toStdString();
                sharedNotebook.__isset.username = true;
            }
            if (name == "servicecreated") {
                sharedNotebook.serviceCreated = longValue();
                sharedNotebook.__isset.serviceCreated = true;
            }
            if (name == "dirty") {
                if (booleanValue())
                    sharedNotebookIsDirty = true;
                else
                    sharedNotebookIsDirty = false;
            }
        }
        reader->readNext();
        QString endName = reader->name().toString().toLower();
        if (endName == "sharednotebook" && reader->isEndElement())
            atEnd = true;		}
    return;
}
コード例 #7
0
/**************************************************************************
* Class AHelloWindow :: editText -- Creates and shows a dialog window     *
*   for inputting text that will be used  to replace the text string      *
**************************************************************************/
AHelloWindow &
  AHelloWindow :: editText()
{
/*------------------------------------------------------------------------|
|  Store the current value of the text to be changed.                     |
|  Set the text in the information area from the dialog information       |
|    string in the resource file.                                         |
|------------------------------------------------------------------------*/
  IString textValue(hello.text());
  infoArea.setDefaultText(STR_INFODLG);

/*------------------------------------------------------------------------|
|  Create a new text dialog with textValue as the string to edit and      |
|    AHelloWindow as the owner window.                                    |
|  Show the dialog modally.  This means that the owner window cannot have |
|    the focus back until the dialog is ended.                            |
|------------------------------------------------------------------------*/
  ATextDialog textDialog(textValue,this);
  textDialog.showModally();

/*------------------------------------------------------------------------|
|  If the OK button was used to end the dialog, then the static text,     |
|    hello, is set to the textValue string.  Else, it is not changed.     |
|  Reset the information area default text.                               |
|------------------------------------------------------------------------*/
  if (textDialog.result() == DID_OK)
        hello.setText(textValue);
  infoArea.setDefaultText(STR_INFO);

  return (*this);                       //Return a reference to the frame
}  /* end AHelloWindow :: editText() */
コード例 #8
0
ファイル: importdata.cpp プロジェクト: rodrigoccurvo/nixnote2
//* Process the  list of tags for a note
void ImportData::processNoteTagList(QStringList &guidList, QStringList &names) {
    bool atEnd = false;
    while(!atEnd) {
        if (reader->isStartElement()) {
            QString name = reader->name().toString().toLower();
            if (name == "guid")
                guidList.append(textValue());
        }
        reader->readNext();
        QString endName = reader->name().toString().toLower();
        if (endName == "notetags" && reader->isEndElement())
            atEnd = true;
    }

    // Now look for any matches with existing ones.  If they don't
    // exist we create a dummy record
    TagTable tagTable(global.db);
    for (qint32 i=0; i<guidList.size(); i++) {
        qint32 lid = tagTable.getLid(guidList[i]);
        if (lid == 0) {
            Tag newTag;
            newTag.guid = guidList[i];
            newTag.name = "newtag";
            tagTable.add(0, newTag, false, 0);
            names.append(newTag.name);
        } else {
            Tag tag;
            tagTable.get(tag, lid);
            names.append(tag.name);
        }
    }
}
コード例 #9
0
//***********************************************************
//* Process an <attributes> node
//***********************************************************
void ImportData::processNoteAttributes(NoteAttributes &attributes) {

    bool atEnd = false;
    while(!atEnd) {
        if (reader->isStartElement()) {
            QString name = reader->name().toString().toLower();
            if (name == "author" && !reader->isEndElement()) {
                attributes.author = textValue().toStdString();
                attributes.__isset.author = true;
            }
            if (name == "sourceurl" && !reader->isEndElement()) {
                attributes.sourceURL = textValue().toStdString();
                attributes.__isset.sourceURL = true;
            }
            if (name == "source" && !reader->isEndElement()) {
                attributes.source = textValue().toStdString();
                attributes.__isset.source = true;
            }
            if (name == "sourceapplication" && !reader->isEndElement()) {
                attributes.sourceApplication = textValue().toStdString();
                attributes.__isset.sourceApplication = true;
            }
            if (name == "altitude" && !reader->isEndElement()) {
                attributes.altitude = doubleValue();
                attributes.__isset.altitude = true;
            }
            if (name == "longitude" && !reader->isEndElement()) {
                attributes.longitude = doubleValue();
                attributes.__isset.longitude = true;
            }
            if (name == "latitude" && !reader->isEndElement()) {
                attributes.latitude = doubleValue();
                attributes.__isset.latitude = true;
            }
            if (name == "subjectdate" && !reader->isEndElement()) {
                attributes.subjectDate = longLongValue();
                attributes.__isset.subjectDate = true;
            }
        }
        reader->readNext();
        QString endName = reader->name().toString().toLower();
        if (endName == "noteattributes" && reader->isEndElement())
            atEnd = true;
    }

    return;
}
コード例 #10
0
ファイル: importdata.cpp プロジェクト: rodrigoccurvo/nixnote2
//***********************************************************
//* take a node's value and return true/false based upon
//* its value
//***********************************************************
bool ImportData::booleanValue() {
    QString value = textValue();
    value.toLower();
    if (value == "1" || value == "true")
        return true;
    else
        return false;
}
コード例 #11
0
//***********************************************************
//* Process a <savedsearch> node.
//***********************************************************
void ImportData::processSavedSearchNode() {
    SavedSearch search;
    bool searchIsDirty = false;
    SearchTable searchTable;

    bool atEnd = false;

    // Keep going until we hit </savedsearch>
    while(!atEnd) {
        if (reader->isStartElement()) {
            QString name = reader->name().toString().toLower();
            if (name == "guid")  {
                search.guid = textValue().toStdString();
                search.__isset.guid = true;
            }
            if (name == "name") {
                search.name = textValue().toStdString();
                search.__isset.name = true;
            }
            if (name == "updatesequencenumber") {
                search.updateSequenceNum = intValue();
                search.__isset.updateSequenceNum = true;
            }
            if (name == "query") {
                search.query = textValue().toStdString();
                search.__isset.query = true;
            }
            if (name == "dirty") {
                if (booleanValue())
                    searchIsDirty = true;
            }
        }
        reader->readNext();
        QString endName = reader->name().toString().toLower();
        if (endName == "savedsearch" && reader->isEndElement())
            atEnd = true;
    }

    // Add this search to the table
    searchTable.add(0,search, searchIsDirty);
    return;
}
コード例 #12
0
ファイル: importenex.cpp プロジェクト: AustinPowered/Nixnote2
//***********************************************************
//* Process a node that has the <noteresourceattribute>
//***********************************************************
void ImportEnex::processResourceAttributes(ResourceAttributes &attributes) {
    bool atEnd = false;
    while(!atEnd) {
        if (reader->isStartElement()) {
            QString name = reader->name().toString().toLower();
            if (name == "camera-make") {
                attributes.cameraMake = textValue();
            }
            if (name == "camera-model") {
                attributes.cameraModel = textValue();
            }
            if (name == "file-name") {
                attributes.fileName = textValue();
            }
            if (name == "reco-type") {
                attributes.recoType = textValue();
            }
            if (name  == "source-url") {
                attributes.sourceURL = textValue();
            }
            if (name == "altitude") {
                attributes.altitude = doubleValue();
            }
            if (name == "longitude") {
                attributes.longitude = doubleValue();
            }
            if (name == "altitude") {
                attributes.latitude = doubleValue();
            }
            if (name == "timestamp") {
                attributes.timestamp = longValue();
            }
            if (name == "attachment") {
                attributes.attachment = booleanValue();
            }
        }
        reader->readNext();
        QString endName = reader->name().toString().toLower();
        if (endName == "resource-attributes" && reader->isEndElement())
            atEnd = true;
    }
}
コード例 #13
0
	void GetPassword (const QString& key, const QString& diaText,
			const ICoreProxy_ptr& proxy,
			const EitherCont<void (), void (QString)>& cont,
			QObject *depender,
			bool useStored)
	{
		if (useStored)
		{
			const auto& result = GetPasswordHelper (key.toUtf8 (), proxy);
			if (!result.isNull ())
			{
				cont.Right (result);
				return;
			}
		}

		const auto dialog = new QInputDialog;
		dialog->setInputMode (QInputDialog::TextInput);
		dialog->setWindowTitle ("LeechCraft");
		dialog->setLabelText (diaText);
		dialog->setTextEchoMode (QLineEdit::Password);
		dialog->setAttribute (Qt::WA_DeleteOnClose);

		if (depender)
			QObject::connect (depender,
					SIGNAL (destroyed ()),
					dialog,
					SLOT (deleteLater ()));

		new Util::SlotClosure<Util::DeleteLaterPolicy>
		{
			[dialog, cont]
			{
				const auto& value = dialog->textValue ();
				if (value.isEmpty ())
					cont.Left ();
				else
					cont.Right (value);
			},
			dialog,
			SIGNAL (accepted ()),
			dialog
		};

		new Util::SlotClosure<Util::DeleteLaterPolicy>
		{
			[cont] { cont.Left (); },
			dialog,
			SIGNAL (rejected ()),
			dialog
		};

		dialog->show ();
	}
コード例 #14
0
ファイル: importenex.cpp プロジェクト: AustinPowered/Nixnote2
//***********************************************************
//* Process a <noteresource> node.
//***********************************************************
void ImportEnex::processResource(Resource &resource) {
    bool atEnd = false;

    resource.active = true;

    while(!atEnd) {
        if (reader->isStartElement()) {
            QString name = reader->name().toString().toLower();
            QUuid uuid;
            QString g =  uuid.createUuid().toString().replace("{","").replace("}","");
            resource.guid = g;
            if (name == "active") {
                resource.active =  booleanValue();
            }
            if (name == "mime") {
                resource.mime = textValue();
            }
            if (name == "duration") {
                resource.duration = shortValue();
            }
            if (name == "height") {
                resource.height = shortValue();
            }
            if (name == "width") {
                resource.width = shortValue();
            }
            if (name == "data") {
                Data d;
                resource.data = d;
                processData("Data", resource.data);
            }
            if (name == "alternate-data") {
                Data d;
                resource.alternateData = d;
                processData("AlternateData", resource.data);
            }
            if (name == "recognition-data") {
                Data d;
                resource.recognition = d;
                processData("RecognitionData", resource.recognition);
            }
            if (name == "resource-attributes") {
                ResourceAttributes ra;
                resource.attributes = ra;
                processResourceAttributes(resource.attributes);
            }
        }
        reader->readNext();
        QString endName = reader->name().toString().toLower();
        if (endName == "resource" && reader->isEndElement())
            atEnd = true;
    }
}
コード例 #15
0
ファイル: importenex.cpp プロジェクト: AustinPowered/Nixnote2
//***********************************************************
//* Process any type of data node
//***********************************************************
void ImportEnex::processData(QString nodeName, Data &data) {
    nodeName.toLower();

    QString x = textValue();
    QByteArray ba;
    ba.append(x);
    QByteArray bin = QByteArray::fromBase64(ba);
    data.body.clear();
    data.body = bin;
    data.size = bin.length();

    QCryptographicHash md5hash(QCryptographicHash::Md5);
    QByteArray hash = md5hash.hash(bin, QCryptographicHash::Md5);
    data.bodyHash = hash;
}
コード例 #16
0
ファイル: DoubleValidator.cpp プロジェクト: dragonlet/fw4spl
bool DoubleValidator::TransferFromWindow()
{
    wxTextCtrl * textCtrl( wxStaticCast(GetWindow(), wxTextCtrl) );
    wxString textValue( textCtrl->GetValue() );
    double doubleValue;
    bool success;

    success = textValue.ToDouble( &doubleValue );
    OSLM_DEBUG( "DoubleValidator::TransferFromWindow() => " << doubleValue );
    if( success &&
        (m_minValue == m_maxValue || doubleValue >= m_minValue && doubleValue <= m_maxValue))
    {
        this->m_value = (double) doubleValue;
    }
    return success;
}
コード例 #17
0
ファイル: importdata.cpp プロジェクト: rodrigoccurvo/nixnote2
//***********************************************************
//* Process any type of data node
//***********************************************************
void ImportData::processData(QString nodeName, Data &data) {
    QLOG_DEBUG() << "Processing Data Node";
    nodeName.toLower();
    bool atEnd = false;
    while(!atEnd) {
        if (reader->isStartElement()) {
            QString name = reader->name().toString().toLower();
//            if (name == "size") {
//                data.size = intValue();
//                data.__isset.size = true;
//            }
            if (name == "body") {
                QString x = textValue();
                QByteArray bin = QByteArray::fromHex(x.toLocal8Bit());
                data.body.clear();
                data.body = bin;

                QCryptographicHash md5hash(QCryptographicHash::Md5);
                QByteArray hash = md5hash.hash(bin, QCryptographicHash::Md5);
                QLOG_DEBUG() << "Actual:" << hash.toHex();

                data.bodyHash.clear();
                data.bodyHash = hash;


                data.size = bin.size();
            }
//            if (name == "bodyhash") {
//                QByteArray hexData = textValue().toLocal8Bit();
//                QLOG_DEBUG() << hexData;
//                //QByteArray hexData;
//                //hexData.append(textValue());
//                QByteArray binData = QByteArray::fromHex(hexData);
//                QLOG_DEBUG() << QByteArray::fromHex(hexData);
//                data.bodyHash.clear();
//                data.bodyHash.append(binData.data(), binData.size());
//                data.__isset.bodyHash = true;
//            }
        }
        reader->readNext();
        QString nName = reader->name().toString().toLower();
        if (nName == nodeName.toLower() && reader->isEndElement())
            atEnd = true;
    }
}
コード例 #18
0
//***********************************************************
//* Process a shared notebook
//***********************************************************
void ImportData::processLinkedNotebookNode() {
    LinkedNotebook  linkedNotebook;
    bool linkedNotebookIsDirty=false;

    QLOG_ERROR() << "Linked notebook database support not implemented yet";

    bool atEnd = false;
    while(!atEnd) {
        if (reader->isStartElement()) {
            QString name = reader->name().toString().toLower();
            if (name == "guid") {
                linkedNotebook.guid = textValue().toStdString();
                linkedNotebook.__isset.guid = true;
            }
            if (name == "shardid") {
                linkedNotebook.shardId = textValue().toStdString();
                linkedNotebook.__isset.shardId = true;
            }
            if (name == "updatesequencenumber") {
                linkedNotebook.updateSequenceNum = intValue();
                linkedNotebook.__isset.updateSequenceNum = true;
            }
            if (name == "sharekey") {
                linkedNotebook.shareKey = textValue().toStdString();
                linkedNotebook.__isset.shareKey = true;
            }
            if (name == "sharename") {
                linkedNotebook.shareName = textValue().toStdString();
                linkedNotebook.__isset.shareName = true;
            }
            if (name == "uri") {
                linkedNotebook.uri = textValue().toStdString();
                linkedNotebook.__isset.uri = true;
            }
            if (name == "username") {
                linkedNotebook.username = textValue().toStdString();
                linkedNotebook.__isset.username = true;
            }
            if (name == "dirty") {
                if (booleanValue())
                    linkedNotebookIsDirty = true;
            }
        }
        reader->readNext();
        QString endName = reader->name().toString().toLower();
        if (endName == "linkednotebook" && reader->isEndElement())
            atEnd = true;		}
    return;
}
コード例 #19
0
ファイル: importenex.cpp プロジェクト: AustinPowered/Nixnote2
//***********************************************************
//* take a node's value and return a long value
//***********************************************************
qlonglong ImportEnex::datetimeValue() {
    QString value = textValue();
    QString year = value.mid(0,4);
    QString month = value.mid(4,2);
    QString day = value.mid(6,2);

    QString hour = value.mid(9,2);
    QString minute = value.mid(11,2);
    QString second = value.mid(13,2);

    QDate date;
    date.setDate(year.toInt(), month.toInt(), day.toInt());
    QTime time;
    time.setHMS(hour.toInt(), minute.toInt(), second.toInt());

    QDateTime dt;
    dt.setDate(date);
    dt.setTime(time);
    dt.setTimeSpec(Qt::UTC);

    return dt.toMSecsSinceEpoch();
}
コード例 #20
0
ファイル: importdata.cpp プロジェクト: rodrigoccurvo/nixnote2
//***********************************************************
//* take a node's value and return longlong.  This is useful
//* for date values.
//***********************************************************
qlonglong ImportData::longLongValue() {
    return textValue().toLongLong();
}
コード例 #21
0
ファイル: importdata.cpp プロジェクト: rodrigoccurvo/nixnote2
//***********************************************************
//* take a node's value and return a double value
//***********************************************************
double ImportData::doubleValue() {
    return textValue().toDouble();
}
コード例 #22
0
double BatchImport::doubleValue() {
    return textValue().toDouble();
}
コード例 #23
0
ファイル: importdata.cpp プロジェクト: rodrigoccurvo/nixnote2
//***********************************************************
//* take a node's value and return the integer value
//***********************************************************
qint32 ImportData::intValue() {
    return textValue().toLong();
}
コード例 #24
0
ファイル: importdata.cpp プロジェクト: rodrigoccurvo/nixnote2
//***********************************************************
//* Process a <notebook> node
//***********************************************************
void ImportData::processNotebookNode() {
    QLOG_DEBUG() << "Processing Notebook Node";


    Notebook notebook;
    bool notebookIsDirty = false;
    bool notebookIsLocal = false;
    Publishing publishing;
//    bool notebookIsReadOnly = false;

//    notebookIcon = null;
    bool atEnd = false;

    // Loop through until we hit </notebook>
    while(!atEnd) {
        if (backup || importNotebooks) {
            if (reader->isStartElement()) {
                QString name = reader->name().toString().toLower();
                if (name == "guid") {
                    notebook.guid = textValue();
                }
                if (name == "name") {
                    notebook.name = textValue();
                }
                if (name == "updatesequencenumber") {
                    notebook.updateSequenceNum = intValue();
                }
                if (name == "servicecreated") {
                    notebook.serviceCreated = longValue();
                }
                if (name == "serviceupdated") {
                    notebook.serviceUpdated = longValue();
                }
                if (name == "defaultnotebook") {
                    notebook.defaultNotebook = booleanValue();
                }
                if (name == "dirty") {
                    if (booleanValue())
                        notebookIsDirty = true;
                }
                if (name == "localnotebook") {
                    if (booleanValue())
                        notebookIsLocal = true;
                }
                if (name == "publishingpublicdescription") {
                    publishing.publicDescription = textValue();
                }
                if (name == "publishinguri") {
                    publishing.uri = textValue();
                }
                if (name == "publishingorder") {
                    //notebook->publishing.order =
                      //      NoteSortOrder.;
                    QLOG_DEBUG() << "!!!!!!!!!!!! PublishingOrder not completed in import";
                }
                if (name == "PublishingAscending") {
                    if (booleanValue())
                        publishing.ascending = true;
                    else
                        publishing.ascending = false;
                }
                if (name == "icon") {
                    //byte[] b = textValue().getBytes();   // data binary
                    //QByteArray hexData = new QByteArray(b);
                    //QByteArray binData = new QByteArray(QByteArray.fromHex(hexData));
                    //notebookIcon = new QIcon(QPixmap.fromImage(QImage.fromData(binData)));
                }
                if (name == "stack") {
                    notebook.stack = textValue();
                }
            }
        }
        reader->readNext();
        QString endName = reader->name().toString().toLower();
        if (endName == "notebook" && reader->isEndElement())
            atEnd = true;
    }
    notebook.publishing = publishing;

    // We are at the end.  We should have a valid notebook now
    NotebookTable notebookTable(global.db);

    // Check if there is a notebook by this name already.
    // If one exists, we treat this as an update
    qint32 lid = notebookTable.findByName(notebook.name);
    if (lid <= 0) {
        lid = notebookTable.getLid(notebook.guid);
    }
    if (lid <= 0) {
        notebookTable.add(lid,notebook,notebookIsDirty, notebookIsLocal);
    } else {
        qint32 oldLid = notebookTable.getLid(notebook.guid);
        if (oldLid != lid)
            notebookTable.merge(oldLid, lid);
        notebookTable.sync(lid, notebook);
//        notebookTable.updateGuid(lid, notebook.guid);
        notebookTable.setDirty(lid, notebookIsDirty);
    }
    return;
}
コード例 #25
0
short BatchImport::shortValue() {
    return textValue().toShort();
}
コード例 #26
0
//***********************************************************
//* Process a <note> tag
//***********************************************************
void BatchImport::addNoteNode() {
    Note note;
    note.title = QString(tr("Untitled Note"));
    QUuid uuid;
    QString newGuid = uuid.createUuid().toString().replace("{", "").replace("}", "");
    note.guid = newGuid;
    QStringList tagNames;
    QStringList tagGuids;
    QString newNoteBody = QString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")+
           QString("<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">")+
           QString("<en-note style=\"word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;\"><br/></en-note>");
    note.active = true;
    note.content = newNoteBody;
    note.created = QDateTime::currentMSecsSinceEpoch();
    note.updated = QDateTime::currentMSecsSinceEpoch();

    bool atEnd = false;
    while(!atEnd) {
        QString name = reader->name().toString().toLower();
        if (name == "title" && !reader->isEndElement()) {
            note.title = textValue();
        }
        if (name == "created" && !reader->isEndElement()) {
            QString dateString = textValue();
            //QDateTime date = QDateTime::fromString("2010-10-25T10:28:58.570Z", "yyyy-MM-ddTHH:mm:ss.zzzZ");
            QDateTime date = QDateTime::fromString(dateString, "yyyy-MM-ddTHH:mm:ss.zzzZ");
            note.created = date.toMSecsSinceEpoch();
        }
        if (name == "updated" && !reader->isEndElement()) {
            QString dateString = textValue();
            QDateTime date = QDateTime::fromString(dateString, "yyyy-MM-ddTHH:mm:ss.zzzZ");
            note.updated = date.toMSecsSinceEpoch();
        }
        if (name == "notebook" && !reader->isEndElement()) {
            QString notebookName = textValue();
            NotebookTable notebookTable(global.db);
            qint32 lid = notebookTable.findByName(notebookName);
            QString notebookGuid;

            // Do we need to add the notebook?
            if (lid == 0) {
                Notebook book;
                book.name = notebookName;
                QUuid uuid;
                QString newGuid = uuid.createUuid().toString().replace("{", "").replace("}", "");
                book.guid = newGuid;
                notebookGuid = newGuid;
                lid = notebookTable.add(0, book, true, false);
            } else {
                notebookTable.getGuid(notebookGuid, lid);
            }
            note.notebookGuid = notebookGuid;
        }
        if (name == "content" && !reader->isEndElement()) {
            note.content = textValue();
        }
        if (name == "tag" && !reader->isEndElement()) {
            QString tagName = textValue();
            TagTable tagTable(global.db);
            qint32 tagLid = tagTable.findByName(tagName, 0);
            QString tagGuid;

            // Do we need to add the tag?
            if (tagLid == 0) {
                Tag tag;
                tag.name = tagName;
                QUuid uuid;
                tagGuid = uuid.createUuid().toString().replace("{", "").replace("}", "");
                tag.guid = tagGuid;
                tagTable.add(0, tag, true, 0);
            } else {
                tagTable.getGuid(tagGuid, tagLid);
            }
            tagNames.append(tagName);
            tagGuids.append(tagGuid);
        }
        reader->readNext();
        QString endName = reader->name().toString().toLower();
        if (endName == "noteadd" && reader->isEndElement()) {
            atEnd = true;
            note.tagGuids = tagGuids;
            note.tagNames = tagNames;
            NoteTable ntable(global.db);

            if (!note.notebookGuid.isSet()) {
                NotebookTable bookTable(global.db);
                QString book = bookTable.getDefaultNotebookGuid();
                note.notebookGuid = book;
            }

            ntable.add(0, note, true);
        }
    }
    return;
}
コード例 #27
0
ファイル: importdata.cpp プロジェクト: rodrigoccurvo/nixnote2
//***********************************************************
//* Process a <noteresource> node.
//***********************************************************
void ImportData::processResource(Resource &resource) {
    QLOG_DEBUG() << "Processing Resource Node";

    bool atEnd = false;
    //bool isDirty = false;

    while(!atEnd) {
        if (reader->isStartElement()) {
            QString name = reader->name().toString().toLower();
            if (name == "guid") {
                resource.guid = textValue();
            }
            if (!backup) {
                QUuid uuid;
                QString g =  uuid.createUuid().toString().replace("{","").replace("}","");
                resource.guid = g;
            }
            if (name == "noteguid") {
                QString tx = textValue();
                resource.noteGuid = tx;
            }
            if (name == "updatesequencenumber") {
                resource.updateSequenceNum = intValue();
            }
            if (name == "active") {
                resource.active =  booleanValue();
            }
            if (name == "mime") {
                resource.mime = textValue();
            }
            if (name == "duration") {
                resource.duration = shortValue();
            }
            if (name == "height") {
                resource.height = shortValue();
            }
            if (name == "width") {
                resource.width = shortValue();
            }
//            if (name == "dirty")
//                isDirty = booleanValue();
            if (name == "data") {
                Data data;
                resource.data = data;
                processData("Data", resource.data);
            }
            if (name == "alternatedata") {
                processData("AlternateData", resource.data);
            }
            if (name == "recognitiondata") {
                processData("RecognitionData", resource.recognition);
            }
            if (name == "noteresourceattributes") {
                processResourceAttributes(resource.attributes);
            }
        }
        reader->readNext();
        QString endName = reader->name().toString().toLower();
        if (endName == "noteresource" && reader->isEndElement())
            atEnd = true;
    }
}
コード例 #28
0
ファイル: importdata.cpp プロジェクト: rodrigoccurvo/nixnote2
//***********************************************************
//* Process a <note> tag
//***********************************************************
void ImportData::processNoteNode() {
    QLOG_DEBUG() << "Processing Note Node";
    Note note;
    QUuid uuid;
    QString newGuid = uuid.createUuid().toString().replace("{", "").replace("}", "");
    note.guid = newGuid;
    NoteMetaData meta;
    bool noteIsDirty = false;

    bool atEnd = false;
    while(!atEnd) {
        QString name = reader->name().toString().toLower();
        if (name == "guid" && !reader->isEndElement() && backup) {
            note.guid = textValue();
            noteList.append(note.guid);
        }
        if (name == "updatesequencenumber" && !reader->isEndElement()) {
            note.updateSequenceNum = textValue().toLong();
        }
        if (name == "title" && !reader->isEndElement()) {
            note.title = textValue();
        }
        if (name == "created" && !reader->isEndElement()) {
            note.created = longLongValue();
        }
        if (name == "updated" && !reader->isEndElement()) {
            note.updated = longLongValue();
        }
        if (name == "deleted" && !reader->isEndElement()) {
            note.deleted = longLongValue();
        }
        if (name == "active" && !reader->isEndElement()) {
            note.active = booleanValue();
        }
        if (name == "notebookguid" && !reader->isEndElement()) {
            note.notebookGuid = textValue();
        }
        if (name == "dirty" && !reader->isEndElement()) {
            noteIsDirty = booleanValue();
        }
        if (name == "content" && !reader->isEndElement()) {
            note.content = textValue();
        }
        if (name == "titlecolor" && !reader->isEndElement()) {
            meta.setColor(intValue());
        }
        if (name == "notetags" && (createTags || backup) && !reader->isEndElement()) {
            QStringList names, guids;
            processNoteTagList(guids, names);
            QList<QString> tagGuids;
            QList<QString> tagNames;
            for (qint32 i=0; i<guids.size(); i++) {
                tagGuids.append(guids[i]);
                tagNames.append(names[i]);
            }
            note.tagNames = tagNames;
            note.tagGuids = tagGuids;
        }
        if (name == "noteattributes" && !reader->isEndElement()) {
            processNoteAttributes(note.attributes);
        }
        if (name == "noteresource" && !reader->isEndElement()) {
            Resource newRes;
            processResource(newRes);
            newRes.noteGuid = note.guid;
            if (!backup)
                newRes.updateSequenceNum = 0;
            QList<Resource> resources;
            if (note.resources.isSet())
                resources = note.resources;
            resources.append(newRes);
            note.resources = resources;
        }
        reader->readNext();
        QString endName = reader->name().toString().toLower();
        if (endName == "note" && reader->isEndElement())
            atEnd = true;
    }

    // Loop through the resources & make sure they all have the
    // proper guid for this note
    QList<Resource> resources;
    if (note.resources.isSet())
        resources = note.resources;
    for (int i=0; i<resources.size(); i++) {
        resources[i].noteGuid = note.guid;
    }
    note.resources = resources;
    NoteTable noteTable(global.db);
    if (backup)
        noteTable.add(0,note, noteIsDirty);
    else {
        note.updateSequenceNum = 0;
        if (notebookGuid != NULL)
            note.notebookGuid = notebookGuid;
        noteTable.add(0,note, true);
        if (metaData.contains(note.guid)) {
            QLOG_ERROR() << "ERROR IN IMPORTING DATA:  Metadata not yet supported";
        }
    }
    return;
}
コード例 #29
0
ファイル: importdata.cpp プロジェクト: rodrigoccurvo/nixnote2
//***********************************************************
//* Take a node's text & return the short value
//***********************************************************
short ImportData::shortValue() {
    return textValue().toShort();
}
コード例 #30
0
qlonglong BatchImport::longlongValue() {
    return textValue().toLongLong();
}