MCPcopy Create free account
hub / github.com/baumgarr/nixnote2 / processSyncChunk

Method processSyncChunk

communication/communicationmanager.cpp:1116–1172  ·  view source on GitHub ↗

Take a sync chunk & get all the missing stuff

Source from the content-addressed store, hash-verified

1114//***********************************************************************
1115//***********************************************************************
1116void CommunicationManager::processSyncChunk(SyncChunk &chunk, QString token) {
1117 QHash<QString,QString> noteList;
1118 QList<Note> notes;
1119 if (chunk.notes.isSet())
1120 notes = chunk.notes;
1121 for (int i=0; i<notes.size(); i++) {
1122 QLOG_TRACE() << "Fetching chunk item: " << i << ": " << notes[i].title;
1123 Note n = notes[i];
1124 noteList.insert(n.guid,"");
1125 n = noteStore->getNote(notes[i].guid, true, true, true, true, token);
1126 QLOG_TRACE() << "Note Retrieved";
1127
1128 // Load up the tag names because Evernote doesn't give them.
1129 QList<QString> tagNames;
1130 QList<QString> tagGuids;
1131 if (n.tagGuids.isSet())
1132 tagGuids = n.tagGuids;
1133 for (int j=0; j<tagGuids.size(); j++) {
1134 QString tagGuid = tagGuids[j];
1135 if (tagGuidMap->contains(tagGuid)) {
1136 QString tagName = tagGuidMap->value(tagGuid);
1137 tagNames.append(tagName);
1138 }
1139 n.tagNames = tagNames;
1140 }
1141 QList<Resource> resources;
1142 if (n.resources.isSet())
1143 resources = n.resources;
1144 if (resources.size() > 0) {
1145 QLOG_TRACE() << "Checking for ink note";
1146 checkForInkNotes(n.resources, "", authToken);
1147 }
1148 notes[i] = n;
1149 }
1150 if (chunk.notes.isSet())
1151 chunk.notes = notes;
1152
1153 QList<Resource> resourceData;
1154 QLOG_DEBUG() << "All notes retrieved. Getting resources";
1155 QList<Resource> resources;
1156 if (chunk.resources.isSet())
1157 resources = chunk.resources;
1158 for (int i=0; i<resources.size(); i++) {
1159 QLOG_TRACE() << "Fetching chunk resource item: " << i << ": " << resources[i].guid;
1160 Resource r;
1161 r = noteStore->getResource(resources[i].guid, true, true, true, true, token);
1162 QLOG_TRACE() << "Resource retrieved";
1163 resourceData.append(r);
1164 }
1165 if (chunk.resources.isSet())
1166 chunk.resources = resourceData;
1167 QLOG_DEBUG() << "Getting ink notes";
1168 if (resources.size()>0) {
1169 QLOG_TRACE() << "Checking for ink notes";
1170 checkForInkNotes(resources,"", token);
1171 }
1172}
1173

Callers

nothing calls this directly

Calls 5

insertMethod · 0.80
valueMethod · 0.80
getResourceMethod · 0.80
isSetMethod · 0.45
getNoteMethod · 0.45

Tested by

no test coverage detected