static void _get_updates (SwLastfmContactView *contact_view) { SwLastfmContactViewPrivate *priv = GET_PRIVATE (contact_view); SwService *service; RestProxyCall *call; const gchar *user_id; sw_call_list_cancel_all (priv->calls); sw_set_empty (priv->set); SW_DEBUG (LASTFM, "Making getFriends call"); call = rest_proxy_new_call (priv->proxy); sw_call_list_add (priv->calls, call); service = sw_contact_view_get_service (SW_CONTACT_VIEW (contact_view)); user_id = sw_service_lastfm_get_user_id (SW_SERVICE_LASTFM (service)); if (!user_id) { /* Not yet configured */ return; } rest_proxy_call_add_params (call, "api_key", sw_keystore_get_key ("lastfm"), "user", user_id, "method", "user.getFriends", NULL); rest_proxy_call_async (call, _get_friends_cb, (GObject *)contact_view, NULL, NULL); }
static void online_notify (gboolean online, gpointer user_data) { SwServicePlurk *plurk = (SwServicePlurk *)user_data; SwServicePlurkPrivate *priv = GET_PRIVATE (plurk); priv->credentials = OFFLINE; if (online) { if (priv->username && priv->password) { RestProxyCall *call; call = rest_proxy_new_call (priv->proxy); rest_proxy_call_set_function (call, "Users/login"); rest_proxy_call_add_params (call, "api_key", priv->api_key, "username", priv->username, "password", priv->password, NULL); rest_proxy_call_async (call, _got_login_data, (GObject*)plurk, NULL, NULL); } } else { g_free (priv->user_id); priv->user_id = NULL; sw_service_emit_capabilities_changed ((SwService *)plurk, get_dynamic_caps ((SwService *)plurk)); } }
static void _plurk_status_update_update_status (SwStatusUpdateIface *self, const gchar *msg, GHashTable *fields, DBusGMethodInvocation *context) { SwServicePlurk *plurk = SW_SERVICE_PLURK (self); SwServicePlurkPrivate *priv = GET_PRIVATE (plurk); RestProxyCall *call; if (!priv->user_id) return; call = rest_proxy_new_call (priv->proxy); rest_proxy_call_set_method (call, "POST"); rest_proxy_call_set_function (call, "Timeline/plurkAdd"); rest_proxy_call_add_params (call, "api_key", priv->api_key, "content", msg, "qualifier", ":", NULL); rest_proxy_call_async (call, _update_status_cb, (GObject *)self, NULL, NULL); sw_status_update_iface_return_from_update_status (context); }
static RestProxyCall* ease_flickr_service_real_create_call (EasePluginImportService* base, RestProxy* proxy, const char* search) { #line 184 "ease-import-flickr-service.c" EaseFlickrService * self; RestProxyCall* result = NULL; char* licenses; RestProxyCall* call; char* _tmp4_; self = (EaseFlickrService*) base; #line 40 "ease-import-flickr-service.vala" g_return_val_if_fail (proxy != NULL, NULL); #line 40 "ease-import-flickr-service.vala" g_return_val_if_fail (search != NULL, NULL); #line 195 "ease-import-flickr-service.c" licenses = NULL; #line 44 "ease-import-flickr-service.vala" if (gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->share_alike)) { #line 199 "ease-import-flickr-service.c" char* _tmp0_; #line 46 "ease-import-flickr-service.vala" licenses = (_tmp0_ = g_strdup (EASE_FLICKR_SERVICE_CC_BY_SA), _g_free0 (licenses), _tmp0_); #line 47 "ease-import-flickr-service.vala" if (!gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->for_commercial)) { #line 205 "ease-import-flickr-service.c" char* _tmp1_; #line 47 "ease-import-flickr-service.vala" licenses = (_tmp1_ = g_strconcat (licenses, EASE_FLICKR_SERVICE_CC_BY_NC_SA, NULL), _g_free0 (licenses), _tmp1_); #line 209 "ease-import-flickr-service.c" } } else { char* _tmp2_; #line 51 "ease-import-flickr-service.vala" licenses = (_tmp2_ = g_strdup (EASE_FLICKR_SERVICE_CC_BY), _g_free0 (licenses), _tmp2_); #line 52 "ease-import-flickr-service.vala" if (!gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->for_commercial)) { #line 217 "ease-import-flickr-service.c" char* _tmp3_; #line 52 "ease-import-flickr-service.vala" licenses = (_tmp3_ = g_strconcat (licenses, EASE_FLICKR_SERVICE_CC_BY_NC, NULL), _g_free0 (licenses), _tmp3_); #line 221 "ease-import-flickr-service.c" } } #line 55 "ease-import-flickr-service.vala" call = rest_proxy_new_call (proxy); #line 56 "ease-import-flickr-service.vala" rest_proxy_call_set_function (call, "flickr.photos.search"); #line 57 "ease-import-flickr-service.vala" rest_proxy_call_add_params (call, "tags", search, "tag_mode", "all", "per_page", "10", "format", "json", "sort", "relevance", "nojsoncallback", "1", "license", _tmp4_ = string_substring (licenses, (glong) 0, string_get_length (licenses) - 1), "extras", "description,license", NULL, NULL); #line 230 "ease-import-flickr-service.c" _g_free0 (_tmp4_); result = call; _g_free0 (licenses); #line 71 "ease-import-flickr-service.vala" return result; #line 236 "ease-import-flickr-service.c" }
static void verify_user (SwService *service) { SwServiceLastfm *lastfm = SW_SERVICE_LASTFM (service); SwServiceLastfmPrivate *priv = lastfm->priv; char *hash_pw, *user_pass, *auth_token; RestProxyCall *call; RestParams *params; GHashTable *params_t; char *api_sig; hash_pw = g_compute_checksum_for_string (G_CHECKSUM_MD5, priv->password, -1); user_pass = g_strconcat(priv->username, hash_pw, NULL); auth_token = g_compute_checksum_for_string (G_CHECKSUM_MD5, user_pass, -1); call = rest_proxy_new_call (priv->proxy); rest_proxy_call_add_params (call, "api_key", priv->api_key, "username", priv->username, "authToken", auth_token, "method", "auth.getMobileSession", NULL); params = rest_proxy_call_get_params (call); params_t = rest_params_as_string_hash_table (params); api_sig = build_call_sig (params_t, priv->api_secret); rest_proxy_call_add_params (call, "api_sig", api_sig, NULL); rest_proxy_call_async (call, _mobile_session_cb, (GObject*)lastfm, NULL, NULL); g_hash_table_unref (params_t); g_free (api_sig); g_free (hash_pw); g_free (user_pass); g_free (auth_token); }
static void online_notify (gboolean online, gpointer user_data) { SwServiceTwitter *twitter = (SwServiceTwitter *)user_data; SwServiceTwitterPrivate *priv = twitter->priv; SW_DEBUG (TWITTER, "Online: %s", online ? "yes" : "no"); /* Clear the token and token secret stored inside the proxy */ oauth_proxy_set_token (OAUTH_PROXY (priv->proxy), NULL); oauth_proxy_set_token_secret (OAUTH_PROXY (priv->proxy), NULL); if (online) { if (priv->username && priv->password) { RestProxyCall *call; SW_DEBUG (TWITTER, "Getting token"); /* * Here we use xAuth to transform a username and password into a OAuth * access token. * * http://apiwiki.twitter.com/Twitter-REST-API-Method:-oauth-access_token-for-xAuth */ call = rest_proxy_new_call (priv->proxy); rest_proxy_call_set_function (call, "oauth/access_token"); rest_proxy_call_add_params (call, "x_auth_mode", "client_auth", "x_auth_username", priv->username, "x_auth_password", priv->password, NULL); rest_proxy_call_async (call, _oauth_access_token_cb, (GObject*)twitter, NULL, NULL); /* Set offline for now and wait for access_token_cb to return */ priv->credentials = OFFLINE; } else { priv->credentials = OFFLINE; } } else { g_free (priv->user_id); if (priv->twitpic_proxy) { g_object_unref (priv->twitpic_proxy); priv->twitpic_proxy = NULL; } priv->user_id = NULL; priv->credentials = OFFLINE; sw_service_emit_capabilities_changed ((SwService *)twitter, get_dynamic_caps ((SwService *)twitter)); } }
static void _twitter_status_update_update_status (SwStatusUpdateIface *self, const gchar *msg, GHashTable *fields, DBusGMethodInvocation *context) { SwServiceTwitter *twitter = SW_SERVICE_TWITTER (self); SwServiceTwitterPrivate *priv = twitter->priv; RestProxyCall *call; if (!priv->user_id) return; /* * http://apiwiki.twitter.com/Twitter-REST-API-Method:-statuses update */ call = rest_proxy_new_call (priv->proxy); rest_proxy_call_set_method (call, "POST"); rest_proxy_call_set_function (call, "1/statuses/update.xml"); rest_proxy_call_add_param (call, "status", msg); if (fields) { const gchar *latitude, *longitude, *twitter_reply_to; latitude = g_hash_table_lookup (fields, "latitude"); longitude = g_hash_table_lookup (fields, "longitude"); if (latitude && longitude) { rest_proxy_call_add_params (call, "lat", latitude, "long", longitude, NULL); } twitter_reply_to = g_hash_table_lookup (fields, "x-twitter-reply-to"); if (twitter_reply_to) { rest_proxy_call_add_param (call, "in_reply_to_status_id", twitter_reply_to); } } rest_proxy_call_async (call, _update_status_cb, (GObject *)self, NULL, NULL); sw_status_update_iface_return_from_update_status (context); }
static int hello_getattr(const char *path, struct stat *stbuf) { RestProxy *proxy = NULL; RestProxyCall *call = NULL; GError *error = NULL; gchar *url = "http://localhost:3000"; int res = 0; proxy = rest_proxy_new (url, FALSE); call = rest_proxy_new_call (proxy); rest_proxy_call_set_function (call, "s3/info"); rest_proxy_call_add_params (call, "format", "json", "url", path, NULL); if (!rest_proxy_call_sync (call, &error)) { snprintf (buf, 1024, "echo '%s' | tee -a /tmp/dl_fuse", error->message); system (buf); g_error_free (error); res = -ENOENT; return res; } else { snprintf (buf, 1024, "echo '%s' | tee -a /tmp/dl_fuse", rest_proxy_call_get_payload (call)); system (buf); } return res = -ENOENT; memset(stbuf, 0, sizeof(struct stat)); if (strcmp(path, "/") == 0) { stbuf->st_mode = S_IFDIR | 0755; stbuf->st_nlink = 2; } else if (strcmp(path, hello_path) == 0) { stbuf->st_mode = S_IFREG | 0444; stbuf->st_nlink = 1; stbuf->st_size = strlen(hello_str); } else if (strcmp(path, "/dliang") == 0) { stbuf->st_mode = S_IFREG | 0444; stbuf->st_nlink = 1; } else res = -ENOENT; return res; }
static void _get_status_updates (SwYoutubeItemView *item_view) { SwYoutubeItemViewPrivate *priv = GET_PRIVATE (item_view); SwService *service = sw_item_view_get_service ((SwItemView *)item_view); RestProxyCall *call; char *user_auth_header = NULL, *devkey_header = NULL; const char *user_auth = NULL; user_auth = sw_service_youtube_get_user_auth (SW_SERVICE_YOUTUBE (service)); if (user_auth == NULL) return; sw_set_empty (priv->set); call = rest_proxy_new_call (priv->proxy); user_auth_header = g_strdup_printf ("GoogleLogin auth=%s", user_auth); rest_proxy_call_add_header (call, "Authorization", user_auth_header); devkey_header = g_strdup_printf ("key=%s", priv->developer_key); rest_proxy_call_add_header (call, "X-GData-Key", devkey_header); if (g_str_equal (priv->query, "feed")) rest_proxy_call_set_function (call, "users/default/newsubscriptionvideos"); else if (g_str_equal (priv->query, "own")) rest_proxy_call_set_function (call, "users/default/uploads"); else g_assert_not_reached (); rest_proxy_call_add_params (call, "max-results", "10", "alt", "rss", NULL); rest_proxy_call_async (call, _got_videos_cb, (GObject *)item_view, NULL, NULL); g_free (user_auth_header); g_free (devkey_header); }
static void update_status (MojitoService *service, const char *msg) { MojitoServiceTwitter *twitter = MOJITO_SERVICE_TWITTER (service); MojitoServiceTwitterPrivate *priv = twitter->priv; RestProxyCall *call; if (!priv->user_id) return; call = rest_proxy_new_call (priv->proxy); rest_proxy_call_set_method (call, "POST"); rest_proxy_call_set_function (call, "statuses/update.xml"); rest_proxy_call_add_params (call, "status", msg, NULL); rest_proxy_call_async (call, _status_updated_cb, (GObject *)service, NULL, NULL); }
static void _twitter_status_update_update_status (MojitoStatusUpdateIface *self, const gchar *msg, DBusGMethodInvocation *context) { MojitoServiceTwitter *twitter = MOJITO_SERVICE_TWITTER (self); MojitoServiceTwitterPrivate *priv = twitter->priv; RestProxyCall *call; if (!priv->user_id) return; call = rest_proxy_new_call (priv->proxy); rest_proxy_call_set_method (call, "POST"); rest_proxy_call_set_function (call, "statuses/update.xml"); rest_proxy_call_add_params (call, "status", msg, NULL); rest_proxy_call_async (call, _update_status_cb, (GObject *)self, NULL, NULL); mojito_status_update_iface_return_from_update_status (context); }
static void online_notify (gboolean online, gpointer user_data) { SwServiceYoutube *youtube = (SwServiceYoutube *)user_data; SwServiceYoutubePrivate *priv = GET_PRIVATE (youtube); priv->credentials = OFFLINE; if (online) { if (priv->username && priv->password) { RestProxyCall *call; /* request user_auth */ /* http://code.google.com/intl/zh-TW/apis/youtube/2.0/developers_guide_protocol_clientlogin.html */ call = rest_proxy_new_call (priv->auth_proxy); rest_proxy_call_set_method (call, "POST"); rest_proxy_call_set_function (call, "ClientLogin"); rest_proxy_call_add_params (call, "Email", priv->username, "Passwd", priv->password, "service", "youtube", "source", "SUSE MeeGo", NULL); rest_proxy_call_add_header (call, "Content-Type", "application/x-www-form-urlencoded"); rest_proxy_call_async (call, (RestProxyCallAsyncCallback)_got_user_auth, (GObject*)youtube, NULL, NULL); } } else { sw_service_emit_capabilities_changed ((SwService *)youtube, get_dynamic_caps ((SwService *)youtube)); } }
static void _sina_status_update_update_status (SwStatusUpdateIface *self, const gchar *msg, GHashTable *fields, DBusGMethodInvocation *context) { SwServiceSina *sina = SW_SERVICE_SINA (self); SwServiceSinaPrivate *priv = GET_PRIVATE (sina); RestProxyCall *call; if (!priv->user_id) return; call = rest_proxy_new_call (priv->proxy); rest_proxy_call_set_method (call, "POST"); rest_proxy_call_set_function (call, "statuses/update.xml"); rest_proxy_call_add_params (call, "status", msg, NULL); rest_proxy_call_async (call, _update_status_cb, (GObject *)self, NULL, NULL); sw_status_update_iface_return_from_update_status (context); }
static void _twitpic_upload_photo (SwPhotoUploadIface *self, const gchar *filename, GHashTable *params, DBusGMethodInvocation *context) { SwServiceTwitter *twitter = SW_SERVICE_TWITTER (self); SwServiceTwitterPrivate *priv = twitter->priv; GError *error = NULL; RestProxyCall *call; RestParam *param; GMappedFile *map; char *title, *content_type; int opid; map = g_mapped_file_new (filename, FALSE, &error); if (error) { dbus_g_method_return_error (context, error); return; } /* Use the title as the tweet, and if the title isn't specified use the filename */ title = g_hash_table_lookup (params, "title"); if (title == NULL) { title = g_path_get_basename (filename); } call = rest_proxy_new_call (priv->twitpic_proxy); rest_proxy_call_set_function (call, "upload.xml"); rest_proxy_call_add_params (call, "key", sw_keystore_get_key ("twitpic"), "message", title, NULL); g_free (title); content_type = g_content_type_guess (filename, (const guchar*) g_mapped_file_get_contents (map), g_mapped_file_get_length (map), NULL); param = rest_param_new_with_owner ("media", g_mapped_file_get_contents (map), g_mapped_file_get_length (map), content_type, filename, map, (GDestroyNotify)g_mapped_file_unref); rest_proxy_call_add_param_full (call, param); g_free (content_type); opid = sw_next_opid (); rest_proxy_call_upload (call, on_upload_cb, (GObject *)self, GINT_TO_POINTER (opid), NULL); sw_photo_upload_iface_return_from_upload_photo (context, opid); }