Scheme_Object * rdbus_call_method (int i, Scheme_Object *proc, Scheme_Object *list ) { //This is the final return value that will be saved in memory after calling Gimp Server GVariant *frvalue; // Intermediary return value for helper method return for scheme to gvariant GVariant *ivalue; // returning the string of the method name const char *methodname; //saving the error in memory GError *error; //final Scheme_Object Scheme_Object *fobject; //Our GDBusProxy Object GDBusProxy *proxy; if (i == 0) { proxy = Proxyobj; ivalue = scheme_obj_to_gvariant (list); // the method is converted into string here methodname = tostring (proc); fprintf (stderr, "Calling %s\n", methodname); frvalue = g_dbus_proxy_call_sync (proxy, methodname, ivalue, 0, -1, NULL, &error); fobject = gvariant_to_schemeobj (frvalue); return fobject; } // if (i == 0) else // if (i != 0) { return scheme_make_utf8_string("There is sth wrong with the Proxy Object"); } // if (i != 0) } // rdbus_call_method
Scheme_Object * rdbus_call_method (int i, Scheme_Object *proc, Scheme_Object *list ) { //This is the final return value that will be saved in memory after calling Gimp Server GVariant *frvalue; // Intermediary return value for helper method return for scheme to gvariant GVariant *ivalue; // returning the string of the method name const char *methodname; //saving the error in memory GError *error; //final Scheme_Object Scheme_Object *fobject; //Our GDBusProxy Object GDBusProxy *proxy; //Scheme_Object actual list // Scheme_Object *alist; if (i == 0) { proxy = Proxyobj; fprintf (stderr, "Before crashing\n"); ivalue = scheme_obj_to_gvariant (list); // the method is converted into string here methodname = tostring (proc); // scheme_signal_error("callerror"); fprintf (stderr, "after method name\n"); // scheme_signal_error ("methodnamepassed"); error = NULL; frvalue = g_dbus_proxy_call_sync (proxy, methodname, ivalue, 0, -1, NULL, &error); fprintf (stderr, "after calling gdbus\n"); if (frvalue == NULL) { fprintf (stderr, "Call to %s failed ", methodname); if (error != NULL) fprintf (stderr, "because %s.\n", error->message); else fprintf (stderr, "for an unknown reason.\n"); return scheme_void; } // if (frvalue == NULL) // scheme_signal_error ("calling gimp"); //scheme_signal_error("newerror"); fobject = gvariant_to_schemeobj (frvalue); fprintf (stderr, "after calling gvariant_to_schemeobj\n"); //scheme_signal_error ("getting the scheme object back"); // scheme_signal_error("lasterror"); return fobject; } // if (i == 0) else // if (i != 0) { return scheme_make_utf8_string("There is sth wrong with the Proxy Object"); } // if (i != 0) } // rdbus_call_method
/** *For Server : Convert an array of Scheme objects into a list of the same objects for SchemeObject to Gvariant <<<<<<< HEAD * ======= *We have not used this recursive helper function. We did it iteratively below. >>>>>>> 3cb492700f6fe2265add3da53ebfb79622e240de */ Scheme_Object * g_variant_tuple_to_scheme_list (GVariant *tuple, int index, int size) { // Base case: We reached the end of the tuple if (index == size) return scheme_null; // Or whatever the empty list value is else { Scheme_Object *car; Scheme_Object *cdr; car = gvariant_to_schemeobj (g_variant_get_child_value (tuple, index)); cdr = g_variant_tuple_to_scheme_list (tuple, index+1, size); return scheme_make_pair (car, cdr); } // if we're still in the tuple } // g_variant_tuple_to_scheme_list
/** *Translating the gvariant to Scheme Object */ Scheme_Object * gvariant_to_schemeobj (GVariant *ivalue) { gint32 i; GVariant *temp; const gchar *fstring; gsize length = 0; gsize size = 0; gint32 r1 = 0; gdouble r2 = 0; Scheme_Object *fint; Scheme_Object *fstringss; Scheme_Object *fdouble; Scheme_Object *sflist = NULL; gchar *tmp; //scheme_signal_error ("Not tuple yet"); tmp = g_variant_print (ivalue, FALSE); fprintf (stderr, "gvariant_to_schemobj(%s)\n", tmp); g_free (tmp); size = g_variant_get_size (ivalue); // fprintf (stderr, "Exploring the return value.\n"); /* if (ivalue == NULL) { fprintf (stderr, "Return value is <NULL>\n"); } // if (ivalue == NULL) else // if (ivalue != NULL) { type = g_variant_get_type (ivalue); typestring = g_variant_type_dup_string (type); fprintf (stderr, "Got type %s\n", typestring); g_free (typestring); description = g_variant_print (ivalue, TRUE); fprintf (stderr, "Got value %s\n", description); g_free (description); } // if (ivalue != NULL)*/ if (ivalue == NULL) { return scheme_void; } if (g_variant_is_of_type (ivalue, G_VARIANT_TYPE_INT32)) { r1 = g_variant_get_int32 (ivalue); fint = scheme_make_integer_value(r1); return fint; }// else if else if (g_variant_is_of_type (ivalue, G_VARIANT_TYPE_STRING)) { fprintf ( stderr, "Type_string\n"); // scheme_signal_error ("%d", size); fstring = g_variant_get_string(ivalue, &size); fstringss = scheme_make_locale_string(fstring); return fstringss; }// else if else if (g_variant_is_of_type (ivalue, G_VARIANT_TYPE_BYTESTRING)) { fprintf (stderr, "Bytestring\n"); scheme_signal_error("stringbyeerror"); fstring = g_variant_get_bytestring (ivalue); fstringss = scheme_make_locale_string(fstring); return fstringss; }// else if else if (g_variant_is_of_type (ivalue, G_VARIANT_TYPE_DOUBLE)) { r2 = g_variant_get_double (ivalue); fdouble = scheme_make_double (r2); return fdouble; }// else if else if (g_variant_is_of_type (ivalue, G_VARIANT_TYPE_TUPLE)) { int i; Scheme_Object *result; // The list we're building Scheme_Object *element; // One element of that list fprintf (stderr, "Handling a tuple.\n"); result = scheme_null; for (i = g_variant_n_children (ivalue) - 1; i >= 0; i--) { fprintf (stderr, "Handling child %d\n", i); element = gvariant_to_schemeobj (g_variant_get_child_value (ivalue, i)); result = scheme_make_pair (element, result); } // for return result; } // if it's a tuple // Default. Give up else { scheme_signal_error ("could not convert type"); } // default } //gvariant_to_schemeobj