MojErr MojDbIndex::stats(MojObject& objOut, MojSize& usageOut, MojDbReq& req) { LOG_TRACE("Entering function %s", __FUNCTION__); MojAssert(isOpen()); MojSize count = 0; MojSize size = 0; MojErr err = m_index->stats(req.txn(), count, size); LOG_DEBUG("[db_mojodb] IndexStats: Kind: %s;Index: %s; Id: %zX; count= %zu; size= %zu; delMisses = %d, err= %d \n", m_kind->name().data(), m_name.data(), idIndex(), count, size, m_delMisses, err); MojErrCheck(err); usageOut += size; err = objOut.put(SizeKey, (MojInt64) size); MojErrCheck(err); err = objOut.put(CountKey, (MojInt64) count); MojErrCheck(err); err = objOut.put(DelMissesKey, (MojInt64) m_delMisses); // cumulative since start MojErrCheck(err); MojThreadReadGuard guard(m_lock); if (!m_watcherMap.empty()) { MojObject watcherInfo; for (WatcherMap::ConstIterator i = m_watcherMap.begin(); i != m_watcherMap.end(); ++i) { err = watcherInfo.put(i.key(), (MojInt64) i.value()); MojErrCheck(err); } err = objOut.put(WatchesKey, watcherInfo); MojErrCheck(err); } return MojErrNone; }
void PopClient::Status(MojObject& status) const { MojErr err; err = status.put("accountId", m_accountId); ErrorToException(err); err = status.putString("state", GetStateName(m_state)); ErrorToException(err); if(m_commandManager->GetActiveCommandCount() > 0 || m_commandManager->GetPendingCommandCount() > 0) { MojObject cmStatus; m_commandManager->Status(cmStatus); err = status.put("commandManager", cmStatus); ErrorToException(err); } if(m_session.get()) { MojObject sessionStatus; m_session->Status(sessionStatus); err = status.put("session", sessionStatus); ErrorToException(err); } }
void FileCacheClient::InsertCacheObject(ReplySignal::SlotRef slot, const char* typeName, const char* fileName, MojInt64 size, MojInt64 cost, MojInt64 lifetime) { MojErr err; MojObject payload; err = payload.putString("typeName", typeName); ErrorToException(err); err = payload.putString("fileName", fileName); ErrorToException(err); // Size must be >0 and larger than the actual content. // If the content is empty, we'll use 1 so FileCache doesn't complain. err = payload.put("size", size > 0 ? size : 1); ErrorToException(err); if(cost >= 0) { err = payload.put("cost", cost); ErrorToException(err); } if(lifetime >= 0) { err = payload.put("lifetime", lifetime); ErrorToException(err); } err = payload.put("subscribe", true); ErrorToException(err); m_busClient.SendRequest(slot, FILECACHE_SERVICE, "InsertCacheObject", payload, MojServiceRequest::Unlimited); }
void ActivityBuilderFactory::BuildDeleteEmailsWatch(ActivityBuilder& builder) { MojString name; GetDeleteEmailsActivityName(name); MojString desc; GetDeleteEmailsActivityDesc(desc); builder.SetName(name.data()); builder.SetDescription(desc.data()); builder.SetPersist(true); builder.SetExplicit(true); builder.SetImmediate(true, "low"); // setup trigger MojDbQuery trigger; MojErr err = trigger.from(PopEmailAdapter::POP_EMAIL_KIND); ErrorToException(err); err = trigger.where("_del", MojDbQuery::OpEq, true); ErrorToException(err); builder.SetDatabaseWatchTrigger(trigger); // setup parameters (to be sent when trigger is called) MojObject params; err = params.put(PopFolderAdapter::ACCOUNT_ID, m_accountId); ErrorToException(err); builder.SetCallback(DELETE_EMAILS_CALLBACK, params); // put accountId in metadata MojObject metadata; err = metadata.put(PopFolderAdapter::ACCOUNT_ID, m_accountId); ErrorToException(err); builder.SetMetadata(metadata); }
void ScheduleRetryCommand::ScheduleRetry() { ActivityBuilder ab; // Get current retry interval from account EmailAccount::RetryStatus retryStatus = m_client.GetAccount()->GetRetry(); int interval = retryStatus.GetInterval(); if(interval <= INITIAL_RETRY_SECONDS) { interval = INITIAL_RETRY_SECONDS; } else if(interval >= MAX_RETRY_SECONDS) { interval = MAX_RETRY_SECONDS; } else { // TODO: only update this on actual retry? interval *= RETRY_MULTIPLIER; } // Update account just in case it wasn't within the limit retryStatus.SetInterval(interval); m_client.GetAccount()->SetRetry(retryStatus); m_client.GetActivityBuilderFactory()->BuildFolderRetrySync(ab, m_folderId, interval); MojErr err; MojObject payload; err = payload.put("activity", ab.GetActivityObject()); ErrorToException(err); err = payload.put("start", true); ErrorToException(err); err = payload.put("replace", true); MojLogInfo(m_log, "Creating retry activity in activity manager: %s", AsJsonString(payload).c_str()); m_client.SendRequest(m_scheduleRetrySlot, "com.palm.activitymanager", "create", payload); }
void ActivityBuilderFactory::BuildAccountPrefsWatch(ActivityBuilder& builder, MojObject& accountRev) { MojString name; GetAccountPrefsWatchActivityName(name); MojString desc; GetAccountPrefsWatchActivityDesc(desc); builder.SetName(name.data()); builder.SetDescription(desc.data()); builder.SetPersist(true); builder.SetExplicit(true); builder.SetImmediate(true, "low"); MojDbQuery trigger; MojErr err = trigger.from(PopAccountAdapter::POP_ACCOUNT_KIND); ErrorToException(err); err = trigger.where(PopAccountAdapter::ACCOUNT_ID, MojDbQuery::OpEq, m_accountId); ErrorToException(err); err = trigger.where("_revPop", MojDbQuery::OpGreaterThan, accountRev); ErrorToException(err); builder.SetDatabaseWatchTrigger(trigger); MojObject params; err = params.put(PopAccountAdapter::ACCOUNT_ID, m_accountId); ErrorToException(err); builder.SetCallback(ACCOUNT_PREFS_WATCH_CALLBACK, params); MojObject metadata; err = metadata.put(PopAccountAdapter::ACCOUNT_ID, m_accountId); ErrorToException(err); builder.SetMetadata(metadata); }
void ActivityBuilderFactory::BuildScheduledSync(ActivityBuilder &builder, int intervalMins) { // activity to setup watch MojString name; GetScheduledSyncActivityName(name); // description of watch MojString desc; GetScheduledSyncActivityDesc(desc); // sync interval in seconds int intervalSecs = MinsToSecs(intervalMins); builder.SetName(name.data()); builder.SetDescription(desc.data()); builder.SetPersist(true); builder.SetExplicit(true); builder.SetRequiresInternet(false); builder.SetSyncInterval(0, intervalSecs); builder.SetImmediate(true, "low"); // setup parameters (to be sent when trigger is called) MojObject params; MojErr err = params.put(PopAccountAdapter::ACCOUNT_ID, m_accountId); ErrorToException(err); builder.SetCallback(SCHEDULED_SYNC_CALLBACK, params); // put accountId in metadata MojObject metadata; err = metadata.put("accountId", m_accountId); ErrorToException(err); builder.SetMetadata(metadata); }
MojErr MojService::CategoryHandler::addMethod(const MojChar* methodName, Callback callback, bool pub, const MojChar* schemaJson) { MojAssert(methodName && callback); MojString str; MojErr err = str.assign(methodName); MojErrCheck(err); MojRefCountedPtr<MojSchema> schema; if (schemaJson) { MojObject schemaObj; err = schemaObj.fromJson(schemaJson); MojErrCheck(err); // add implicit $activity property MojObject properties; schemaObj.get(MojSchema::PropertiesKey, properties); MojObject activityProp; err = activityProp.putBool(MojSchema::OptionalKey, true); MojErrCheck(err); err = properties.put(_T("$activity"), activityProp); MojErrCheck(err); err = schemaObj.put(MojSchema::PropertiesKey, properties); MojErrCheck(err); schema.reset(new MojSchema); MojAllocCheck(schema.get()); err = schema->fromObject(schemaObj); MojErrCheck(err); } MojAssert(!m_callbackMap.contains(str)); err = m_callbackMap.put(str, CallbackInfo(callback, schema.get(), pub)); MojErrCheck(err); return MojErrNone; }
void PopAccountUpdateCommand::UpdateAccountWatchActivity() { CommandTraceFunction(); try { MojObject revPop; MojErr err = m_transportObj.getRequired("_revPop", revPop); ErrorToException(err); ActivityBuilder ab; m_activityBuilderFactory->BuildAccountPrefsWatch(ab, revPop); MojObject payload; err = payload.put("activity", ab.GetActivityObject()); ErrorToException(err); err = payload.put("start", true); ErrorToException(err); err = payload.put("replace", true); ErrorToException(err); m_client.SendRequest(m_createActivitySlot, "com.palm.activitymanager", "create", payload); } catch (const std::exception& ex) { Failure(ex); } catch (...) { Failure(MailException("unknown exception", __FILE__, __LINE__)); } }
MojErr ContainerManager::InfoToJson(MojObject& rep) const { MojObject containers(MojObject::TypeArray); std::for_each(m_containers.begin(), m_containers.end(), boost::bind(&ResourceContainer::PushJson, boost::bind(&ContainerMap::value_type::second, _1), boost::ref(containers))); MojErr err = rep.put(_T("containers"), containers); MojErrCheck(err); MojObject entityMap(MojObject::TypeArray); for (EntityContainerMap::const_iterator iter = m_entityContainers.begin(); iter != m_entityContainers.end(); ++iter) { MojObject mapping(MojObject::TypeObject); MojString containerName; err = containerName.assign(iter->second->GetName().c_str()); MojErrCheck(err); err = mapping.put(iter->first->GetName().c_str(), containerName); MojErrCheck(err); err = entityMap.push(mapping); MojErrCheck(err); } err = rep.put(_T("entityMap"), entityMap); MojErrCheck(err); return MojErrNone; }
void ImapActivityFactory::BuildStartIdle(ActivityBuilder& ab, const MojObject& accountId, const MojObject& folderId) { MojErr err; ab.SetName( GetStartIdleName(accountId, folderId) ); ab.SetDescription("Starts a push connection when the network is available"); ab.SetExplicit(false); ab.SetPersist(true); ab.SetImmediate(true, "low"); SetNetworkRequirements(ab, false); // Metadata MojObject metadata; SetMetadata(metadata, MAINTAIN_IDLE_NAME, accountId, folderId); ab.SetMetadata(metadata); // Callback MojObject params; err = params.put("accountId", accountId); ErrorToException(err); err = params.put("folderId", folderId); ErrorToException(err); ab.SetCallback(MAINTAIN_IDLE_CALLBACK, params); }
void SmtpActivityFactory::BuildOutboxWatch(ActivityBuilder& ab, const MojObject& accountId, const MojObject& folderId) { ActivityBuilder actBuilder; MojString name; name.format(OUTBOX_WATCH_ACTIVITY_FMT, AsJsonString(accountId).c_str()); ab.SetName(name); ab.SetDescription("Watches SMTP outbox for new emails"); ab.SetPersist(true); ab.SetExplicit(true); ab.SetRequiresInternet(false); // don't trigger until we also have connectivity ab.SetImmediate(true, ActivityBuilder::PRIORITY_LOW); // Callback MojObject callbackParams; MojErr err = callbackParams.put("accountId", accountId); ErrorToException(err); err = callbackParams.put("folderId", folderId); ErrorToException(err); ab.SetCallback(OUTBOX_BUS_METHOD, callbackParams); ab.SetMetadata(callbackParams); }
void DownloadListener::ReportError(MailError::ErrorCode errorCode, const string& errorText) { MojErr err; MojObject payload; err = payload.put("returnValue", false); ErrorToException(err); err = payload.put("emailId", m_emailId); ErrorToException(err); if(!m_partId.undefined()) { err = payload.put("partId", m_partId); ErrorToException(err); } err = payload.put("errorCode", errorCode); ErrorToException(err); err = payload.putString("errorText", errorText.c_str()); ErrorToException(err); err = m_msg->reply(payload); ErrorToException(err); }
void SmtpSendMailCommand::UpdateSendStatus() { try { MojObject sendStatus; MojObject visible; MojErr err; bool update = false; if (m_error.errorCode == 0) { MojLogInfo(m_log, "updating send status to SENT successfully"); err = sendStatus.put(EmailSchema::SendStatus::SENT, true); ErrorToException(err); err = visible.put(EmailSchema::Flags::VISIBLE, false); ErrorToException(err); update = true; } else if (m_error.errorOnEmail) { MojLogInfo(m_log, "updating send status on email to indicate error"); MojString str; str.assign(m_error.errorText.c_str()); err = sendStatus.put(EmailSchema::SendStatus::LAST_ERROR, str); ErrorToException(err); // FIXME: Should we store an actual error code? err = sendStatus.put(EmailSchema::SendStatus::FATAL_ERROR, true); ErrorToException(err); update = true; } // account errors are not handled in sent status: message // status will not be changed in those cases. if (update) { MojString idJson; m_emailId.toJson(idJson); MojLogInfo(m_log, "updating send status for email %s", idJson.data()); m_session.GetDatabaseInterface().UpdateSendStatus(m_updateSendStatusSlot, m_emailId, sendStatus, visible); } else { // Finish up now Done(); } } catch (std::exception & e) { // Error updating status, just give up. MojLogInfo(m_log, "Exception %s hit trying to update send status, bailing", e.what()); Done(); } catch (...) { // Error updating status, just give up. MojLogInfo(m_log, "Unknown exception hit trying to update send status, bailing"); Done(); } }
MojErr MojObjectTest::putTest(MojObject& obj) { MojString str; MojObject obj2; MojObject array1; MojObject str2; MojObject bool2(false); MojObject int2(-260000000000LL); MojObject MojDecimal2(MojDecimal(2.34)); MojErr err = str.assign(_T("howdy")); MojTestErrCheck(err); str2 = str; err = obj2.put(_T("nested"), str); MojTestErrCheck(err); err = obj.put(_T("object"), obj2); MojTestErrCheck(err); err = obj.put(_T("string"), str2); MojTestErrCheck(err); err = obj.put(_T("bool1"), true); MojTestErrCheck(err); err = obj.put(_T("bool2"), bool2); MojTestErrCheck(err); err = obj.put(_T("int1"), 50); MojTestErrCheck(err); err = obj.put(_T("int2"), int2); MojTestErrCheck(err); err = obj.put(_T("MojDecimal1"), MojDecimal(0.1)); MojTestErrCheck(err); err = obj.put(_T("MojDecimal2"), MojDecimal2); MojTestErrCheck(err); err = obj.put(_T("null"), MojObject(MojObject::TypeNull)); MojTestErrCheck(err); // array err = array1.push(MojObject(MojObject::TypeObject)); MojTestErrCheck(err); err = array1.push(MojObject(MojObject::TypeArray)); MojTestErrCheck(err); err = array1.push(str2); MojTestErrCheck(err); err = array1.push(true); MojTestErrCheck(err); err = array1.setAt(3, false); MojTestErrCheck(err); err = array1.push(MojDecimal(3, 140000)); MojTestErrCheck(err); err = array1.push(100); MojTestErrCheck(err); err = array1.push(MojObject(MojObject::TypeNull)); MojTestErrCheck(err); err = array1.setAt(7, 4); MojTestErrCheck(err); err = obj.put(_T("array"), array1); MojTestErrCheck(err); return MojErrNone; }
void AuthYahooCommand::RunImpl() { MojLogTrace(m_log); // HACK: Hard-code partner ID and fetch of NDUID m_partnerId.assign("mblclt11"); char id[256]; memset(id, '\0', 256); // Read nduid, if available, otherwise make a fake one and try to record it. FILE * nduid = fopen("/proc/nduid", "r"); if (!nduid) { nduid = fopen("yahooCachedFakeDeviceId", "r"); if (!nduid) { snprintf(id, 255, "FEED0BEEF479121481533145%016llX", timeMillis()); nduid = fopen("yahooCachedFakeDeviceId", "w"); if (nduid) { fputs(id, nduid); fclose(nduid); nduid = NULL; } } } if (nduid) { if (fgets(id, 255, nduid) == NULL) id[0] = '\0'; fclose(nduid); nduid = NULL; if (strlen(id) > 0 && id[strlen(id)-1] == '\n') id[strlen(id)-1] = '\0'; } m_deviceId.assign(id); MojLogInfo(m_log, "Temp: partnerId=%s deviceId=%s", m_partnerId.data(), m_deviceId.data()); MojObject accountId = m_session.GetAccount()->GetAccountId(); MojObject params; MojErr err = params.put("accountId", accountId); ErrorToException(err); MojString token; token.assign(m_session.GetAccount()->GetYahooToken().c_str()); err = params.put("securityToken", token); ErrorToException(err); MojLogInfo(m_log, "Looking up yahoo cookies for account %s", AsJsonString(accountId).c_str()); // TODO: Should send the request with SmtpClient instead. err = m_session.CreateRequest()->send(m_getYahooCookiesSlot, "com.palm.yahoo","fetchcookies", params); ErrorToException(err); }
void buildSample() { for (int i = 0; i < 100; ++i) { MojObject obj; MojAssertNoErr( obj.putString(MojDb::KindKey, _T("Test:1")) ); MojAssertNoErr( obj.put(_T("foo"), (i + 25) % 100) ); MojAssertNoErr( obj.put(_T("bar"), i % 3) ); MojExpectNoErr( db.put(obj) ) << "Failed to put record #" << i; } // db: x0 = (25, 0), (26, 1), (27, 2), (28, 0) .. x74 = (99,2), x75 = (0,0) .. x99 = (24,0) }
void MockRemoteService::SimulateOffline(MockRequestPtr req) { MojErr err; MojObject payload; err = payload.put("returnValue", false); ErrorToException(err); err = payload.put("errorCode", -1); ErrorToException(err); req->ReplyNow(payload, MojErrInternal); }
/** * Return MojObject formated to save to MojDb * Used for incoming messages */ MojErr IMMessage::createDBObject(MojObject& returnObj) { MojLogInfo(IMServiceApp::s_log, _T("createMojObject")); // Communications kind // From/to address is itself a CommunicationsAddress object // "name" and "type" properties are optional // Sender MojObject addressObj; MojErr err = addressObj.putString(MOJDB_ADDRESS, fromAddress); MojErrCheck(err); err = returnObj.put(MOJDB_FROM, addressObj); MojErrCheck(err); // Recipient MojObject recipientArray, recipient; err = recipient.put(MOJDB_ADDRESS, toAddress); MojErrCheck(err); err = recipientArray.push(recipient); MojErrCheck(err); err = returnObj.put(MOJDB_TO, recipientArray); MojErrCheck(err); // Message kind err = returnObj.putString(MOJDB_FOLDER, folderStrings[folder]); MojErrCheck(err); err = returnObj.putString(MOJDB_STATUS, statusStrings[status]); MojErrCheck(err); err = returnObj.putString(MOJDB_MSG_TEXT, msgText); MojErrCheck(err); // username - since this is incoming message, the username is always in toAddress err = returnObj.putString(MOJDB_USERNAME, toAddress); MojErrCheck(err); // service name err = returnObj.putString(MOJDB_SERVICENAME, msgType); MojErrCheck(err); // localTimestamp err = returnObj.putInt(MOJDB_DEVICE_TIMESTAMP, deviceTimestamp); MojErrCheck(err); // incoming server err = returnObj.putInt(MOJDB_SERVER_TIMESTAMP, serverTimestamp); MojErrCheck(err); IMServiceHandler::privatelogIMMessage(_T("DB Message object %s:"), returnObj, MOJDB_MSG_TEXT); return err; }
MojErr MojDbWatchTest::merge(MojDb& db, const MojObject& id, const MojObject& barVal) { MojObject obj; MojErr err = obj.put(MojDb::IdKey, id); MojTestErrCheck(err); err = obj.put(_T("bar"), barVal); MojTestErrCheck(err); err = db.merge(obj); MojTestErrCheck(err); return MojErrNone; }
void ImapActivityFactory::SetMetadata(MojObject& metadata, const char* name, const MojObject& accountId, const MojObject& folderId) { MojErr err; err = metadata.putString("name", name); ErrorToException(err); err = metadata.put("accountId", accountId); ErrorToException(err); err = metadata.put("folderId", folderId); ErrorToException(err); }
MojErr PowerdProxy::BatteryRequirement::ToJson(MojObject& rep, unsigned flags) const { MojErr err = MojErrNone; if (flags & ACTIVITY_JSON_CURRENT) { err = rep.put(_T("battery"), m_powerd->GetBatteryPercent()); } else { err = rep.put(_T("battery"), m_key); } return err; }
void MojoDatabase::UpdateEmailSummary(Signal::SlotRef slot, const MojObject& emailId, const MojString& summary) { MojObject email; MojErr err = email.put(PopEmailAdapter::ID, emailId); ErrorToException(err); err = email.put(EmailSchema::SUMMARY, summary); ErrorToException(err); //MojLogInfo(PopClient::s_log, "Updating email '%s' with summary: '%s'", AsJsonString(emailId).c_str(), AsJsonString(summary).c_str()); err = m_dbClient.merge(slot, email); ErrorToException(err); }
MojErr MojDb::insertIncrementalKey(MojObject& response, const MojChar* keyName, const MojObject& curRev) { // get the incremental key if it already exists MojObject incremental; response.get(MojDbServiceDefs::IncrementalKey, incremental); MojErr err = incremental.put(keyName, curRev); MojErrCheck(err); err = response.put(MojDbServiceDefs::IncrementalKey, incremental); MojErrCheck(err); return MojErrNone; }
void SmtpSendMailCommand::Status(MojObject& status) const { MojErr err; SmtpProtocolCommand::Status(status); err = status.put("emailId", m_emailId); ErrorToException(err); if(m_counter.get()) { err = status.put("emailSize", (MojInt64) m_counter->GetBytesWritten()); ErrorToException(err); } }
void NetworkStatusMonitor::Status(MojObject& status) const { MojErr err; if(m_lastUpdateTime) { MojObject networkStatus; m_networkStatus.Status(networkStatus); err = status.put("networkStatus", networkStatus); ErrorToException(err); } err = status.put("lastUpdateTime", (MojInt64) m_lastUpdateTime); ErrorToException(err); }
MojErr MojDbPurgeTest::createRevTimestamp(MojDb& db, MojObject& revNum, MojInt64 timestamp) { MojObject revTimeObj; MojErr err = revTimeObj.put(_T("rev"), revNum); MojTestErrCheck(err); err = revTimeObj.put(_T("timestamp"), timestamp); MojTestErrCheck(err); err = revTimeObj.putString(MojDb::KindKey, MojDbKindEngine::RevTimestampId); MojTestErrCheck(err); err = db.put(revTimeObj); MojTestErrCheck(err); return MojErrNone; }
void SmtpSyncOutboxCommand::UpdateAccountWatchActivity() { MojLogInfo(m_log, "UpdatingAccountWatchActivity"); try { // accoundId json object MojString accountIdJson; MojErr err = m_accountId.toJson(accountIdJson); ErrorToException(err); SmtpActivityFactory factory; ActivityBuilder ab; factory.BuildSmtpConfigWatch(ab, m_accountId, m_accountRev); bool updating = m_accountWatchActivity.get(); // and either update and complete the updated activity if we had adopted it, or re-create it. if ( updating ) { MojLogInfo(m_log, "updating account watch activity"); m_accountWatchActivity->SetSlots(m_accountActivityUpdatedSlot, m_accountActivityErrorSlot); m_accountWatchActivity->UpdateAndComplete(m_client, ab.GetActivityObject()); } else { // Create payload MojObject payload; err = payload.put("activity", ab.GetActivityObject()); ErrorToException(err); err = payload.put("start", true); ErrorToException(err); err = payload.put("replace", true); ErrorToException(err); MojLogInfo(m_log, "creating account watch activity"); m_client.SendRequest(m_createAccountWatchActivityResponseSlot, "com.palm.activitymanager", "create", payload); } } catch (std::exception & e) { HandleException(e, __func__); } catch (...) { HandleException(__func__); } }
/* * Fail the message in the DB * This is the result of an internal error that should not happen - we just need to get back to a consistent state */ MojErr SendOneMessageHandler::failMessage(const MojChar *errorString) { // permanent error - no retry option MojObject propObject; propObject.putString(MOJDB_STATUS, IMMessage::statusStrings[Undeliverable]); // set the error category string for the UI propObject.putString(MOJDB_ERROR_CATEGORY,errorString); MojLogError(IMServiceApp::s_log, _T("failMessage error: %s"), errorString); // id to update propObject.putString(MOJDB_ID, m_currentMsgdbId); // set server timestamp to current time. MojInt64 now = time (NULL); propObject.put(MOJDB_SERVER_TIMESTAMP, now); // save the new fields - call merge // MojErr merge(Signal::SlotRef handler, const MojObject& obj, MojUInt32 flags = MojDb::FlagNone); MojErr err = m_dbClient.merge(this->m_imSaveMessageSlot, propObject); if (err) { MojLogError(IMServiceApp::s_log, _T("call to merge message into DB failed. err %d, DB id %s: "), err, m_currentMsgdbId.data() ); // call to save failed - not much we can do here... m_outgoingIMHandler->messageFinished(); } return MojErrNone; }
void MojoDatabase::MoveDeletedEmailToTrash (Signal::SlotRef slot, const MojObject& emailId, const MojObject& trashFolderId) { MojObject email; MojErr err = email.put(PopEmailAdapter::ID, emailId); ErrorToException(err); err = email.put(EmailSchema::FOLDER_ID, trashFolderId); ErrorToException(err); err = email.put("_del", false); ErrorToException(err); MojLogInfo(PopClient::s_log, "Moving email '%s' to trash folder '%s'", AsJsonString(emailId).c_str(), AsJsonString(trashFolderId).c_str()); err = m_dbClient.merge(slot, email); ErrorToException(err); }