summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIckhee Woo <ickhee.woo@samsung.com>2015-09-01 22:47:15 +0900
committerIckhee Woo <ickhee.woo@samsung.com>2015-09-10 15:20:30 +0900
commit2446fa6460cc2ea496e4e91923f2fb8a342d8615 (patch)
tree93880720fc0b31b84a8fc1b9af04553d7931c398
parentfdec81e42551f4bf0acdf0f6e8d25d1d73a5d371 (diff)
downloadsync-manager-2446fa6460cc2ea496e4e91923f2fb8a342d8615.tar.gz
sync-manager-2446fa6460cc2ea496e4e91923f2fb8a342d8615.tar.bz2
sync-manager-2446fa6460cc2ea496e4e91923f2fb8a342d8615.zip
refactored sync-manager.
Change-Id: I378785af32526ad43ef8f6f557c42e531c94a819 Signed-off-by: Ickhee Woo <ickhee.woo@samsung.com>
-rw-r--r--common/sync-ipc-marshal.c8
-rw-r--r--common/sync-ipc-marshal.h1
-rw-r--r--packaging/org.tizen.sync.service3
-rw-r--r--packaging/sync-manager.spec14
-rw-r--r--src/sync-client/sync_adapter.c13
-rw-r--r--src/sync-client/sync_manager.c9
-rw-r--r--src/sync-service/SyncManager_CapabilityInfo.cpp8
-rw-r--r--src/sync-service/SyncManager_CurrentSyncJobQueue.cpp7
-rw-r--r--src/sync-service/SyncManager_DataChangeSyncScheduler.cpp4
-rw-r--r--src/sync-service/SyncManager_PeriodicSyncScheduler.cpp6
-rw-r--r--src/sync-service/SyncManager_RepositoryEngine.cpp12
-rw-r--r--src/sync-service/SyncManager_SyncAdapterAggregator.cpp3
-rw-r--r--src/sync-service/SyncManager_SyncJob.cpp72
-rw-r--r--src/sync-service/SyncManager_SyncJob.h16
-rw-r--r--src/sync-service/SyncManager_SyncJobDispatcher.cpp2
-rw-r--r--src/sync-service/SyncManager_SyncJobsInfo.cpp2
-rw-r--r--src/sync-service/SyncManager_SyncJobsInfo.h2
-rw-r--r--src/sync-service/SyncManager_SyncManager.cpp84
-rw-r--r--src/sync-service/SyncManager_SyncManager.h4
-rw-r--r--src/sync-service/SyncManager_SyncService.cpp296
-rw-r--r--src/sync-service/SyncManager_SyncService.h2
-rw-r--r--sync-service.manifest1
22 files changed, 298 insertions, 271 deletions
diff --git a/common/sync-ipc-marshal.c b/common/sync-ipc-marshal.c
index 5868898..2ce6f04 100644
--- a/common/sync-ipc-marshal.c
+++ b/common/sync-ipc-marshal.c
@@ -25,6 +25,7 @@ extern "C"
{
#endif
+
void
bundle_iterate_cb(const char *key, const char *val, void *data)
{
@@ -34,6 +35,7 @@ bundle_iterate_cb(const char *key, const char *val, void *data)
g_variant_new_string(val));
}
+
GVariant*
marshal_bundle(bundle *extras)
{
@@ -46,7 +48,7 @@ marshal_bundle(bundle *extras)
void
-unmarshal_sync_job_list(GVariant* variant, sync_manager_sync_job_cb callback, void* user_data)
+umarshal_sync_job_list(GVariant* variant, sync_manager_sync_job_cb callback, void* user_data)
{
GVariantIter iter;
GVariantIter* iter_job = NULL;
@@ -56,7 +58,7 @@ unmarshal_sync_job_list(GVariant* variant, sync_manager_sync_job_cb callback, vo
while (g_variant_iter_loop (&iter, "a{sv}", &iter_job))
{
- int sync_job_id;
+ int sync_job_id = 0;
account_h account = NULL;
char* sync_job_name = NULL;
char* sync_capability = NULL;
@@ -92,12 +94,14 @@ unmarshal_sync_job_list(GVariant* variant, sync_manager_sync_job_cb callback, vo
job_user_data = umarshal_bundle(value);
}
}
+
if (!callback(account, sync_job_name, sync_capability, sync_job_id, job_user_data, user_data))
{
account_destroy(account);
bundle_free(job_user_data);
break;
}
+
account_destroy(account);
bundle_free(job_user_data);
}
diff --git a/common/sync-ipc-marshal.h b/common/sync-ipc-marshal.h
index cd544cc..2206959 100644
--- a/common/sync-ipc-marshal.h
+++ b/common/sync-ipc-marshal.h
@@ -34,6 +34,7 @@ extern "C"
#define KEY_SYNC_JOB_CAPABILITY "job_capability"
#define KEY_SYNC_JOB_USER_DATA "job_data"
+
GVariant* marshal_bundle(bundle* extras);
bundle* umarshal_bundle(GVariant* in_data);
diff --git a/packaging/org.tizen.sync.service b/packaging/org.tizen.sync.service
index 8b9aa85..9742438 100644
--- a/packaging/org.tizen.sync.service
+++ b/packaging/org.tizen.sync.service
@@ -1,4 +1,5 @@
[D-BUS Service]
Name=org.tizen.sync
Exec=/usr/bin/false
-#Exec=/usr/bin/sync-service
+SystemdService=sync-manager.service
+User=app
diff --git a/packaging/sync-manager.spec b/packaging/sync-manager.spec
index 7b552df..e8cbc14 100644
--- a/packaging/sync-manager.spec
+++ b/packaging/sync-manager.spec
@@ -91,14 +91,14 @@ make %{?jobs:-j%jobs}
%install
%make_install
mkdir -p %{buildroot}%{_unitdir_user}/default.target.wants
-install -m 644 %SOURCE1 %{buildroot}%{_unitdir_user}/sync-manager.service
+install -m 0644 %SOURCE1 %{buildroot}%{_unitdir_user}/sync-manager.service
ln -s ../sync-manager.service %{buildroot}%{_unitdir_user}/default.target.wants/sync-manager.service
-#mkdir -p %{buildroot}/usr/share/dbus-1/services
-#install -m 0644 %SOURCE2 %{buildroot}/usr/share/dbus-1/services/org.tizen.sync.service
+mkdir -p %{buildroot}/usr/share/dbus-1/services
+install -m 0644 %SOURCE2 %{buildroot}/usr/share/dbus-1/services/org.tizen.sync.service
-#mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/session.d
-#install -m 0644 %SOURCE3 %{buildroot}%{_sysconfdir}/dbus-1/session.d/
+mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/session.d
+install -m 0644 %SOURCE3 %{buildroot}%{_sysconfdir}/dbus-1/session.d/org.tizen.sync.conf
#mkdir -p %{buildroot}%{TZ_SYS_DATA}/sync-manager
@@ -119,13 +119,13 @@ rm -rf %{buildroot}
%files -n sync-service
%manifest sync-service.manifest
%defattr(-,root,root,-)
-#%config %{_sysconfdir}/dbus-1/session.d/org.tizen.sync.conf
+%config %{_sysconfdir}/dbus-1/session.d/org.tizen.sync.conf
%{_bindir}/*
#%{_unitdir}/*
#%{TZ_SYS_DATA}/sync-manager/
%{_unitdir_user}/sync-manager.service
%{_unitdir_user}/default.target.wants/sync-manager.service
-#usr/share/dbus-1/services/org.tizen.sync.service
+/usr/share/dbus-1/services/org.tizen.sync.service
%files -n libcore-sync-client
%manifest libcore-sync-client.manifest
diff --git a/src/sync-client/sync_adapter.c b/src/sync-client/sync_adapter.c
index bc06538..ffaeb78 100644
--- a/src/sync-client/sync_adapter.c
+++ b/src/sync-client/sync_adapter.c
@@ -42,9 +42,9 @@ typedef enum {
#define SYNC_THREAD 0 /*As sync adapter itself runs in service app*/
-#define SYNC_MANAGER_DBUS_SERVICE "org.tizen.sync"
-#define SYNC_MANAGER_DBUS_PATH "/org/tizen/sync/manager"
-#define SYNC_ADAPTER_COMMON_DBUS_PATH "/org/tizen/sync/adapter"
+#define SYNC_MANAGER_DBUS_SERVICE "org.tizen.sync"
+#define SYNC_MANAGER_DBUS_PATH "/org/tizen/sync/manager"
+#define SYNC_ADAPTER_COMMON_DBUS_PATH "/org/tizen/sync/adapter"
typedef struct sync_adapter_s {
@@ -101,6 +101,9 @@ __sync_adapter_on_start_sync(TizenSyncAdapter *pObject,
bundle_free(sync_job_user_data);
LOG_LOGD("Sync completed");
+ if (ret == SYNC_STATUS_FAILURE)
+ return false;
+
return true;
}
@@ -138,7 +141,7 @@ __sync_adapter_on_stop_sync(
int __register_sync_adapter(bool flag)
{
GError *error = NULL;
- GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
SYNC_LOGE_RET_RES(connection != NULL, SYNC_ERROR_IO_ERROR, "tizen_sync_manager_proxy_new_sync failed %s", error->message);
TizenSyncManager *ipcObj = tizen_sync_manager_proxy_new_sync(connection,
@@ -176,7 +179,7 @@ int sync_adapter_set_callbacks(sync_adapter_start_sync_cb on_start_cb, sync_adap
if (__register_sync_adapter(true) == SYNC_ERROR_NONE) {
pid_t pid = getpid();
GError *error = NULL;
- GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
SYNC_LOGE_RET_RES(connection != NULL, SYNC_ERROR_SYSTEM, "System error occured %s", error->message);
char obj_path[50];
diff --git a/src/sync-client/sync_manager.c b/src/sync-client/sync_manager.c
index f5dec5e..1b62e07 100644
--- a/src/sync-client/sync_manager.c
+++ b/src/sync-client/sync_manager.c
@@ -77,8 +77,11 @@ char *proc_get_cmdline_self()
int ret;
ret = read_proc("/proc/self/cmdline", cmdline, sizeof(cmdline));
- if (ret <= 0)
+ if (ret <= 0) {
+ LOG_LOGD("Can not read /proc/self/cmdline");
return NULL;
+ }
+ LOG_LOGD("sync client: cmdLine [%s]", cmdline);
return strdup(cmdline);
}
@@ -135,7 +138,7 @@ static int initialize_connection()
GDBusConnection *connection = NULL;
GError *error = NULL;
- connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
TizenSyncManager *ipcObj = tizen_sync_manager_proxy_new_sync(connection,
G_DBUS_PROXY_FLAGS_NONE,
@@ -423,7 +426,7 @@ int sync_manager_foreach_sync_job(sync_manager_sync_job_cb sync_job_cb, void *us
return error_code;
} else {
- unmarshal_sync_job_list(sync_job_list_variant, sync_job_cb, user_data);
+ umarshal_sync_job_list(sync_job_list_variant, sync_job_cb, user_data);
}
return SYNC_ERROR_NONE;
diff --git a/src/sync-service/SyncManager_CapabilityInfo.cpp b/src/sync-service/SyncManager_CapabilityInfo.cpp
index 678aee6..9da4f27 100644
--- a/src/sync-service/SyncManager_CapabilityInfo.cpp
+++ b/src/sync-service/SyncManager_CapabilityInfo.cpp
@@ -62,11 +62,13 @@ CapabilityInfo::AddPeriodicSyncJob(int account_id, PeriodicSyncJob* pJob)
void
CapabilityInfo::RemovePeriodicSyncJob(PeriodicSyncJob* pJob)
{
+ /*
int acc_id;
- //int ret = account_get_account_id(pJob->accountHandle, &acc_id);
- //LOG_LOGE_VOID(ret == ACCOUNT_ERROR_NONE, "app account_get_account_id failed %d", ret);
+ int ret = account_get_account_id(pJob->accountHandle, &acc_id);
+ LOG_LOGE_VOID(ret == ACCOUNT_ERROR_NONE, "app account_get_account_id failed %d", ret);
- //__periodicSyncList.erase(__periodicSyncList.find(acc_id));
+ __periodicSyncList.erase(__periodicSyncList.find(acc_id));
+ */
}
diff --git a/src/sync-service/SyncManager_CurrentSyncJobQueue.cpp b/src/sync-service/SyncManager_CurrentSyncJobQueue.cpp
index 9c08065..59d3d4c 100644
--- a/src/sync-service/SyncManager_CurrentSyncJobQueue.cpp
+++ b/src/sync-service/SyncManager_CurrentSyncJobQueue.cpp
@@ -181,14 +181,19 @@ CurrentSyncJobQueue::RemoveSyncContextFromCurrentSyncQueue(CurrentSyncContext* p
string
CurrentSyncJobQueue::ToKey(account_h account, string capability)
{
- int ret;
+ int ret = ACCOUNT_ERROR_NONE;
string key;
char* pName;
int id;
stringstream ss;
ret = account_get_user_name(account, &pName);
+ if (ret != ACCOUNT_ERROR_NONE)
+ LOG_LOGD("Account get user name failed because of [%s]", get_error_message(ret));
+
ret = account_get_account_id(account, &id);
+ if (ret != ACCOUNT_ERROR_NONE)
+ LOG_LOGD("Account get account id failed because of [%s]", get_error_message(ret));
ss<<id;
key.append("id:").append(ss.str()).append("name:").append(pName).append("capability:").append(capability.c_str());
diff --git a/src/sync-service/SyncManager_DataChangeSyncScheduler.cpp b/src/sync-service/SyncManager_DataChangeSyncScheduler.cpp
index 7a03335..fc19fa5 100644
--- a/src/sync-service/SyncManager_DataChangeSyncScheduler.cpp
+++ b/src/sync-service/SyncManager_DataChangeSyncScheduler.cpp
@@ -70,7 +70,6 @@ void OnMediaContentDataChanged(media_content_error_e error, int pid, media_conte
{
LOG_LOGD("On Media Content Data Changed");
- media_content_type_e value = media_type;
DataChangeSyncScheduler* pDCScheduler = (DataChangeSyncScheduler*) (user_data);
switch (media_type) {
@@ -346,10 +345,13 @@ DataChangeSyncScheduler::HandleDataChangeEvent(const char* pSyncCapability)
}
+/* capability can be called as syncJobName in SyncManager */
int
DataChangeSyncScheduler::AddDataSyncJob(string capability, DataSyncJob* dataSyncJob)
{
__dataChangeSyncJobs.insert(make_pair(capability, dataSyncJob));
+
+ return SYNC_ERROR_NONE;
}
diff --git a/src/sync-service/SyncManager_PeriodicSyncScheduler.cpp b/src/sync-service/SyncManager_PeriodicSyncScheduler.cpp
index 55aa445..8f088aa 100644
--- a/src/sync-service/SyncManager_PeriodicSyncScheduler.cpp
+++ b/src/sync-service/SyncManager_PeriodicSyncScheduler.cpp
@@ -99,7 +99,8 @@ PeriodicSyncScheduler::SchedulePeriodicSyncJob(PeriodicSyncJob* periodicSyncJob)
string jobKey = periodicSyncJob->__key;
// Remove previous alarms, if set already
- int ret = RemoveAlarmForPeriodicSyncJob(periodicSyncJob);
+ int ret = SYNC_ERROR_NONE;
+ ret = RemoveAlarmForPeriodicSyncJob(periodicSyncJob);
SYNC_LOGE_RET_RES(ret == SYNC_ERROR_NONE, SYNC_ERROR_SYSTEM, "Failed to remove previous alarm for [%s], [%d]", jobKey.c_str(), ret);
alarm_id_t alarm_id;
@@ -114,8 +115,11 @@ PeriodicSyncScheduler::SchedulePeriodicSyncJob(PeriodicSyncJob* periodicSyncJob)
else
{
LOG_LOGD("Failed to add Alarm added for %ld min, ret %dd", periodicSyncJob->__period, ret);
+ return SYNC_ERROR_SYSTEM;
}
LOG_LOGD("Active periodic alarm count, %d", __activePeriodicSyncJobs.size());
+
+ return SYNC_ERROR_NONE;
}
diff --git a/src/sync-service/SyncManager_RepositoryEngine.cpp b/src/sync-service/SyncManager_RepositoryEngine.cpp
index 3e7152b..ee2fdc7 100644
--- a/src/sync-service/SyncManager_RepositoryEngine.cpp
+++ b/src/sync-service/SyncManager_RepositoryEngine.cpp
@@ -505,8 +505,7 @@ RepositoryEngine::ParseExtras(xmlNodePtr cur, bundle* pExtra)
void
RepositoryEngine::ParseSyncJobsN(xmlNodePtr cur, xmlChar* pPackage)
{
-
- xmlChar* pAppId = xmlGetProp(cur, XML_ATTR_JOB_APP_ID);
+ //xmlChar* pAppId = xmlGetProp(cur, XML_ATTR_JOB_APP_ID);
xmlChar* pAccId = xmlGetProp(cur, XML_ATTR_JOB_ACCOUNT_ID);
xmlChar* pJobId = xmlGetProp(cur, XML_ATTR_JOB_ID);
xmlChar* pJobName = xmlGetProp(cur, XML_ATTR_JOB_NAME);
@@ -536,10 +535,12 @@ RepositoryEngine::ParseSyncJobsN(xmlNodePtr cur, xmlChar* pPackage)
case SYNC_TYPE_DATA_CHANGE:
{
SyncManager::GetInstance()->AddDataSyncJob((char*)pPackage, (char*)pJobName, acountId, pExtra, syncOption, jobId, (char*)pJobName);
+ break;
}
case SYNC_TYPE_ON_DEMAND:
{
SyncManager::GetInstance()->AddOnDemandSync((char*)pPackage, (char*)pJobName, acountId, pExtra, syncOption,jobId);
+ break;
}
case SYNC_TYPE_PERIODIC:
{
@@ -547,6 +548,13 @@ RepositoryEngine::ParseSyncJobsN(xmlNodePtr cur, xmlChar* pPackage)
int period = (pPeriod == NULL)? 1800 : atoi((char*) pPeriod);
SyncManager::GetInstance()->AddPeriodicSyncJob((char*)pPackage, (char*)pJobName, acountId, pExtra, syncOption, jobId, period);
+ break;
+ }
+ case SYNC_TYPE_UNKNOWN:
+ default:
+ {
+ LOG_LOGD("failed add sync job: sync type is SYNC_TYPE_UNKNOWN");
+ break;
}
}
}
diff --git a/src/sync-service/SyncManager_SyncAdapterAggregator.cpp b/src/sync-service/SyncManager_SyncAdapterAggregator.cpp
index c5abba0..854e5b5 100644
--- a/src/sync-service/SyncManager_SyncAdapterAggregator.cpp
+++ b/src/sync-service/SyncManager_SyncAdapterAggregator.cpp
@@ -83,7 +83,7 @@ SyncAdapterAggregator::GetSyncAdapter(const char* pAppId)
string PkgId(pAppId);
if (PkgId.empty())
{
- PkgId = SyncManager::GetInstance()->GetPkgIdByCommandline(pAppId);
+ //PkgId = SyncManager::GetInstance()->GetPkgIdByCommandline(pAppId);
if (PkgId.empty())
return NULL;
}
@@ -95,6 +95,7 @@ SyncAdapterAggregator::GetSyncAdapter(const char* pAppId)
}
LOG_LOGD("Sync adapter not found for account provider id %s", pAppId);
+
return NULL;
}
diff --git a/src/sync-service/SyncManager_SyncJob.cpp b/src/sync-service/SyncManager_SyncJob.cpp
index 7580465..36633a7 100644
--- a/src/sync-service/SyncManager_SyncJob.cpp
+++ b/src/sync-service/SyncManager_SyncJob.cpp
@@ -52,51 +52,14 @@ SyncJob::~SyncJob(void)
SyncJob::SyncJob(const SyncJob& job)
{
- /*this->__appId = job.__appId;
- this->__account = job.__account;
- int id, id2;
- if (job.account != NULL)
- {
- int ret = account_get_account_id(job.__account, &id);
- if (ret != 0)
- {
- LOG_LOGD("Failed to get account id");
- return;
- }
- if (this->account == 0)
- {
- LOG_LOGD("acc null");
- }
- ret = account_get_account_id(this->__account, &id2);
- if (ret != 0)
- {
- LOG_LOGD("Failed to get account id2");
- return;
- }
- }
- this->__syncJobName = job.__syncJobName.c_str();
- this->__pExtras = bundle_dup(job.__pExtras);
- this->__reason = job.__reason;
- this->__syncSource = job.__syncSource;
- this->__isExpedited = job.__isExpedited;
- this->__key = job.__key.c_str();*/
-}
-
-
-SyncJob&
-SyncJob::operator = (const SyncJob& job)
-{
-/* this->__appId = job.__appId;
- LOG_LOGD("__appId %s", this->__appId.c_str());
- this->__account = job.__account;
- this->__syncJobName = job.__syncJobName;
- this->__pExtras = bundle_dup(job.pExtras);
- this->__reason = job.__reason;
- this->__syncSource = job.__syncSource;
- this->__isExpedited = job.__isExpedited;
- this->__key = job.__key;
-
- return *this;*/
+ __appId = job.__appId;
+ __accountId = job.__accountId;
+ __syncJobName = job.__syncJobName;
+ __pExtras = bundle_dup(job.__pExtras);
+ __isExpedited = job.__isExpedited;
+ __key = job.__key;
+ __waitCounter = job.__waitCounter;
+ __noRetry = job.__noRetry;
}
@@ -109,8 +72,8 @@ SyncJob::CleanBundle(bundle* pData)
SyncJob::SyncJob(const string appId, const string syncJobName, int account, bundle* pExtras, int syncOption, int syncJobId, SyncType syncType)
: ISyncJob(syncJobId, syncType)
, __appId(appId)
- , __accountId(account)
, __syncJobName(syncJobName)
+ , __accountId(account)
, __pExtras(NULL)
, __isExpedited(syncOption & SYNC_OPTION_EXPEDITED)
, __noRetry(syncOption & SYNC_OPTION_NO_RETRY)
@@ -188,27 +151,12 @@ SyncJob::Reset(int accountId, bundle* pUserData, int syncOption)
__accountId = accountId;
__noRetry = syncOption & SYNC_OPTION_NO_RETRY;
__isExpedited = syncOption & SYNC_OPTION_EXPEDITED;
- if (__pExtras)
- {
+ if (__pExtras) {
bundle_free(__pExtras);
__pExtras = bundle_dup(pUserData);
}
}
-
-/*
- * This compare is based on earliest effective runtime
- */
-int
-SyncJob::Compare(void* pObj)
-{
- SyncJob* pOtherJob = (SyncJob*)pObj;
- if (__isExpedited != pOtherJob->__isExpedited)
- {
- return __isExpedited ? -1 : 1;
- }
}
-
-}
//}//_SyncManager
diff --git a/src/sync-service/SyncManager_SyncJob.h b/src/sync-service/SyncManager_SyncJob.h
index 763f31a..4453799 100644
--- a/src/sync-service/SyncManager_SyncJob.h
+++ b/src/sync-service/SyncManager_SyncJob.h
@@ -49,8 +49,6 @@ public:
SyncJob(const SyncJob& job);
- SyncJob& operator=(const SyncJob& job);
-
SyncJob(const string appId, const string syncJobName, int accountId, bundle* pUserData, int syncOption, int syncJobId, SyncType type);
void Reset(int accountId, bundle* pUserData, int syncOption);
@@ -63,8 +61,6 @@ public:
string GetExtrasInfo(bundle* pData);
- int Compare(void* pOtherJob);
-
void SetJobExtraValue(const char* data, bool val);
void IncrementWaitCounter();
@@ -76,17 +72,17 @@ public:
public:
string __appId;
+ string __syncJobName;
int __accountId;
- SyncReason __reason;
- SyncSource __syncSource;
bundle* __pExtras;
- string __syncJobName;
- string __key;
- bool __noRetry;
bool __isExpedited;
- int __waitCounter;
+ bool __noRetry;
//SyncType __syncType;
//PendingJob* pPendingJob;
+ SyncReason __reason;
+ SyncSource __syncSource;
+ string __key;
+ int __waitCounter;
private:
diff --git a/src/sync-service/SyncManager_SyncJobDispatcher.cpp b/src/sync-service/SyncManager_SyncJobDispatcher.cpp
index b74ad12..a135de6 100644
--- a/src/sync-service/SyncManager_SyncJobDispatcher.cpp
+++ b/src/sync-service/SyncManager_SyncJobDispatcher.cpp
@@ -112,11 +112,13 @@ SyncJobDispatcher::HandleJobCompletedOrCancelledLocked(SyncStatus res, SyncJob *
case SYNC_STATUS_CANCELLED:
LOG_LOGD("Handle Sync event : SYNC_STATUS_CANCELLED");
SyncService::GetInstance()->TriggerStopSync(pJob->__appId.c_str(), pJob->__accountId, pJob->__syncJobName.c_str(), (pJob->GetSyncType() == SYNC_TYPE_DATA_CHANGE), pJob->__pExtras);
+ delete pJob;
break;
default:
break;
}
+
}
void
diff --git a/src/sync-service/SyncManager_SyncJobsInfo.cpp b/src/sync-service/SyncManager_SyncJobsInfo.cpp
index 3d4d3d1..3174db9 100644
--- a/src/sync-service/SyncManager_SyncJobsInfo.cpp
+++ b/src/sync-service/SyncManager_SyncJobsInfo.cpp
@@ -46,7 +46,7 @@ SyncJobsInfo::SyncJobsInfo(string packageId)
}
-int
+void
SyncJobsInfo::AddSyncJob(string syncJobName, ISyncJob* pSyncJob)
{
__syncJobsList.insert(make_pair(syncJobName, pSyncJob));
diff --git a/src/sync-service/SyncManager_SyncJobsInfo.h b/src/sync-service/SyncManager_SyncJobsInfo.h
index 735db9b..bc1969a 100644
--- a/src/sync-service/SyncManager_SyncJobsInfo.h
+++ b/src/sync-service/SyncManager_SyncJobsInfo.h
@@ -49,7 +49,7 @@ public:
int RemoveSyncJob(string syncJobName);
- int AddSyncJob(string syncJobName, ISyncJob* pSyncJob);
+ void AddSyncJob(string syncJobName, ISyncJob* pSyncJob);
int GetNextSyncJobId();
diff --git a/src/sync-service/SyncManager_SyncManager.cpp b/src/sync-service/SyncManager_SyncManager.cpp
index a6a5a48..59e31b7 100644
--- a/src/sync-service/SyncManager_SyncManager.cpp
+++ b/src/sync-service/SyncManager_SyncManager.cpp
@@ -30,6 +30,7 @@
#include <glib.h>
#include <aul.h>
#include <pkgmgr-info.h>
+#include <app_manager.h>
#include <tzplatform_config.h>
#include "sync-error.h"
#include "SyncManager_SyncManager.h"
@@ -52,32 +53,6 @@
int DELAY_RETRY_SYNC_IN_PROGRESS_IN_SECONDS = 10;
#define ID_FOR_ACCOUNT_LESS_SYNC -2
-template<>
-SyncManager*
-Singleton< SyncManager >::GetInstance()
-{
- if (__pInstance == NULL)
- {
- __pInstance = new (std::nothrow) SyncManager();
- if (__pInstance == NULL)
- {
- LOG_LOGD("Sync Manager creation failed");
- }
- else
- {
- if (!__pInstance->Construct())
- {
- LOG_LOGD("Sync Manager initialization failed");
-
- delete __pInstance;
- }
-
- }
- }
- return __pInstance;
-
-}
-
void
SyncManager::SetSyncSetting(bool enable)
@@ -292,6 +267,7 @@ SyncManager::UpdateRunningAccounts(void)
#endif
}
+
#if !defined(_SEC_FEATURE_CONTAINER_ENABLE)
bool OnAccountUpdated(const char* pEventType, int acountId, void* pUserData)
{
@@ -305,12 +281,13 @@ bool OnAccountUpdated(const char* pEventType, int acountId, void* pUserData)
}
#endif
+
void
SyncManager::OnDNetStatusChanged(bool connected)
{
LOG_LOGD("Data network change detected %d", connected);
- bool wasConnected = __isSimDataConnectionPresent;
+ //bool wasConnected = __isSimDataConnectionPresent;
__isSimDataConnectionPresent = connected;
if (__isSimDataConnectionPresent)
{
@@ -324,7 +301,7 @@ SyncManager::OnWifiStatusChanged(bool connected)
{
LOG_LOGD("Wifi network change detected %d", connected);
- bool wasConnected = __isWifiConnectionPresent;
+ //bool wasConnected = __isWifiConnectionPresent;
__isWifiConnectionPresent = connected;
if (__isWifiConnectionPresent)
{
@@ -358,6 +335,7 @@ SyncManager::OnStorageStatusChanged(int value)
}
}
+
void
SyncManager::OnUPSModeChanged(bool enable)
{
@@ -390,8 +368,6 @@ SyncManager::OnBatteryStatusChanged(int value)
}
-
-
static int OnPackageUninstalled(unsigned int userId, int reqId, const char* pPkgType, const char* pPkgId, const char* pKey, const char* pVal, const void* pMsg, void* pData)
{
LOG_LOGD("OnPackageUninstalled [type %s] type [pkdId:%s]", pPkgType, pPkgId);
@@ -406,36 +382,8 @@ static int OnPackageUninstalled(unsigned int userId, int reqId, const char* pPkg
string
-SyncManager::GetPkgIdByPID(int pid)
+SyncManager::GetPkgIdByAppId(const char* pAppId)
{
- string pkgIdStr;
- char appId[1024] = {0,};
-
- int ret = SYNC_ERROR_SYSTEM;
- if(aul_app_get_appid_bypid(pid, appId, sizeof(appId) - 1) == AUL_R_OK)
- {
- char pkgId[1024] = {0,};
- int ret = aul_app_get_pkgname_bypid(pid, pkgId, (int)(sizeof(pkgId) - 1));
- if(ret != AUL_R_OK)
- {
- LOG_LOGD("Get pkgid by PID failed for [%s] ret = %d ", appId, ret);
- }
- else
- {
- pkgIdStr.append(pkgId);
- }
- }
- else
- {
- char commandLine[1024] = {0,};
- //ret = aul_app_get_cmdline_bypid(pid, commandLine, sizeof(commandLine) - 1);
-
- LOG_LOGD("Request seems to be from app-id less/command line based request");
- pkgIdStr = GetPkgIdByCommandline(commandLine);
- }
-
- return pkgIdStr;
-/*
pkgmgrinfo_appinfo_h handle;
string pkgId;
@@ -459,10 +407,11 @@ SyncManager::GetPkgIdByPID(int pid)
{
LOG_LOGD("Failed to get pkgmgr AppInfoHandle from App Id [%s]", pAppId);
}
- return pkgId;*/
-}
+ return pkgId;
+}
+/*
string
SyncManager::GetPkgIdByCommandline(const char* pCommandLine)
{
@@ -495,8 +444,7 @@ SyncManager::GetPkgIdByCommandline(const char* pCommandLine)
return pkgId;
}
-
-
+*/
void
SyncManager::RegisterForNetworkChange(void)
@@ -525,6 +473,7 @@ SyncManager::DeRegisterForNetworkChange(void)
return -1;
}
+
void OnUPSModeChangedCb(keynode_t* pKey, void* pData)
{
int value = vconf_keynode_get_int(pKey);
@@ -778,13 +727,12 @@ SyncManager::Construct(void)
LOG_LOGD("wifi %d, sim %d storage %d", __isWifiConnectionPresent, __isSimDataConnectionPresent, __isStorageLow);
- __pDataChangeSyncScheduler->RegisterDataChangeListeners();
-
LOG_LOGD("Register event listeners");
RegisterForNetworkChange();
RegisterForStorageChange();
RegisterForBatteryStatus();
RegisterForUPSModeChange();
+ RegisterForDataChange();
LOG_LOGE_BOOL(pthread_mutex_init(&__syncJobQueueMutex, NULL) == 0, "__syncJobQueueMutex init failed");
LOG_LOGE_BOOL(pthread_mutex_init(&__currJobQueueMutex, NULL) == 0, "__currJobQueueMutex init failed");
@@ -794,7 +742,7 @@ SyncManager::Construct(void)
LOG_LOGE_BOOL(SetPkgMgrClientStatusChangedListener() == 0, "Failed to register for uninstall callback.");
-
+/*
#if !defined(_SEC_FEATURE_CONTAINER_ENABLE)
UpdateRunningAccounts();
@@ -807,7 +755,7 @@ SyncManager::Construct(void)
LOG_LOGD("Failed to register callback for account updation");
}
#endif
-
+*/
Initialize();
@@ -980,7 +928,7 @@ SyncManager::SendCancelSyncsMessage(SyncJob* pJob)
LOG_LOGD("SyncManager::SendCancelSyncsMessage :sending MESSAGE_CANCEL");
Message msg;
msg.type = SYNC_CANCEL;
- msg.pSyncJob = pJob;
+ msg.pSyncJob = new SyncJob(*pJob);
FireEvent(__pSyncJobDispatcher, msg);
}
diff --git a/src/sync-service/SyncManager_SyncManager.h b/src/sync-service/SyncManager_SyncManager.h
index 4c65460..9f84507 100644
--- a/src/sync-service/SyncManager_SyncManager.h
+++ b/src/sync-service/SyncManager_SyncManager.h
@@ -122,9 +122,9 @@ public:
long long GetElapsedTime(void);
- string GetPkgIdByPID(int pid);
+ string GetPkgIdByAppId(const char* pAppId);
- string GetPkgIdByCommandline(const char* pCommandLine);
+ //string GetPkgIdByCommandline(const char* pCommandLine);
void HandleShutdown(void);
diff --git a/src/sync-service/SyncManager_SyncService.cpp b/src/sync-service/SyncManager_SyncService.cpp
index f6e82cb..52a27f1 100644
--- a/src/sync-service/SyncManager_SyncService.cpp
+++ b/src/sync-service/SyncManager_SyncService.cpp
@@ -83,13 +83,18 @@ void convert_to_path(char app_id[])
int
SyncService::StartService()
{
- __pSyncMangerIntacnce = SyncManager::GetInstance();
- if (__pSyncMangerIntacnce == NULL)
- {
+ __pSyncManagerInstance = SyncManager::GetInstance();
+ if (__pSyncManagerInstance == NULL) {
LOG_LOGD("Failed to initialize sync manager");
return -1;
}
+ bool ret = __pSyncManagerInstance->Construct();
+ if (!ret) {
+ LOG_LOGD("Sync Manager Construct failed");
+
+ }
+
return 0;
}
@@ -221,7 +226,7 @@ SyncService::TriggerStopSync(const char* appId, int accountId, const char* syncJ
{
LOG_LOGD("Trigger stop sync %s", appId);
- int id = -1;
+ //int id = -1;
TizenSyncAdapter* pSyncAdapter = (TizenSyncAdapter*) g_hash_table_lookup(g_hash_table, appId);
if (pSyncAdapter == NULL)
@@ -239,7 +244,8 @@ SyncService::RequestOnDemandSync(const char* pPackageId, const char* pSyncJobNam
{
int ret = SYNC_ERROR_NONE;
int syncJobId = -1;
- SyncJobsAggregator* pSyncJobsAggregator = __pSyncMangerIntacnce->GetSyncJobsAggregator();
+
+ SyncJobsAggregator* pSyncJobsAggregator = __pSyncManagerInstance->GetSyncJobsAggregator();
ISyncJob* pSyncJob = pSyncJobsAggregator->GetSyncJob(pPackageId, pSyncJobName);
if (pSyncJob)
@@ -259,7 +265,7 @@ SyncService::RequestOnDemandSync(const char* pPackageId, const char* pSyncJobNam
SYNC_LOGE_RET_RES(syncJobId <= SYNC_JOB_LIMIT, SYNC_ERROR_QUOTA_EXCEEDED, "Sync job quota exceeded");
LOG_LOGD("New sync request. Adding sync job with Sync job name [%s] Sync job id [%d]", pSyncJobName, syncJobId);
- ret = __pSyncMangerIntacnce->AddOnDemandSync(pPackageId, pSyncJobName, accountId, pExtras, syncOption, syncJobId);
+ ret = __pSyncManagerInstance->AddOnDemandSync(pPackageId, pSyncJobName, accountId, pExtras, syncOption, syncJobId);
}
if (ret == SYNC_ERROR_NONE)
@@ -275,7 +281,7 @@ int
SyncService::RequestPeriodicSync(const char* pPackageId, const char* pSyncJobName, int accountId, bundle* pExtras, int syncOption, unsigned long pollFrequency, int* pSyncJobId)
{
int ret = SYNC_ERROR_NONE;
- SyncJobsAggregator* pSyncJobsAggregator = __pSyncMangerIntacnce->GetSyncJobsAggregator();
+ SyncJobsAggregator* pSyncJobsAggregator = __pSyncManagerInstance->GetSyncJobsAggregator();
int syncJobId = -1;
ISyncJob* pSyncJob = pSyncJobsAggregator->GetSyncJob(pPackageId, pSyncJobName);
@@ -296,7 +302,7 @@ SyncService::RequestPeriodicSync(const char* pPackageId, const char* pSyncJobNam
SYNC_LOGE_RET_RES(syncJobId <= SYNC_JOB_LIMIT, SYNC_ERROR_QUOTA_EXCEEDED, "Sync job quota exceeded");
LOG_LOGD("New sync request. Adding sync job with Sync job name [%s] Sync job id [%d]", pSyncJobName, syncJobId);
- ret = __pSyncMangerIntacnce->AddPeriodicSyncJob(pPackageId, pSyncJobName, accountId, pExtras, syncOption, syncJobId, pollFrequency);
+ ret = __pSyncManagerInstance->AddPeriodicSyncJob(pPackageId, pSyncJobName, accountId, pExtras, syncOption, syncJobId, pollFrequency);
}
if (ret == SYNC_ERROR_NONE)
@@ -311,7 +317,7 @@ int
SyncService::RequestDataSync(const char* pPackageId, const char* pSyncJobName, int accountId, bundle* pExtras, int syncOption, const char* pCapability, int* pSyncJobId)
{
int ret = SYNC_ERROR_NONE;
- SyncJobsAggregator* pSyncJobsAggregator = __pSyncMangerIntacnce->GetSyncJobsAggregator();
+ SyncJobsAggregator* pSyncJobsAggregator = __pSyncManagerInstance->GetSyncJobsAggregator();
int syncJobId = -1;
ISyncJob* pSyncJob = pSyncJobsAggregator->GetSyncJob(pPackageId, pSyncJobName);
@@ -332,7 +338,7 @@ SyncService::RequestDataSync(const char* pPackageId, const char* pSyncJobName, i
SYNC_LOGE_RET_RES(syncJobId <= SYNC_JOB_LIMIT, SYNC_ERROR_QUOTA_EXCEEDED, "Sync job quota exceeded");
LOG_LOGD("New sync request. Adding sync job with Sync job name [%s] Sync job id [%d]", pSyncJobName, syncJobId);
- ret = __pSyncMangerIntacnce->AddDataSyncJob(pPackageId, pSyncJobName, accountId, pExtras, syncOption, syncJobId, pCapability);
+ ret = __pSyncManagerInstance->AddDataSyncJob(pPackageId, pSyncJobName, accountId, pExtras, syncOption, syncJobId, pCapability);
}
if (ret == SYNC_ERROR_NONE)
@@ -401,37 +407,32 @@ sync_adapter_handle_send_result( TizenSyncAdapter* pObject, GDBusMethodInvocatio
guint pid = get_caller_pid(pInvocation);
string pkgIdStr;
- int ret;
- char appId[1024] = {0,};
- if(aul_app_get_appid_bypid(pid, appId, sizeof(appId) - 1) == AUL_R_OK)
+ char* pAppId = NULL;
+ int ret = app_manager_get_app_id(pid, &pAppId);
+ if (ret == APP_MANAGER_ERROR_NONE)
{
- char pkgId[1024] = {0,};
- ret = aul_app_get_pkgname_bypid(pid, pkgId, (int)(sizeof(pkgId) - 1));
- if(ret != AUL_R_OK)
- {
- LOG_LOGD("Get pkg name by PID failed for [%s] ret = %d ", appId, ret);
- }
- else
- {
- pkgIdStr.append(pkgId);
- }
+ pkgIdStr = SyncManager::GetInstance()->GetPkgIdByAppId(pAppId);
}
else
{
- char commandLine[1024] = {0,};
- //ret = aul_app_get_cmdline_bypid(pid, commandLine, sizeof(commandLine) - 1);
LOG_LOGD("Request seems to be from app-id less/command line based request");
- pkgIdStr = SyncManager::GetInstance()->GetPkgIdByCommandline(commandLine);
+ /*
+ char commandLine[1024] = {0,};
+ ret = aul_app_get_cmdline_bypid(pid, commandLine, sizeof(commandLine) - 1);
+ if (ret == AUL_R_OK)
+ pkgIdStr = SyncManager::GetInstance()->GetPkgIdByCommandline(commandLine);
+ */
}
if (!pkgIdStr.empty())
{
- LOG_LOGD("Sync result received from [%s]: sync_job_name [%s] result [%d]", appId, sync_job_name, sync_result);
+ LOG_LOGD("Sync result received from [%s]: sync_job_name [%s] result [%d]", pAppId, sync_job_name, sync_result);
- SyncManager::GetInstance()->OnResultReceived((SyncStatus)sync_result, appId, pkgIdStr, sync_job_name);
+ SyncManager::GetInstance()->OnResultReceived((SyncStatus)sync_result, pAppId, pkgIdStr, sync_job_name);
+ free(pAppId);
}
else
- LOG_LOGD("Get package Id fail %d", ret);
+ LOG_LOGD("sync service: Get package Id fail %d", ret);
tizen_sync_adapter_complete_send_result(pObject, pInvocation);
@@ -476,21 +477,36 @@ sync_manager_add_on_demand_sync_job(TizenSyncManager* pObject, GDBusMethodInvoca
LOG_LOGD("Received On-Demand Sync request");
guint pid = get_caller_pid(pInvocation);
- string pkgId = SyncManager::GetInstance()->GetPkgIdByPID(pid);
- int ret = SYNC_ERROR_SYSTEM;
+ string pkgIdStr;
+ char* pAppId = NULL;
+ int ret = app_manager_get_app_id(pid, &pAppId);
+ if (ret == APP_MANAGER_ERROR_NONE)
+ {
+ pkgIdStr = SyncManager::GetInstance()->GetPkgIdByAppId(pAppId);
+ free(pAppId);
+ }
+ else
+ {
+ LOG_LOGD("Request seems to be from app-id less/command line based request");
+ /*
+ char commandLine[1024] = {0,};
+ ret = aul_app_get_cmdline_bypid(pid, commandLine, sizeof(commandLine) - 1);
+ if (ret == AUL_R_OK)
+ pkgIdStr = SyncManager::GetInstance()->GetPkgIdByCommandline(commandLine);
+ */
+ }
+
int sync_job_id = 0;
- if(!pkgId.empty())
+ if(!pkgIdStr.empty())
{
- LOG_LOGD("Params acc[%d] name[%s] option[%d] package[%s]", accountId, pSyncJobName, sync_option, pkgId.c_str());
+ LOG_LOGD("Params acc[%d] name[%s] option[%d] package[%s]", accountId, pSyncJobName, sync_option, pkgIdStr.c_str());
bundle* pBundle = umarshal_bundle(pSyncJobUserData);
SyncManager::GetInstance()->AddRunningAccount(accountId, pid);
- ret = SyncService::GetInstance()->RequestOnDemandSync(pkgId.c_str(), pSyncJobName, accountId, pBundle, sync_option, &sync_job_id);
+ ret = SyncService::GetInstance()->RequestOnDemandSync(pkgIdStr.c_str(), pSyncJobName, accountId, pBundle, sync_option, &sync_job_id);
bundle_free(pBundle);
}
else
- {
- LOG_LOGD("Failed to get package id");
- }
+ LOG_LOGD("sync service: Get package Id fail %d", ret);
if (ret != SYNC_ERROR_NONE)
{
@@ -511,15 +527,35 @@ gboolean
sync_manager_remove_sync_job(TizenSyncManager* pObject, GDBusMethodInvocation* pInvocation, gint sync_job_id)
{
LOG_LOGD("Request to remove sync job %d", sync_job_id);
- int ret = SYNC_ERROR_SYSTEM;
+
guint pid = get_caller_pid(pInvocation);
+ string pkgIdStr;
+ char* pAppId;
+ int ret = APP_MANAGER_ERROR_NONE;
- string pkgId = SyncManager::GetInstance()->GetPkgIdByPID(pid);
- if(!pkgId.empty())
+ ret = app_manager_get_app_id(pid, &pAppId);
+ if (ret == APP_MANAGER_ERROR_NONE)
+ {
+ pkgIdStr = SyncManager::GetInstance()->GetPkgIdByAppId(pAppId);
+ free(pAppId);
+ }
+ else
+ {
+ LOG_LOGD("Request seems to be from app-id less/command line based request");
+ /*
+ char commandLine[1024] = {0,};
+ ret = aul_app_get_cmdline_bypid(pid, commandLine, sizeof(commandLine) - 1);
+ if (ret == AUL_R_OK)
+ pkgIdStr = SyncManager::GetInstance()->GetPkgIdByCommandline(commandLine);
+ */
+ }
+ if(!pkgIdStr.empty())
{
- LOG_LOGD("package id [%s]", pkgId.c_str());
- ret = SyncManager::GetInstance()->RemoveSyncJob(pkgId, sync_job_id);
+ LOG_LOGD("package id [%s]", pkgIdStr.c_str());
+ ret = SyncManager::GetInstance()->RemoveSyncJob(pkgIdStr, sync_job_id);
}
+ else
+ LOG_LOGD("sync service: Get package Id fail %d", ret);
if (ret != SYNC_ERROR_NONE)
{
@@ -531,6 +567,7 @@ sync_manager_remove_sync_job(TizenSyncManager* pObject, GDBusMethodInvocation* p
tizen_sync_manager_complete_remove_sync_job(pObject, pInvocation);
LOG_LOGD("sync service: remove sync job ends");
+
return true;
}
@@ -545,7 +582,6 @@ sync_manager_add_periodic_sync_job(TizenSyncManager* pObject, GDBusMethodInvocat
{
LOG_LOGD("Received Period Sync request");
- int ret = SYNC_ERROR_NONE;
guint pid = get_caller_pid(pInvocation);
/*
ret = _check_privilege_by_pid(ALARM_SET_LABEL, WRITE_PERM, true, pid);
@@ -556,16 +592,38 @@ sync_manager_add_periodic_sync_job(TizenSyncManager* pObject, GDBusMethodInvocat
return true;
}
*/
+ string pkgIdStr;
+
int sync_job_id = 0;
- string pkgId = SyncManager::GetInstance()->GetPkgIdByPID(pid);
- if(!pkgId.empty())
+ char* pAppId;
+ int ret = APP_MANAGER_ERROR_NONE;
+
+ ret = app_manager_get_app_id(pid, &pAppId);
+ if (ret == APP_MANAGER_ERROR_NONE)
+ {
+ pkgIdStr = SyncManager::GetInstance()->GetPkgIdByAppId(pAppId);
+ free(pAppId);
+ }
+ else
+ {
+ LOG_LOGD("Request seems to be from app-id less/command line based request");
+ /*
+ char commandLine[1024] = {0,};
+ ret = aul_app_get_cmdline_bypid(pid, commandLine, sizeof(commandLine) - 1);
+ if (ret == AUL_R_OK)
+ pkgIdStr = SyncManager::GetInstance()->GetPkgIdByCommandline(commandLine);
+ */
+ }
+ if(!pkgIdStr.empty())
{
- LOG_LOGD("Params acc[%d] name[%s] option[%d] period[%d] package[%s]", accountId, pSyncJobName, sync_option, sync_interval, pkgId.c_str());
+ LOG_LOGD("Params acc[%d] name[%s] option[%d] period[%d] package[%s]", accountId, pSyncJobName, sync_option, sync_interval, pkgIdStr.c_str());
bundle* pBundle = umarshal_bundle(pSyncJobUserData);
SyncManager::GetInstance()->AddRunningAccount(accountId, pid);
- ret = SyncService::GetInstance()->RequestPeriodicSync(pkgId.c_str(), pSyncJobName, accountId, pBundle, sync_option, sync_interval, &sync_job_id);
+ ret = SyncService::GetInstance()->RequestPeriodicSync(pkgIdStr.c_str(), pSyncJobName, accountId, pBundle, sync_option, sync_interval, &sync_job_id);
bundle_free(pBundle);
}
+ else
+ LOG_LOGD("sync service: Get package Id fail %d", ret);
if (ret != SYNC_ERROR_NONE)
{
@@ -577,6 +635,7 @@ sync_manager_add_periodic_sync_job(TizenSyncManager* pObject, GDBusMethodInvocat
tizen_sync_manager_complete_add_periodic_sync_job(pObject, pInvocation, sync_job_id);
LOG_LOGD("sync service: add periodic sync job ends");
+
return true;
}
@@ -589,7 +648,7 @@ sync_manager_add_data_change_sync_job(TizenSyncManager* pObject, GDBusMethodInvo
GVariant* pSyncJobUserData)
{
LOG_LOGD("Received data change Sync request");
- int ret = SYNC_ERROR_NONE;
+
guint pid = get_caller_pid(pInvocation);
/*
const char *capability = (char *)pCapabilityArg;
@@ -608,18 +667,39 @@ sync_manager_add_data_change_sync_job(TizenSyncManager* pObject, GDBusMethodInvo
}
}
*/
+ string pkgIdStr;
int sync_job_id = 0;
- string pkgId = SyncManager::GetInstance()->GetPkgIdByPID(pid);
- if(!pkgId.empty())
+ char* pAppId;
+ int ret = APP_MANAGER_ERROR_NONE;
+
+ ret = app_manager_get_app_id(pid, &pAppId);
+ if (ret == APP_MANAGER_ERROR_NONE)
{
- LOG_LOGD("Params account [%d] job_name [%s] sync_option[%d] sync_job_id[%d] package [%s] ", accountId, pCapabilityArg, sync_option, sync_job_id, pkgId.c_str());
+ pkgIdStr = SyncManager::GetInstance()->GetPkgIdByAppId(pAppId);
+ free(pAppId);
+ }
+ else
+ {
+ LOG_LOGD("Request seems to be from app-id less/command line based request");
+ /*
+ char commandLine[1024] = {0,};
+ ret = aul_app_get_cmdline_bypid(pid, commandLine, sizeof(commandLine) - 1);
+ if (ret == AUL_R_OK)
+ pkgIdStr = SyncManager::GetInstance()->GetPkgIdByCommandline(commandLine);
+ */
+ }
+ if(!pkgIdStr.empty())
+ {
+ LOG_LOGD("Params account [%d] job_name [%s] sync_option[%d] sync_job_id[%d] package [%s] ", accountId, pCapabilityArg, sync_option, sync_job_id, pkgIdStr.c_str());
bundle* pBundle = umarshal_bundle(pSyncJobUserData);
SyncManager::GetInstance()->AddRunningAccount(accountId, pid);
- ret = SyncService::GetInstance()->RequestDataSync(pkgId.c_str(), pCapabilityArg, accountId, pBundle, sync_option, pCapabilityArg, &sync_job_id);
+ ret = SyncService::GetInstance()->RequestDataSync(pkgIdStr.c_str(), pCapabilityArg, accountId, pBundle, sync_option, pCapabilityArg, &sync_job_id);
bundle_free(pBundle);
}
+ else
+ LOG_LOGD("sync service: Get package Id fail %d", ret);
if (ret != SYNC_ERROR_NONE)
{
@@ -631,6 +711,7 @@ sync_manager_add_data_change_sync_job(TizenSyncManager* pObject, GDBusMethodInvo
tizen_sync_manager_complete_add_data_change_sync_job(pObject, pInvocation, sync_job_id);
LOG_LOGD("sync service: add data sync job ends");
+
return true;
}
@@ -667,29 +748,26 @@ gboolean
sync_manager_add_sync_adapter(TizenSyncManager* pObject, GDBusMethodInvocation* pInvocation, const gchar* pCommandLine)
{
LOG_LOGD("Received sync adapter registration request");
- guint pid = get_caller_pid(pInvocation);
- int ret = SYNC_ERROR_SYSTEM;
+
string pkgIdStr;
- char appId[1024] = {0,};
- if(aul_app_get_appid_bypid(pid, appId, sizeof(appId) - 1) == AUL_R_OK)
+ guint pid = get_caller_pid(pInvocation);
+ char* pAppId;
+ int ret = APP_MANAGER_ERROR_NONE;
+
+ ret = app_manager_get_app_id(pid, &pAppId);
+ if (ret == APP_MANAGER_ERROR_NONE)
{
- char pkgId[1024] = {0,};
- int ret = aul_app_get_pkgname_bypid(pid, pkgId, (int)(sizeof(pkgId) - 1));
- if(ret != AUL_R_OK)
- {
- LOG_LOGD("Get pkgid by PID failed for [%s] ret = %d ", appId, ret);
- }
- else
- {
- pkgIdStr.append(pkgId);
- }
+ pkgIdStr = SyncManager::GetInstance()->GetPkgIdByAppId(pAppId);
}
else
{
- char commandLine[1024] = {0,};
- //ret = aul_app_get_cmdline_bypid(pid, commandLine, sizeof(commandLine) - 1);
LOG_LOGD("Request seems to be from app-id less/command line based request");
- pkgIdStr = SyncManager::GetInstance()->GetPkgIdByCommandline(commandLine);
+ /*
+ char commandLine[1024] = {0,};
+ ret = aul_app_get_cmdline_bypid(pid, commandLine, sizeof(commandLine) - 1);
+ if (ret == AUL_R_OK)
+ pkgIdStr = SyncManager::GetInstance()->GetPkgIdByCommandline(commandLine);
+ */
}
if(!pkgIdStr.empty())
@@ -706,13 +784,18 @@ sync_manager_add_sync_adapter(TizenSyncManager* pObject, GDBusMethodInvocation*
if (g_dbus_interface_skeleton_export(interface, gdbusConnection, object_path, &error))
{
g_signal_connect(syncAdapterObj, "handle-send-result", G_CALLBACK(sync_adapter_handle_send_result), NULL);
- g_signal_connect(syncAdapterObj, "handle-init-complete", G_CALLBACK(sync_adapter_handle_init_complete), NULL);
+ //g_signal_connect(syncAdapterObj, "handle-init-complete", G_CALLBACK(sync_adapter_handle_init_complete), NULL);
SyncAdapterAggregator* pAggregator = SyncManager::GetInstance()->GetSyncAdapterAggregator();
- pAggregator->AddSyncAdapter(pkgIdStr.c_str(), appId);
+ if (pAggregator == NULL) {
+ LOG_LOGD("sync adapter aggregator is NULL");
+ tizen_sync_manager_complete_add_sync_adapter(pObject, pInvocation);
+ return true;
+ }
+ pAggregator->AddSyncAdapter(pkgIdStr.c_str(), pAppId);
- LOG_LOGD("inserting sync adapter ipc %s", appId);
- g_hash_table_insert(g_hash_table, strdup(appId), syncAdapterObj);
+ LOG_LOGD("inserting sync adapter ipc %s", pAppId);
+ g_hash_table_insert(g_hash_table, strdup(pAppId), syncAdapterObj);
ret = SYNC_ERROR_NONE;
}
else
@@ -739,7 +822,7 @@ sync_manager_add_sync_adapter(TizenSyncManager* pObject, GDBusMethodInvocation*
else
tizen_sync_manager_complete_add_sync_adapter(pObject, pInvocation);
- LOG_LOGD("End");
+ LOG_LOGD("sync service: add sync adapter ends");
return true;
}
@@ -749,29 +832,26 @@ gboolean
sync_manager_remove_sync_adapter(TizenSyncManager* pObject, GDBusMethodInvocation* pInvocation, const gchar* pCommandLine)
{
LOG_LOGD("Request to remove sync adapter");
+
guint pid = get_caller_pid(pInvocation);
string pkgIdStr;
- int ret;
- char appId[1024] = {0,};
- if(aul_app_get_appid_bypid(pid, appId, sizeof(appId) - 1) == AUL_R_OK)
+ char* pAppId;
+ int ret = APP_MANAGER_ERROR_NONE;
+
+ ret = app_manager_get_app_id(pid, &pAppId);
+ if (ret == APP_MANAGER_ERROR_NONE)
{
- char pkgId[1024] = {0,};
- ret = aul_app_get_pkgname_bypid(pid, pkgId, (int)(sizeof(pkgId) - 1));
- if(ret != AUL_R_OK)
- {
- LOG_LOGD("Get pkgid by PID failed for [%s] ret = %d ", appId, ret);
- }
- else
- {
- pkgIdStr.append(pkgId);
- }
+ pkgIdStr = SyncManager::GetInstance()->GetPkgIdByAppId(pAppId);
}
else
{
- char commandLine[1024] = {0,};
- //ret = aul_app_get_cmdline_bypid(pid, commandLine, sizeof(commandLine) - 1);
LOG_LOGD("Request seems to be from app-id less/command line based request");
- pkgIdStr = SyncManager::GetInstance()->GetPkgIdByCommandline(commandLine);
+ /*
+ char commandLine[1024] = {0,};
+ ret = aul_app_get_cmdline_bypid(pid, commandLine, sizeof(commandLine) - 1);
+ if (ret == AUL_R_OK)
+ pkgIdStr = SyncManager::GetInstance()->GetPkgIdByCommandline(commandLine);
+ */
}
if(!pkgIdStr.empty())
@@ -780,11 +860,14 @@ sync_manager_remove_sync_adapter(TizenSyncManager* pObject, GDBusMethodInvocatio
pAggregator->RemoveSyncAdapter(pkgIdStr.c_str());
LOG_LOGD("Sync adapter removed for package [%s]", pkgIdStr.c_str());
}
+ else
+ LOG_LOGD("sync service: Get package Id fail %d", ret);
- TizenSyncAdapter* pSyncAdapter = (TizenSyncAdapter*) g_hash_table_lookup(g_hash_table, appId);
+ TizenSyncAdapter* pSyncAdapter = (TizenSyncAdapter*) g_hash_table_lookup(g_hash_table, pAppId);
if (pSyncAdapter == NULL)
{
- LOG_LOGD("Failed to lookup syncadapter gdbus object for [%s]", appId);
+ LOG_LOGD("Failed to lookup syncadapter gdbus object for [%s]", pAppId);
+ free(pAppId);
}
else
{
@@ -795,7 +878,7 @@ sync_manager_remove_sync_adapter(TizenSyncManager* pObject, GDBusMethodInvocatio
tizen_sync_manager_complete_remove_sync_adapter(pObject, pInvocation);
- LOG_LOGD("End");
+ LOG_LOGD("sync service: remove sync adapter ends");
return true;
}
@@ -833,12 +916,29 @@ sync_manager_get_all_sync_jobs(TizenSyncManager* pObject, GDBusMethodInvocation*
{
LOG_LOGD("Received request to get Sync job ids");
- int ret = SYNC_ERROR_SYSTEM;
-
guint pid = get_caller_pid(pInvocation);
- string pkgId = SyncManager::GetInstance()->GetPkgIdByPID(pid);
+ string pkgId;
+ char* pAppId;
+ int ret = APP_MANAGER_ERROR_NONE;
+
+ ret = app_manager_get_app_id(pid, &pAppId);
+ if (ret == APP_MANAGER_ERROR_NONE)
+ {
+ pkgId = SyncManager::GetInstance()->GetPkgIdByAppId(pAppId);
+ free(pAppId);
+ }
+ else
+ {
+ LOG_LOGD("Request seems to be from app-id less/command line based request");
+ /*
+ char commandLine[1024] = {0,};
+ ret = aul_app_get_cmdline_bypid(pid, commandLine, sizeof(commandLine) - 1);
+ if (ret == AUL_R_OK)
+ pkgIdStr = SyncManager::GetInstance()->GetPkgIdByCommandline(commandLine);
+ */
+ }
- GVariant* outSyncJobList;
+ GVariant* outSyncJobList = NULL;
GVariantBuilder builder;
if(!pkgId.empty())
@@ -883,7 +983,7 @@ sync_manager_get_all_sync_jobs(TizenSyncManager* pObject, GDBusMethodInvocation*
else
tizen_sync_manager_complete_get_all_sync_jobs(pObject, pInvocation, outSyncJobList);
- LOG_LOGD("End");
+ LOG_LOGD("sync service: get all sync jobs ends");
return true;
}
diff --git a/src/sync-service/SyncManager_SyncService.h b/src/sync-service/SyncManager_SyncService.h
index 8a4cf6d..9e492d4 100644
--- a/src/sync-service/SyncManager_SyncService.h
+++ b/src/sync-service/SyncManager_SyncService.h
@@ -72,7 +72,7 @@ private:
void InitializeDbus();
private:
- SyncManager* __pSyncMangerIntacnce;
+ SyncManager* __pSyncManagerInstance;
};
//}//_SyncManager
#endif //SYNC_SERVICE_SYNC_SERVICE_H
diff --git a/sync-service.manifest b/sync-service.manifest
index ca37499..a76fdba 100644
--- a/sync-service.manifest
+++ b/sync-service.manifest
@@ -3,4 +3,3 @@
<domain name="_" />
</request>
</manifest>
-