Added tcore_server_unload_modem_plugin() function.
authorSuresh Kumar Narasimhaiah <suresh.n@samsung.com>
Wed, 20 Mar 2013 18:04:11 +0000 (23:34 +0530)
committerwootak.jung <wootak.jung@samsung.com>
Sun, 24 Mar 2013 09:03:16 +0000 (18:03 +0900)
include/server.h
src/server.c

index ae36280faafedb55568fa5edaac21715a5302705..b01a4464164f4bcfed63543cc47aba4515d66713 100644 (file)
@@ -88,6 +88,8 @@ void tcore_server_print_modems(TcorePlugin *plugin);
 TReturn tcore_server_load_modem_plugin(Server *s,
                                        TcorePlugin *modem_if_plugin,
                                        const char *name);
+void tcore_server_unload_modem_plugin(Server *s, TcorePlugin *modem_if_plugin);
+
 
 __END_DECLS
 
index a9b7abbcc79efa1bf7bf654a9895be0252616249..425d772ab65bc814a361618e2990509f24fffc6c 100644 (file)
@@ -1000,3 +1000,57 @@ out:
 
        return ret;
 }
+
+void tcore_server_unload_modem_plugin(Server *s, TcorePlugin *modem_if_plugin)
+{
+       TcoreModem *modem;
+       TcorePlugin *modem_plugin;
+       const struct tcore_plugin_define_desc *desc;
+
+       dbg("Enter");
+
+       if ((s == NULL) || (modem_if_plugin == NULL)) {
+               err("Invalid inputs");
+               return;
+       }
+
+       /* Find modem from Server's Modem's list */
+       modem = _server_find_modem(s, modem_if_plugin, modem_if_plugin);
+       if (modem == NULL) {
+               err("Failed to find 'modem' for Plug-in: [%s]",
+                                       tcore_plugin_ref_plugin_name(modem_if_plugin));
+               return;
+       }
+
+       msg("Modem Plug-in: [%s] Modem Interface Plug-in: [%s]",
+                       tcore_plugin_ref_plugin_name(modem->modem_plugin),
+                       tcore_plugin_ref_plugin_name(modem->modem_iface_plugin));
+       msg("CP Name: [%s]", modem->cp_name);
+
+       /* Extract Modem Plug-in */
+       modem_plugin = modem->modem_plugin;
+       if (modem_plugin == NULL) {
+               err("Modem Plug-in is NULL");
+               return;
+       }
+
+       /* Notify deletion of Plug-in to Upper Layers */
+       tcore_server_send_notification(s, NULL, TNOTI_SERVER_REMOVED_PLUGIN,
+                                                       0, modem_plugin);
+
+       /* Extract descriptor of Modem Plug-in */
+       desc = tcore_plugin_get_description(modem_plugin);
+       if (desc != NULL) {
+               /* Unload Modem Plug-in */
+               if (desc->unload != NULL) {
+                       dbg("Unloading Modem Plug-in: [%s]",
+                                               tcore_plugin_ref_plugin_name(modem_plugin));
+                       desc->unload(modem_plugin);
+               }
+       }
+
+       /* Free Modem Plug-in */
+       tcore_plugin_free(modem_plugin);
+
+       dbg("Unloaded Modem Plug-in");
+}