Skip to content
Snippets Groups Projects
Commit 0def5bb3 authored by Dilip Balaraju's avatar Dilip Balaraju Committed by Sjoerd Simons
Browse files

Added GLib message logging mechanism.


Added macros NEWPORT_DEBUG, NEWPORT_CRITICAL, NEWPORT_WARNING
for g_debug,g_critical,g_warning respectively.
And replaced few g_debug with NEWPORT_CRITICAL/NEWPORT_WARNING.

Part of D199

Reviewed-by: default avatarPhilip Withnall <philip.withnall@collabora.co.uk>
Signed-off-by: default avatarSjoerd Simons <sjoerd.simons@collabora.co.uk>
parent bf801930
No related branches found
No related tags found
No related merge requests found
......@@ -59,7 +59,8 @@ nodist_libnewportiface_la_SOURCES = \
$(newport_sources_xml:.xml=.h) \
$(NULL)
libnewportiface_la_CPPFLAGS = $(service_cppflags)
libnewportiface_la_CPPFLAGS = $(service_cppflags) \
-DG_LOG_DOMAIN=\"Newport\"
libnewportiface_la_CFLAGS = $(service_cflags)
libnewportiface_la_LIBADD = $(service_libadd)
libnewportiface_la_LDFLAGS = $(service_ldflags)
......
......@@ -27,8 +27,8 @@ source_c = newport-main.c \
newport-service-handler.c
# Preprocessor flags
newport_CPPFLAGS = $(includes) \
$(AM_CPPFLAGS)
newport_CPPFLAGS = $(includes) $(AM_CPPFLAGS) \
-DG_LOG_DOMAIN=\"Newport\"
newport_LDADD = $(GCC_FLAGS) $(GLIB_LIBS) $(CURL_LIBS) $(SEATON_LIBS) $(CODE_COVERAGE_LIBS) $(AM_LIBADD) \
../interface/libnewportiface.la
......
......@@ -59,7 +59,7 @@ static gint download_progress_clb(DownloadUrlInfo* pUrlInfo, double dltotal,
|| (pUrlInfo->u32CurrentDownloadState == NEWPORT_DOWNLOAD_CANCELLED)
|| (pUrlInfo->u32CurrentDownloadState == NEWPORT_DOWNLOAD_PAUSED_BY_SYSTEM))
{
g_debug("stopped the curl dnl thread %s",
NEWPORT_DEBUG("Stopped the curl download thread %s",
pUrlInfo->pDownloadFileName);
pUrlInfo->progress.u8ProgressCount = 0;
g_object_unref (Download);
......@@ -99,12 +99,12 @@ static FILE* curl_plugin_open_file(DownloadUrlInfo* pUrlInfo,GError **error)
fseek (fp, 0, SEEK_END);
pUrlInfo->FileOffset = ftell (fp);
g_debug("File offset %"G_GOFFSET_FORMAT"", pUrlInfo->FileOffset);
NEWPORT_DEBUG("File offset %"G_GOFFSET_FORMAT"", pUrlInfo->FileOffset);
curl_easy_setopt (pUrlInfo->pCurlObg, CURLOPT_WRITEDATA, fp);
curl_easy_setopt (pUrlInfo->pCurlObg, CURLOPT_RESUME_FROM_LARGE,
pUrlInfo->FileOffset);
return fp;
return fp;
}
GQuark newport_download_error_quark(void)
......@@ -125,7 +125,7 @@ start_new_download_thread (GTask *task, NewportDownload *Download,
gint error_no=-1;
// long curl_time;
long response_code;
g_debug("Starting new download thread, Count = %d",
NEWPORT_DEBUG("Starting new download thread, Count = %d",
pDnlMgrObj.uinDownloadCount);
// pCurlObg init
......@@ -186,7 +186,7 @@ start_new_download_thread (GTask *task, NewportDownload *Download,
// 5xx Server Error
if (response_code >= 400)
{
g_debug("Server response code : %ld", response_code);
NEWPORT_DEBUG("Server response code : %ld", response_code);
// discard data if error
pUrlInfo->FileOffset = pUrlInfo->OldFileOffset;
fseek (fp, pUrlInfo->FileOffset, SEEK_SET);
......@@ -205,7 +205,7 @@ start_new_download_thread (GTask *task, NewportDownload *Download,
switch (curl_code)
{
case CURLE_OK:
g_debug("CURL DOWNLOAD STATUS: OK ");
NEWPORT_DEBUG("CURL DOWNLOAD STATUS: OK ");
curl_easy_getinfo (pCurlObg, CURLINFO_FILETIME, &pUrlInfo->lCurlTime);
pUrlInfo->u32CurrentDownloadState = NEWPORT_DOWNLOAD_SUCCESS;
g_task_return_boolean (task, TRUE);
......@@ -213,7 +213,6 @@ start_new_download_thread (GTask *task, NewportDownload *Download,
// can resume (retry)
case CURLE_PARTIAL_FILE:
g_debug("CURL DNL STATUS: Partial file downloaded");
pUrlInfo->u32CurrentDownloadState = NEWPORT_DOWNLOAD_FAILED;
error_no=NEWPORT_DOWNLOAD_MANAGER_NETWORK_ERROR;
break;
......@@ -227,7 +226,7 @@ start_new_download_thread (GTask *task, NewportDownload *Download,
fs_truncate (fp, 0);
pUrlInfo->u32CurrentDownloadState = NEWPORT_DOWNLOAD_IN_PROGRESS;
newport_download_set_state (Download, NEWPORT_DOWNLOAD_IN_PROGRESS);
g_debug("CURL DNL STATUS: Range error or bad download error");
NEWPORT_WARNING("CURL DNL STATUS: Range error or bad download error");
unlink_file (pUrlInfo->pTempDownloadPath);
store_url_data_in_db (pUrlInfo);
start_new_download_thread (task, Download, pUrlInfo, cancellable);
......@@ -236,18 +235,15 @@ start_new_download_thread (GTask *task, NewportDownload *Download,
// retry
case CURLE_GOT_NOTHING:
g_debug("CURL DNL STATUS: got nothing error");
pUrlInfo->u32CurrentDownloadState = NEWPORT_DOWNLOAD_FAILED;
error_no=NEWPORT_DOWNLOAD_MANAGER_NETWORK_ERROR;
break;
case CURLE_RECV_ERROR:
g_debug("CURL DNL STATUS: reveive error");
pUrlInfo->u32CurrentDownloadState = NEWPORT_DOWNLOAD_FAILED;
error_no=NEWPORT_DOWNLOAD_MANAGER_NETWORK_ERROR;
break;
case CURLE_OPERATION_TIMEDOUT:
case CURLE_BAD_CONTENT_ENCODING:
g_debug("CURL DNL STATUS: no data found error , bad encoding error");
pUrlInfo->u32CurrentDownloadState = NEWPORT_DOWNLOAD_FAILED;
error_no=NEWPORT_DOWNLOAD_MANAGER_NETWORK_ERROR;
/* send a retry message to resume the download */
......@@ -255,38 +251,31 @@ start_new_download_thread (GTask *task, NewportDownload *Download,
// can't connect (retry)
case CURLE_COULDNT_CONNECT:
g_debug("CURL DNL STATUS: couldnt connect to network :: %s",
pUrlInfo->pCurlErrorString);
pUrlInfo->u32CurrentDownloadState = NEWPORT_DOWNLOAD_FAILED;
error_no=NEWPORT_DOWNLOAD_MANAGER_NETWORK_ERROR;
break;
// too many redirection (exit)
case CURLE_TOO_MANY_REDIRECTS:
g_debug("CURL DNL STATUS: too many redirections");
pUrlInfo->u32CurrentDownloadState = NEWPORT_DOWNLOAD_FAILED;
error_no=NEWPORT_DOWNLOAD_MANAGER_NETWORK_ERROR;
break;
// abort by user (exit)
case CURLE_ABORTED_BY_CALLBACK:
g_debug("CURL DNL STATUS: pCurlObg was aborted by the user callback");
NEWPORT_DEBUG("CURL DNL STATUS: pCurlObg was aborted by the user callback");
g_task_return_boolean (task, FALSE);
break;
// out of resource (exit)
case CURLE_OUT_OF_MEMORY:
case CURLE_WRITE_ERROR:
g_debug("CURL DNL STATUS: there was a write error or we ran out of memory :: %s",
pUrlInfo->pCurlErrorString);
pUrlInfo->u32CurrentDownloadState = NEWPORT_DOWNLOAD_FAILED;
error_no=NEWPORT_DOWNLOAD_MANAGER_NO_MEMORY_ERROR;
break;
// exit
case CURLE_UNSUPPORTED_PROTOCOL:
g_debug(" CURL DNL STATUS: unsupported protocol :: %s",
pUrlInfo->pCurlErrorString);
pUrlInfo->u32CurrentDownloadState = NEWPORT_DOWNLOAD_FAILED;
error_no=NEWPORT_DOWNLOAD_MANAGER_NETWORK_ERROR;
break;
......@@ -299,13 +288,10 @@ start_new_download_thread (GTask *task, NewportDownload *Download,
case CURLE_FTP_WEIRD_SERVER_REPLY:
case CURLE_REMOTE_ACCESS_DENIED:
default:
g_debug(" CURL DNL STATUS: access denied to the server :: %s",
pUrlInfo->pCurlErrorString);
pUrlInfo->u32CurrentDownloadState = NEWPORT_DOWNLOAD_FAILED;
error_no=NEWPORT_DOWNLOAD_MANAGER_NETWORK_ERROR;
break;
}
}
if (error_no != -1)
{
......@@ -318,7 +304,7 @@ start_new_download_thread (GTask *task, NewportDownload *Download,
{
fclose (fp);
fp = NULL;
}
}
pDnlMgrObj.uinDownloadCount--;
......@@ -341,33 +327,34 @@ void download_url_info_free(DownloadUrlInfo *pUrlInfo)
gint unlink_file(const gchar *pFilename)
{
if (g_get_filename_charsets(NULL))
{
g_debug("Temp download path %s", pFilename);
return g_unlink(pFilename);
}
else
{
gchar *cp_filename = g_filename_from_utf8(pFilename, -1, NULL, NULL,
NULL);
g_debug("Temp download path %s", cp_filename);
gint save_errno;
gint retval;
g_return_val_if_fail (pFilename != NULL, -1);
if (g_get_filename_charsets (NULL))
{
NEWPORT_DEBUG("Temp download path %s", pFilename);
return g_unlink (pFilename);
}
else
{
gchar *cp_filename = g_filename_from_utf8 (pFilename, -1, NULL, NULL,
NULL);
NEWPORT_DEBUG("Temporary download path %s", cp_filename);
gint save_errno;
gint retval;
if (cp_filename == NULL)
{
errno = EINVAL;
return -1;
}
if (cp_filename == NULL)
{
errno = EINVAL;
return -1;
}
retval = g_unlink(cp_filename);
save_errno = errno;
retval = g_unlink (cp_filename);
save_errno = errno;
g_free(cp_filename);
g_free (cp_filename);
errno = save_errno;
return retval;
}
errno = save_errno;
return retval;
}
}
static gint fs_truncate(FILE* file, gint64 size)
......
......@@ -21,7 +21,7 @@ void initialize_db(GError **error)
"Newport", SEATON_PREFERENCE_SERVICE_DB);
if (!inResult)
{
g_debug("Data Base Created...");
NEWPORT_DEBUG("Data Base Created...");
}
else if (inResult)
{
......@@ -54,7 +54,7 @@ pfieldparam[7].pKeyName = "fileName";
if (!inResult)
{
g_debug("Table creation Successful");
NEWPORT_DEBUG("Table creation Successful");
}
else if (inResult)
{
......@@ -71,11 +71,11 @@ void retrieve_contents_from_db(void)
gpArray = seaton_preference_get(pDnlMgrObj.pSqliteObj, NULL, NULL, NULL);
if (gpArray == NULL)
{
g_debug("table doesnot exists");
NEWPORT_DEBUG("table doesnot exists");
}
else
{
g_debug("Resulting query is successful The result follows");
NEWPORT_DEBUG("Resulting query is successful The result follows");
}
gint inNumRows;
......@@ -97,7 +97,7 @@ void retrieve_contents_from_db(void)
sscanf((gchar*)g_hash_table_lookup(hashChk,"DownloadedSize") , "%"G_GUINT64_FORMAT , &pUrlInfo->progress.u64CurrentSize );
pUrlInfo->pDownloadFileName = g_strdup(
g_hash_table_lookup(hashChk, "fileName"));
g_debug("url is %s state is %d object path is %s", pUrlInfo->pUrl,
NEWPORT_DEBUG("url is %s state is %d object path is %s", pUrlInfo->pUrl,
pUrlInfo->u32CurrentDownloadState, pUrlInfo->object_path);
pUrlInfo->pTempDownloadPath = newport_build_temporary_download_path(pUrlInfo->pDownloadFileName);
......@@ -150,7 +150,7 @@ static gint lookup_download_id(const gchar* pUrl, const gchar *appname)
void store_all_download_info_in_db(void)
{
g_debug("Storing the download information into database");
NEWPORT_DEBUG("Storing the download information into database");
GList *iter;
for (iter = pDnlMgrObj.pClientDownloadList; iter!=NULL;
iter = g_list_next (iter))
......@@ -169,14 +169,11 @@ void store_url_data_in_db(DownloadUrlInfo *pUrlInfo)
{
int existng_db_info = lookup_download_id(pUrlInfo->pUrl,
pUrlInfo->pAppName);
// g_debug("store_url_data_in_db");
// NEWPORT_DEBUG("store_url_data_in_db ");
if (existng_db_info)
{
g_debug(
" store_url_data_in_db exisitng_db_info state is %d url is %s ID is %d",
pUrlInfo->u32CurrentDownloadState, pUrlInfo->pUrl,
exisitng_db_info);
gchar *u32CurrentDownloadState = g_strdup_printf("%d",
pUrlInfo->u32CurrentDownloadState);
gchar *u64ElapsedTime=g_strdup_printf("%"G_GUINT64_FORMAT,pUrlInfo->progress.u64ElapsedTime);
......@@ -199,7 +196,7 @@ void store_url_data_in_db(DownloadUrlInfo *pUrlInfo)
}
else
{
g_debug(" store_url_data_in_db NO DATA state is %d url %s",
NEWPORT_DEBUG(" store_url_data_in_db NO DATA state is %d url %s",
pUrlInfo->u32CurrentDownloadState, pUrlInfo->pUrl);
int inResult;
gchar *currentstate = g_strdup_printf("%d",
......@@ -230,11 +227,11 @@ void store_url_data_in_db(DownloadUrlInfo *pUrlInfo)
if (!inResult)
{
g_debug("Data Added ..");
NEWPORT_DEBUG("Data Added ..");
}
else if (inResult)
{
g_debug("Data Adding Failed ...");
NEWPORT_CRITICAL("Data Adding Failed ...");
}
g_free (currentstate);
......@@ -276,7 +273,7 @@ gchar **dnl_mgr_get_download_object_paths_from_db(gchar *app_name)
hashChk = g_ptr_array_index(gpArray, inNumRows);
obj_paths[inNumRows] = g_strdup(
g_hash_table_lookup(hashChk, "objectpath"));
g_debug("object path is %s", obj_paths[inNumRows]);
NEWPORT_DEBUG("object path is %s", obj_paths[inNumRows]);
}
obj_paths[inNumRows] = NULL;
return obj_paths;
......
......@@ -23,6 +23,10 @@ newport_download_error_quark(void);
#define NEWPORT_DOWNLOAD_ERROR_QUARK newport_download_error_quark()
#define NEWPORT_DEBUG(format, ...) g_debug ("%s: " format, G_STRFUNC, ##__VA_ARGS__)
#define NEWPORT_CRITICAL(format, ...) g_critical ("%s: " format, G_STRFUNC, ##__VA_ARGS__)
#define NEWPORT_WARNING(format, ...) g_warning ("%s: " format, G_STRFUNC, ##__VA_ARGS__)
typedef struct _DownloadMgr DownloadMgr;
typedef struct _DownloadUrlInfo DownloadUrlInfo;
typedef struct _DownloadProgressData ProgressData;
......
......@@ -32,21 +32,21 @@ on_bus_acquired (GDBusConnection *pConnection, const gchar *pName,
gpointer pUserData)
{
g_debug("on_bus_acquired %s", pName);
dnl_mgr_initialize_all_resources(pConnection);
pDnlMgrObj.pDnlMgrDbusObj = newport_service_skeleton_new();
g_signal_connect(pDnlMgrObj.pDnlMgrDbusObj, "handle-start-download",
G_CALLBACK(handle_start_download), pUserData);
g_signal_connect(pDnlMgrObj.pDnlMgrDbusObj, "handle-get-downloads",
G_CALLBACK(handle_get_downloads), pUserData);
g_signal_connect(pDnlMgrObj.pDnlMgrDbusObj, "handle-get-download-for-url",
G_CALLBACK(handle_get_download_for_url), pUserData);
NEWPORT_DEBUG("%s Bus acquired ", pName);
dnl_mgr_initialize_all_resources (pConnection);
pDnlMgrObj.pDnlMgrDbusObj = newport_service_skeleton_new ();
g_signal_connect (pDnlMgrObj.pDnlMgrDbusObj, "handle-start-download",
G_CALLBACK (handle_start_download), pUserData);
g_signal_connect (pDnlMgrObj.pDnlMgrDbusObj, "handle-get-downloads",
G_CALLBACK (handle_get_downloads), pUserData);
g_signal_connect (pDnlMgrObj.pDnlMgrDbusObj, "handle-get-download-for-url",
G_CALLBACK (handle_get_download_for_url), pUserData);
if (!g_dbus_interface_skeleton_export(
G_DBUS_INTERFACE_SKELETON(pDnlMgrObj.pDnlMgrDbusObj), pConnection,
"/org/secure_automotive_cloud/Newport/Service", NULL))
{
g_debug("export pError");
NEWPORT_CRITICAL("Interface skeleton export error");
}
}
......@@ -55,18 +55,19 @@ static void
on_name_acquired (GDBusConnection *pConnection, const gchar *pName,
gpointer pUserData)
{
g_debug("dnl mgr service Name acquired");
NEWPORT_DEBUG("%s Name acquired",pName);
}
static void
on_name_lost (GDBusConnection *pConnection, const gchar *pName,
gpointer pUserData)
{
g_debug("pName lost");
NEWPORT_CRITICAL (" %s name lost", pName);
}
gint main(gint argc, gchar *argv[])
{
GMainLoop *pMainLoop = NULL;
guint owner_id;
......@@ -80,7 +81,6 @@ gint main(gint argc, gchar *argv[])
NULL, // user data
NULL); // user data free func
g_debug("Download Manager has been initialised");
pMainLoop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(pMainLoop);
......@@ -138,27 +138,27 @@ _newport_connman_property_changed_clb (GDBusConnection *connection,
const gchar *signal_name,
GVariant *parameters, gpointer user_data)
{
g_debug (G_STRLOC"_newport_connman_property_changed_clb");
const gchar *name = NULL;
GVariant *params = NULL;
g_variant_get (parameters, "(&sv)", &name, &params);
if ((g_strcmp0 (name, "State") == 0))
{
if ((g_strcmp0 (g_variant_get_string (params, NULL), "ready") == 0)
|| (g_strcmp0 (g_variant_get_string (params, NULL), "online") == 0))
{
newport_check_for_preferred_network ();
}
else
halt_all_url_dnl ();
}
else if ((g_strcmp0 (name, "Type") == 0))
{
newport_check_for_preferred_network ();
}
if (params)
g_variant_unref (params);
NEWPORT_DEBUG ("newport_connman_property_changed_clb");
const gchar *name = NULL;
GVariant *params = NULL;
g_variant_get (parameters, "(&sv)", &name, &params);
if ((g_strcmp0 (name, "State") == 0))
{
if ((g_strcmp0 (g_variant_get_string (params, NULL), "ready") == 0)
|| (g_strcmp0 (g_variant_get_string (params, NULL), "online") == 0))
{
newport_check_for_preferred_network ();
}
else
halt_all_url_dnl ();
}
else if ((g_strcmp0 (name, "Type") == 0))
{
newport_check_for_preferred_network ();
}
if (params)
g_variant_unref (params);
}
......@@ -210,7 +210,7 @@ pDnlMgrObj.uinProgressCount = g_settings_get_uint (
}
else
{
g_critical("%s",error->message);
NEWPORT_CRITICAL("%s",error->message);
g_error_free(error);
exit(1);
}
......@@ -221,20 +221,21 @@ pDnlMgrObj.system_dbus_connection, NULL, "net.connman.Manager", "PropertyChanged
(GDBusSignalCallback) _newport_connman_property_changed_clb, NULL, NULL);
newport_check_for_preferred_network ();
// create your own exit callback to take care of clearing and storing of resources
dnl_mgr_register_exit_functionalities();
}
static gboolean dnl_mgr_termination_handler(gpointer data)
{
g_debug("dnl_mgr_termination_handler");
store_all_download_info_in_db();
seaton_preference_close(pDnlMgrObj.pSqliteObj);
if (NULL != pDnlMgrObj.pSqliteObj)
{
g_object_unref(pDnlMgrObj.pSqliteObj);
pDnlMgrObj.pSqliteObj = NULL;
}
NEWPORT_DEBUG("Termination Handler");
store_all_download_info_in_db ();
seaton_preference_close (pDnlMgrObj.pSqliteObj);
if (NULL != pDnlMgrObj.pSqliteObj)
{
g_object_unref (pDnlMgrObj.pSqliteObj);
pDnlMgrObj.pSqliteObj = NULL;
}
g_list_free_full(pDnlMgrObj.pClientDownloadList,
(GDestroyNotify) download_url_info_free);
......
......@@ -194,7 +194,7 @@ _newport_handler_get_apparmor_context_for_sender (MethodRequest *request_data,
{
const gchar *sender = g_dbus_method_invocation_get_sender (
request_data->invocation);
g_debug("sender is %s", sender);
NEWPORT_DEBUG("sender is %s", sender);
g_dbus_connection_call (
g_dbus_method_invocation_get_connection (request_data->invocation),
"org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus",
......@@ -400,7 +400,7 @@ newport_security_context_to_start_download_clb (GObject *source_object,
g_free (pUrlInfo->pDownloadFileName);
pUrlInfo->pDownloadFileName = g_path_get_basename (
request_data->download_path);
g_debug("Download file name : %s", pUrlInfo->pDownloadFileName);
NEWPORT_DEBUG("Download file name : %s", pUrlInfo->pDownloadFileName);
g_free (pUrlInfo->pDownloadPath);
pUrlInfo->pDownloadPath = g_strdup (request_data->download_path);
newport_download_set_path (download, pUrlInfo->pDownloadPath);
......@@ -429,7 +429,7 @@ newport_security_context_to_start_download_clb (GObject *source_object,
initialize_url_info (pUrlInfo);
pUrlInfo->pDownloadFileName = g_path_get_basename (
request_data->download_path);
g_debug("Download file name %s", pUrlInfo->pDownloadFileName);
NEWPORT_DEBUG("Download file name %s", pUrlInfo->pDownloadFileName);
pUrlInfo->pAppName = g_strdup (apparmor_label);
pUrlInfo->pDownloadPath = g_strdup (request_data->download_path);
pUrlInfo->pUrl = g_strdup (request_data->url);
......@@ -574,7 +574,7 @@ newport_security_context_to_pause_download_clb (GObject *source_object,
if (pUrlInfo)
{
/* looks like application sent a request to pause download of a pUrl */
g_debug(
NEWPORT_DEBUG(
"Sending current download status to the client. Requested pUrl:%s Download state:%d currentsize:%"G_GINT64_FORMAT,
pUrlInfo->pUrl, pUrlInfo->u32CurrentDownloadState,
pUrlInfo->progress.u64CurrentSize);
......@@ -635,7 +635,7 @@ newport_security_context_to_resume_download_clb (GObject *source_object,
if (pUrlInfo)
{
/* looks like application sent a request to resume download of a pUrl */
g_debug("handle_resume_download %s %d", request_data->url,
NEWPORT_DEBUG("handle_resume_download %s %d", request_data->url,
pUrlInfo->u32CurrentDownloadState);
if (!pDnlMgrObj.is_preferred_network)
{
......@@ -673,7 +673,6 @@ gboolean handle_resume_download(NewportDownload *object,
GDBusMethodInvocation *invocation, gpointer user_data)
{
g_debug("handle_resume_download");
/* Get the App security label of the sender*/
MethodRequest *request_data = g_new0 (MethodRequest, 1);
......@@ -739,6 +738,5 @@ gboolean handle_get_downloads(NewportService *object,
(GAsyncReadyCallback) newport_security_context_to_get_downloads_clb);
return TRUE;
}
......@@ -23,7 +23,7 @@ static void _newport_download_finished(GObject *source_object,
newport_download_set_total_size(download,pUrlInfo->progress.u64TotalSize);
newport_download_set_downloaded_size(download,pUrlInfo->progress.u64CurrentSize);
newport_download_set_state(download, pUrlInfo->u32CurrentDownloadState);
g_debug("_newport_download_finished %d", pUrlInfo->u32CurrentDownloadState);
NEWPORT_DEBUG("_newport_download_finished %d", pUrlInfo->u32CurrentDownloadState);
store_url_data_in_db(pUrlInfo);
gboolean is_download_success = g_task_propagate_boolean(G_TASK(result),
&error);
......@@ -39,7 +39,7 @@ static void _newport_download_finished(GObject *source_object,
unlink_file(pUrlInfo->pTempDownloadPath);
newport_download_set_error(download,
NEWPORT_DOWNLOAD_MANAGER_UNKNOWN_ERROR);
g_warning("%s", err->message);
NEWPORT_WARNING("%s", err->message);
g_error_free(err);
return;
}
......@@ -49,7 +49,7 @@ static void _newport_download_finished(GObject *source_object,
{
if (error)
{
g_debug("ERROR is %s", error->message);
NEWPORT_WARNING("ERROR is %s", error->message);
g_error_free(error);
return;
}
......@@ -120,7 +120,7 @@ void initialize_url_info(DownloadUrlInfo *pUrlInfo)
void resume_url_download(NewportDownload *Download, DownloadUrlInfo *pUrlInfo)
{
g_debug("resume_url_download ");
NEWPORT_DEBUG("resume_url_download ");
if (pDnlMgrObj.uinDownloadCount >= g_settings_get_uint (
pDnlMgrObj.schema, "max-parallel-download"))
{
......@@ -140,12 +140,13 @@ void resume_url_download(NewportDownload *Download, DownloadUrlInfo *pUrlInfo)
DownloadUrlInfo* check_for_valid_url(const gchar *pUrl, const gchar *pAppName)
{
DownloadUrlInfo *pUrlInfo = look_for_url_in_db(pUrl, pAppName);
if (pUrlInfo == NULL)
{
g_debug("pUrlInfo is null");
}
return pUrlInfo;
DownloadUrlInfo *pUrlInfo = look_for_url_in_db (pUrl, pAppName);
if (pUrlInfo == NULL)
{
NEWPORT_DEBUG ("pUrlInfo is null");
}
return pUrlInfo;
}
DownloadUrlInfo* look_for_url_in_db(const gchar* pUrl, const gchar* pAppName)
......@@ -156,19 +157,19 @@ DownloadUrlInfo* look_for_url_in_db(const gchar* pUrl, const gchar* pAppName)
{
DownloadUrlInfo *pUrlInfo = iter->data;
if ((!g_strcmp0(pUrlInfo->pAppName, pAppName))
&& (!g_strcmp0(pUrlInfo->pUrl, pUrl)))
{
g_debug("%s :: A valid pUrl found in db ", __FUNCTION__);
return pUrlInfo;
}
}
return NULL;
if ((!g_strcmp0 (pUrlInfo->pAppName, pAppName))
&& (!g_strcmp0 (pUrlInfo->pUrl, pUrl)))
{
NEWPORT_DEBUG(" Valid URL found in db");
return pUrlInfo;
}
}
return NULL;
}
void download_pending_urls(void)
{
g_debug(" Downloading Pending URL");
NEWPORT_DEBUG(" Downloading Pending URL");
GList *iter;
for (iter = pDnlMgrObj.pClientDownloadList; iter!=NULL;
......@@ -181,6 +182,7 @@ void download_pending_urls(void)
{
GDBusObject *dbus_object =
newport_download_url_info_ensure_dbus_object (pUrlInfo);
NewportDownload *Download =
(NewportDownload *) g_dbus_object_get_interface (
dbus_object, "org.secure_automotive_cloud.Newport.Download");
......@@ -192,7 +194,7 @@ void download_pending_urls(void)
static void download_queued_urls(void)
{
g_debug("Download queued URLs");
NEWPORT_DEBUG("Download queued URLs");
GList *iter;
for (iter = pDnlMgrObj.pClientDownloadList; iter != NULL;
......@@ -221,7 +223,7 @@ void halt_all_url_dnl(void)
iter = g_list_next (iter))
{
DownloadUrlInfo *pUrlInfo = iter->data;
g_debug("Halt the downloading URL %s", pUrlInfo->pUrl);
NEWPORT_DEBUG("Halt the downloading URL %s", pUrlInfo->pUrl);
if (pUrlInfo->u32CurrentDownloadState == NEWPORT_DOWNLOAD_IN_PROGRESS)
{
pUrlInfo->u32CurrentDownloadState = NEWPORT_DOWNLOAD_PAUSED_BY_SYSTEM;
......
......@@ -11,7 +11,8 @@ bin_PROGRAMS = newport-client
# Preprocessor flags
newport_client_CPPFLAGS = $(includes) \
$(AM_CPPFLAGS)
-DG_LOG_DOMAIN=\"Newport-Client\" \
$(AM_CPPFLAGS)
newport_client_LDADD = $(GCC_FLAGS) $(GLIB_LIBS) $(CODE_COVERAGE_LIBS) $(AM_LIBADD) \
../interface/libnewportiface.la
......
......@@ -16,6 +16,10 @@
#define ASYNC 0
#define NEWPORT_CLIENT_DEBUG(format, ...) g_debug ("%s: " format, G_STRFUNC, ##__VA_ARGS__)
#define NEWPORT_CLIENT_WARNING(format, ...) g_warning ("%s: " format, G_STRFUNC, ##__VA_ARGS__)
static NewportService *proxy = NULL;
gpointer service_proxy_new(gpointer data);
......@@ -125,11 +129,11 @@ static void dnl_proxy_clb( GObject *source_object,
if(proxy == NULL)
{
g_print(">>> Test 'Proxy created'.... FAIL\n");
NEWPORT_CLIENT_WARNING(">>> Test 'Proxy created'.... FAIL");
exit(0);
}
else
g_print(">>> Test 'Proxy_Creation'.... PASS\n");
NEWPORT_CLIENT_DEBUG(">>> Test 'Proxy_Creation'.... PASS");
start_download (source_object,user_data);
//connect signals to to get download-information and download success
......@@ -192,7 +196,7 @@ gboolean dnl_info_clb(NewportService *object,
{
if (Pause_count == 0 && check_cancel == 0)
{
g_print(">>> Test 'Download_Progress'.... PASS\n");
NEWPORT_CLIENT_DEBUG(">>> Test 'Download_Progress'.... PASS");
Pause_count=1;
newport_service_call_pause_download (proxy,
(const gchar*)dwl_info->arg_app_name,
......@@ -225,8 +229,8 @@ gboolean dnl_success_clb(NewportService *object,
{
if(check_cancel ==0)
{
g_print(">>> Test 'Download_Sucessful'.... PASS\n");
g_print(">>> Test 'Downloaded_file_size'.... PASS [%"G_GINT64_FORMAT" KB]\n>>> Test 'Download_Time'.... PASS [%"G_GINT64_FORMAT" Secs]\n>>> Test 'Downloaded_file_path'.... PASS [%s]\n",arg_downloaded_file_size/(1000),arg_elapsed_time,arg_url_download_path);
NEWPORT_CLIENT_DEBUG(">>> Test 'Download_Sucessful'.... PASS");
NEWPORT_CLIENT_DEBUG(">>> Test 'Downloaded_file_size'.... PASS [%"G_GINT64_FORMAT" KB]>>> Test 'Download_Time'.... PASS [%"G_GINT64_FORMAT" Secs]>>> Test 'Downloaded_file_path'.... PASS [%s]",arg_downloaded_file_size/(1000),arg_elapsed_time,arg_url_download_path);
}
check_cancel=1;
gpointer user_data = NULL;
......@@ -242,7 +246,7 @@ static void start_download_clb( GObject *source_object,
{
if( check_cancel == 0)
{
g_print(">>> Test 'Download_Started'.... PASS\n");
NEWPORT_CLIENT_DEBUG(">>> Test 'Download_Started'.... PASS");
Pause_count=0;
}
}
......@@ -252,7 +256,7 @@ static void pause_dnl_clb( GObject *source_object,
gpointer user_data)
{
GError *error=NULL;
g_print(">>> Test 'Pause_Downloads'.... PASS\n");
NEWPORT_CLIENT_DEBUG(">>> Test 'Pause_Downloads'.... PASS");
newport_service_call_pause_download_finish ( proxy,
res,
......@@ -281,7 +285,7 @@ static void cancel_dnl_clb( GObject *source_object,
newport_service_call_cancel_download_finish (proxy,
res,
&error);
g_print(">>> Test 'Cancel_Download'.... PASS\n");
NEWPORT_CLIENT_DEBUG(">>> Test 'Cancel_Download'.... PASS");
exit(0);
}
......@@ -296,7 +300,7 @@ static void resume_dnl_clb( GObject *source_object,
res,
&error);
g_print(">>> Test 'Resume_Download'.... PASS\n");
NEWPORT_CLIENT_DEBUG(">>> Test 'Resume_Download'.... PASS");
}
gboolean dnl_error_clb (NewportService *object,
......@@ -305,7 +309,7 @@ static void resume_dnl_clb( GObject *source_object,
const gchar *arg_error_info)
{
g_print(">>> Test 'Download_URL'.... FAIL\n");
NEWPORT_CLIENT_DEBUG(">>> Test 'Download_URL'.... FAIL");
exit(0);
}
static void name_vanished(GDBusConnection *connection,
......@@ -314,7 +318,7 @@ static void name_vanished(GDBusConnection *connection,
{
if(NULL != proxy)
g_object_unref(proxy);
g_print(">>> Test 'Download Manager name vanished'.... FAIL\n");
NEWPORT_CLIENT_DEBUG(">>> Test 'Download Manager name vanished'.... FAIL");
exit(0);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment