From: Luc Yriarte Date: Tue, 1 Oct 2013 17:09:00 +0000 (+0200) Subject: support FoundServer / LostServer UPnPManager DBus signals X-Git-Tag: submit/tizen/20131016.221725~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F87%2F10987%2F1;p=profile%2Fivi%2Fwrt-plugins-ivi.git support FoundServer / LostServer UPnPManager DBus signals Signed-off-by: lyriarte Change-Id: Ifaf192bbbb5062adba31c11832c5ac8c8c8e2af4 --- diff --git a/src/MediaServer/MediaServer.cpp b/src/MediaServer/MediaServer.cpp index 9303273..0dfbce8 100644 --- a/src/MediaServer/MediaServer.cpp +++ b/src/MediaServer/MediaServer.cpp @@ -66,7 +66,7 @@ static void findCallback(GObject *source_object, GAsyncResult *res, gpointer us )) { LoggerD("findCallback success"); } else { - LoggerD(gerror->message); + LoggerE(gerror->message); g_error_free(gerror); return; } @@ -95,7 +95,7 @@ static void browseCallback(GObject *source_object, GAsyncResult *res, gpointer )) { LoggerD("browseCallback success"); } else { - LoggerD(gerror->message); + LoggerE(gerror->message); g_error_free(gerror); return; } @@ -164,7 +164,7 @@ void MediaServer::setProxyPath(std::string path) &gerror); if (gerror) { - LoggerD(gerror->message); + LoggerE(gerror->message); g_error_free(gerror); return; } @@ -219,7 +219,7 @@ void MediaServer::browse(std::string containerId, &gerror); if (gerror) { - LoggerD(gerror->message); + LoggerE(gerror->message); g_error_free(gerror); return; } @@ -259,7 +259,7 @@ void MediaServer::find(std::string containerId, &gerror); if (gerror) { - LoggerD(gerror->message); + LoggerE(gerror->message); g_error_free(gerror); return; } diff --git a/src/MediaServer/MediaServerManager.cpp b/src/MediaServer/MediaServerManager.cpp index 35ea830..cf9d99a 100644 --- a/src/MediaServer/MediaServerManager.cpp +++ b/src/MediaServer/MediaServerManager.cpp @@ -17,6 +17,30 @@ using namespace WrtDeviceApis::Commons; /* + * 'FoundServer' UPnPManager proxy signal callback + */ +static void FoundServerCallback( + UPnPManager *object, + const gchar *arg_Path, + gpointer user_data) +{ + LoggerD("found server: " << arg_Path); +} + + +/* + * 'LostServer' UPnPManager proxy signal callback + */ +static void LostServerCallback( + UPnPManager *object, + const gchar *arg_Path, + gpointer user_data) +{ + LoggerD("lost server: " << arg_Path); +} + + +/* * Callback for get servers on UPnPManager proxy */ static void getServersCallback(GObject *source_object, GAsyncResult *res, gpointer user_data) { @@ -35,7 +59,7 @@ static void getServersCallback(GObject *source_object, GAsyncResult *res, gpoin )) { LoggerD("getServersCallback success"); } else { - LoggerD(gerror->message); + LoggerE(gerror->message); g_error_free(gerror); return; } @@ -68,7 +92,33 @@ MediaServerManager::MediaServerManager() :EventRequestReceiver(ThreadEnum::APPLICATION_THREAD) { LoggerD("Entered MediaServerManager::MediaServerManager"); - proxy = NULL; + GError* gerror = NULL; + proxy = upn_pmanager__proxy_new_for_bus_sync(G_BUS_TYPE_SESSION, + G_DBUS_PROXY_FLAGS_NONE, + "com.intel.dleyna-server", + "/com/intel/dLeynaServer", + NULL, /* GCancellable */ + &gerror); + + if (gerror) { + LoggerE(gerror->message); + g_error_free(gerror); + return; + } + + /* Register for manager signals 'FoundServer(String)' */ + LoggerD("Register UPnPManager 'FoundServer' signal"); + g_signal_connect(proxy, + "FoundServer", + G_CALLBACK (FoundServerCallback), + NULL); + + /* Register for manager signals 'LostServer(String)' */ + LoggerD("Register UPnPManager 'LostServer' signal"); + g_signal_connect(proxy, + "LostServer", + G_CALLBACK (LostServerCallback), + NULL); } @@ -84,18 +134,8 @@ void MediaServerManager::scanNetwork(ScanNetworkCB *callback) { LoggerD("Entered MediaServerManager::scanNetwork"); - GError* gerror = NULL; - if (!proxy) - proxy = upn_pmanager__proxy_new_for_bus_sync(G_BUS_TYPE_SESSION, - G_DBUS_PROXY_FLAGS_NONE, - "com.intel.dleyna-server", - "/com/intel/dLeynaServer", - NULL, /* GCancellable */ - &gerror); - - if (gerror) { - LoggerD(gerror->message); - g_error_free(gerror); + if (!proxy) { + LoggerE("No UPnPManager proxy, aborting"); return; }