Add renew method for fault recovering.
authorSung-jae Park <nicesj.park@samsung.com>
Tue, 22 May 2012 03:20:31 +0000 (12:20 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Tue, 22 May 2012 03:20:31 +0000 (12:20 +0900)
Master will send "renew" event to re-create normal livebox instances.

Change-Id: I76adf33ec1c8ae317454abc0f9e5aa772ce45de8

src/dbus.c

index 25b4609..537566e 100644 (file)
@@ -73,6 +73,20 @@ static struct info {
        "  <arg type='i' name='h' direction='in' />"
        "  <arg type='i' name='result' direction='out' />"
        " </method>"
+       " <method name='renew'>"
+       "  <arg type='s' name='pkgname' direction='in' />"
+       "  <arg type='s' name='filename' direction='in' />"
+       "  <arg type='s' name='content' direction='in' />"
+       "  <arg type='i' name='timeout' direction='in' />"
+       "  <arg type='i' name='has_script' direction='in' />"
+       "  <arg type='d' name='period' direction='in' />"
+       "  <arg type='s' name='cluster' direction='in' />"
+       "  <arg type='s' name='category' direction='in' />"
+       "  <arg type='i' name='pinup' direction='in' />"
+       "  <arg type='i' name='width' direction='in' />"
+       "  <arg type='i' name='height' direction='in' />"
+       "  <arg type='i' name='ret' direction='out' />"
+       " </method>"
        " <method name='new'>"
        "  <arg type='s' name='pkgname' direction='in' />"
        "  <arg type='s' name='filename' direction='in' />"
@@ -292,6 +306,45 @@ static void method_resume(GDBusMethodInvocation *inv, GVariant *param)
        livebox_resume_all();
 }
 
+static void method_renew(GDBusMethodInvocation *inv, GVariant *param)
+{
+       const char *pkgname;
+       const char *filename;
+       const char *content;
+       const char *cluster;
+       const char *category;
+       int timeout;
+       int has_livebox_script;
+       double period;
+       int ret;
+       int w;
+       int h;
+       int lw;
+       int lh;
+       double priority;
+       int pinup;
+
+       g_variant_get(param, "(&s&s&siid&s&siii)", &pkgname, &filename,
+                               &content, &timeout, &has_livebox_script,
+                               &period, &cluster, &category, &pinup, &w, &h);
+
+       ret = livebox_create(pkgname, filename, content, timeout, has_livebox_script, period, cluster, category, &lw, &lh, &priority, pinup, 1);
+       if (ret == 0) {
+               if (lw != w || lh != h) {
+                       int tmp;
+                       tmp = livebox_resize(pkgname, filename, w, h);
+                       /* Ignore return value */
+                       DbgPrint("Resize returns %d\n", tmp);
+               }
+       }
+
+       param = g_variant_new("(i)", ret);
+       if (!param)
+               ErrPrint("Failed to create param\n");
+
+       g_dbus_method_invocation_return_value(inv, param);
+}
+
 static void method_new(GDBusMethodInvocation *inv, GVariant *param)
 {
        const char *pkgname;
@@ -356,6 +409,10 @@ static void method_handler(GDBusConnection *conn,
                        .method = method_resize,
                },
                {
+                       .name = "renew",
+                       .method = method_renew,
+               },
+               {
                        .name = "new",
                        .method = method_new,
                },