int WebOsCalendarSyncSource::updateItem(SyncItem &item) { int ret = STC_COMMAND_FAILED; LOG.info("updateItem called with %s data. And Type %s.",item.getKey(),item.getDataType()); LOG.info("Calling updateEvent %s.",item.getKey()); std::vector<WString> result = BlockingServiceCall("updateEvent",(WCHAR*)item.getData(),item.getKey()); if(result.empty()) { LOG.error("update event %s did not work.",item.getData()); ret = STC_COMMAND_FAILED; } else { LOG.debug("update event was successful, received: %s.",result[0].c_str()); ret = STC_OK; } if (isErrorCode(ret)) { report->setLastErrorCode(ERR_ITEM_ERROR); report->setLastErrorMsg(ERRMSG_ITEM_ERROR); report->setState(SOURCE_ERROR); LOG.debug("Error updating item: %s", item.getKey()); } return ret; }
int AbstractSyncSource::updateItem(SyncItem& item) { QByteArray data((char *)item.getData()); QUniqueId id(QString((char *)item.getKey())); //qDebug() << "AbstractSyncSource::updateItem()" << toString(item) << "Id:" << id.toString(); if (m_model->updateRecord(id, data, m_type)) return 200; //ok, the SyncML command completed successfully else return 500; //failed, the recipient encountered an error }
int AbstractSyncSource::addItem(SyncItem& item) { QByteArray data((char *)item.getData()); QUniqueId id = m_model->addRecord(data, QPimSource(), m_type); item.setKey(id.toString().toAscii().data()); m_model->updateRecord(id, data, m_type); //qDebug() << "AbstractSyncSource::addItem() " << toString(item) << "Id:" << id.toString(); if (!id.isNull()) return 201; //ok, the requested item was added else return 500; //failed, the recipient encountered an error }
void testFillSyncItem(){ StringBuffer inFile = getTestFileFullPath(TEST_INPUT_DIR, TEST_FILE_NAME1); SyncItem* si = fmss->fakeFillSyncItem(&inFile, true); StringBuffer* data = new StringBuffer((char*)si->getData()); CPPUNIT_ASSERT(si != NULL); CPPUNIT_ASSERT(data != NULL); CPPUNIT_ASSERT(data->find("body") == StringBuffer::npos); CPPUNIT_ASSERT(data->find("size") != StringBuffer::npos); }
int TestSyncSource::updateItem(SyncItem& item) { char* val = toMultibyte( item.getKey() ); LOG.info("updated item: %s", val); if(val){ delete [] val; val = 0; } char *data = new char [item.getDataSize()]; memcpy(data, item.getData(), item.getDataSize()); data[item.getDataSize()] = 0; LOG.info("Data: %s", data); delete [] data; return 200; }
//test te getFirstItem. We pass all the values into the properties ArrayList //and we get the first one void testAllItems() { ArrayList properties; ConfigSyncSource source(TEXT("config"), APPLICATIONURI, s); StringBuffer emailaddress("./Email/Address"); properties.add(emailaddress); source.setConfigProperties(properties); Enumeration* val = source.getAllItemList(); SyncItem* value = source.getFirstItem(); StringBuffer valuedata((const char*)value->getData(),value->getDataSize()); CPPUNIT_ASSERT(valuedata == VALUE); delete val; delete value; }
QString AbstractSyncSource::toString(SyncItem& item) { QByteArray data((char *)item.getData()); QString ret("Key: "); ret += item.getKey(); ret += " Mod.Time: "; ret += QString::number(item.getModificationTime()); ret += " Encoding: "; ret += item.getDataEncoding(); ret += " Size: "; ret += QString::number(item.getDataSize()); ret += " Type: "; ret += item.getDataType(); ret += " State: "; ret += QString::number(item.getState()); ret += " Data:\n"; ret += data; return ret; }
int TestSyncSource::addItem(SyncItem& item) { char* val = toMultibyte( item.getKey() ); LOG.info("added item: %s", val); if(val){ delete [] val; val = 0; } char *data = new char [item.getDataSize()]; memcpy(data, item.getData(), item.getDataSize()); data[item.getDataSize()] = 0; LOG.info("Data: %s", data); delete [] data; WCHAR *luid = new WCHAR[wcslen(item.getKey())+10]; wsprintf(luid, TEXT("%s-luid"), item.getKey()); item.setKey(luid); return 200; }
END_TEST WinContact* updateOutlookItem(WindowsSyncSource* ss, SyncItem* item) { int ret = ss->updateItem(*item); WIN_ASSERT_EQUAL(ret, 200, TEXT("Update item is not correct")); wstring keyModified = item->getKey(); SyncItem* itemTmp = ss->getItemFromId(keyModified.c_str()); WIN_ASSERT_NOT_NULL(item, TEXT("The item retrieved from the backend is null.")); WCHAR* wcon = toWideChar((const char*)itemTmp->getData()); wstring wcontact(wcon); delete [] wcon; WinContact* winC = new WinContact(wcontact); return winC; }