コード例 #1
0
static gboolean
sw_service_youtube_initable (GInitable    *initable,
                             GCancellable *cancellable,
                             GError      **error)
{
  SwServiceYoutube *youtube = SW_SERVICE_YOUTUBE (initable);
  SwServiceYoutubePrivate *priv = GET_PRIVATE (youtube);
  const char *key = NULL;

  if (priv->inited)
    return TRUE;

  sw_keystore_get_key_secret ("youtube", &key, NULL);
  if (key == NULL) {
    g_set_error_literal (error,
                         SW_SERVICE_ERROR,
                         SW_SERVICE_ERROR_NO_KEYS,
                         "No API key configured");
    return FALSE;
  }

  priv->proxy = rest_proxy_new ("http://gdata.youtube.com/feeds/api/", FALSE);
  priv->auth_proxy = rest_proxy_new ("https://www.google.com/youtube/accounts/", FALSE);

  priv->developer_key = (char *)key;
  priv->credentials = OFFLINE;
  
  sw_online_add_notify (online_notify, youtube);

  refresh_credentials (youtube);

  priv->inited = TRUE;

  return TRUE;
}
コード例 #2
0
ファイル: lastfm.c プロジェクト: Artea/libsocialweb
static gboolean
sw_service_lastfm_initable (GInitable     *initable,
                            GCancellable  *cancellable,
                            GError       **error)
{
  SwServiceLastfm *lastfm = SW_SERVICE_LASTFM (initable);
  SwServiceLastfmPrivate *priv = lastfm->priv;

  if (sw_keystore_get_key ("lastfm") == NULL) {
    g_set_error_literal (error,
                         SW_SERVICE_ERROR,
                         SW_SERVICE_ERROR_NO_KEYS,
                         "No API key configured");
    return FALSE;
  }

  if (priv->proxy)
    return TRUE;

  priv->proxy = rest_proxy_new ("http://ws.audioscrobbler.com/2.0/", FALSE);

  refresh_credentials (lastfm);

  return TRUE;
}
コード例 #3
0
ファイル: proxy-continuous.c プロジェクト: UIKit0/librest
int
main (int argc, char **argv)
{
  SoupSession *session;
  char *url;
  RestProxy *proxy;

  g_type_init ();
  loop = g_main_loop_new (NULL, FALSE);

  session = soup_session_async_new ();

  server = soup_server_new (NULL);
  soup_server_add_handler (server, NULL, server_callback, NULL, NULL);
  soup_server_run_async (server);

  url = g_strdup_printf ("http://127.0.0.1:%d/", soup_server_get_port (server));
  proxy = rest_proxy_new (url, FALSE);
  g_free (url);

  stream_test (proxy);
  g_main_loop_run (loop);

  return errors != 0;
}
コード例 #4
0
ファイル: lastfm.c プロジェクト: Artea/libsocialweb-1
static gboolean
sw_service_lastfm_initable (GInitable     *initable,
                            GCancellable  *cancellable,
                            GError       **error)
{
  SwServiceLastfm *lastfm = SW_SERVICE_LASTFM (initable);
  SwServiceLastfmPrivate *priv = lastfm->priv;
  const char *key = NULL, *secret = NULL;

  if (priv->inited)
    return TRUE;

  sw_keystore_get_key_secret ("lastfm", &key, &secret);

  if (key == NULL || secret == NULL) {
    g_set_error_literal (error,
                         SW_SERVICE_ERROR,
                         SW_SERVICE_ERROR_NO_KEYS,
                         "No API key configured");
    return FALSE;
  }

  priv->proxy = rest_proxy_new ("http://ws.audioscrobbler.com/2.0/", FALSE);
  priv->api_key = g_strdup (key);
  priv->api_secret = g_strdup (secret);

  refresh_credentials (lastfm);

  priv->inited = TRUE;

  return TRUE;
}
コード例 #5
0
ファイル: vimeo.c プロジェクト: Artea/libsocialweb
static gboolean
sw_service_vimeo_initable (GInitable     *initable,
                             GCancellable  *cancellable,
                             GError       **error)
{
  SwServiceVimeo *self = SW_SERVICE_VIMEO (initable);
  SwServiceVimeoPrivate *priv = self->priv;
  const gchar *api_key;
  const gchar *api_secret;

  if (priv->inited)
    return TRUE;

  sw_keystore_get_key_secret ("vimeo", &api_key, &api_secret);

  if (api_key == NULL || api_secret == NULL) {
    g_set_error_literal (error,
                         SW_SERVICE_ERROR,
                         SW_SERVICE_ERROR_NO_KEYS,
                         "No API or secret key configured");
    return FALSE;
  }

  priv->inited = TRUE;

  priv->proxy = oauth_proxy_new (api_key, api_secret, "http://vimeo.com/", FALSE);
  priv->simple_proxy = rest_proxy_new ("http://vimeo.com/api/v2/%s/", TRUE);

  sw_online_add_notify (online_notify, self);
  refresh_credentials (self);

  return TRUE;
}
コード例 #6
0
static RestProxy* ease_oca_service_real_create_proxy (EasePluginImportService* base) {
#line 103 "ease-import-oca-service.c"
	EaseOCAService * self;
	RestProxy* result = NULL;
	self = (EaseOCAService*) base;
	result = rest_proxy_new (EASE_OCA_SERVICE_REST_URL, FALSE);
#line 25 "ease-import-oca-service.vala"
	return result;
#line 110 "ease-import-oca-service.c"
}
コード例 #7
0
ファイル: twitter.c プロジェクト: lcp/mojito
static void
online_notify (gboolean online, gpointer user_data)
{
  MojitoServiceTwitter *twitter = (MojitoServiceTwitter *)user_data;
  MojitoServiceTwitterPrivate *priv = twitter->priv;

  MOJITO_DEBUG (TWITTER, "Online: %s", online ? "yes" : "no");

  if (online) {
#if TWITTER_USE_OAUTH
    const char *key = NULL, *secret = NULL;

    mojito_keystore_get_key_secret ("twitter", &key, &secret);
    priv->proxy = oauth_proxy_new (key, secret, "http://twitter.com/", FALSE);
    mojito_keyfob_oauth ((OAuthProxy *)priv->proxy, got_tokens_cb, twitter);
#else
    if (priv->username && priv->password) {
      char *url;
      char *escaped_user;
      char *escaped_password;

      escaped_user = g_uri_escape_string (priv->username,
                                          NULL,
                                          FALSE);
      escaped_password = g_uri_escape_string (priv->password,
                                          NULL,
                                          FALSE);

      url = g_strdup_printf ("https://%s:%[email protected]/",
                             escaped_user, escaped_password);

      g_free (escaped_user);
      g_free (escaped_password);

      priv->proxy = rest_proxy_new (url, FALSE);
      g_free (url);

      got_tokens_cb (priv->proxy, TRUE, twitter);
    } else {
      mojito_service_emit_refreshed ((MojitoService *)twitter, NULL);
    }
#endif
  } else {
    if (priv->proxy) {
      g_object_unref (priv->proxy);
      priv->proxy = NULL;
    }
    g_free (priv->user_id);
    priv->user_id = NULL;

    mojito_service_emit_capabilities_changed ((MojitoService *)twitter, NULL);
  }
}
コード例 #8
0
ファイル: gfbgraph-common.c プロジェクト: alvaropg/gfbgraph
/**
 * gfbgraph_new_rest_call:
 * @authorizer: a #GFBGraphAuthorizer.
 *
 * Create a new #RestProxyCall pointing to the Facebook Graph API url (https://graph.facebook.com)
 * and processed by the authorizer to allow queries.
 *
 * Returns: (transfer full): a new #RestProxyCall or %NULL in case of error.
 **/
RestProxyCall*
gfbgraph_new_rest_call (GFBGraphAuthorizer *authorizer)
{
        RestProxy *proxy;
        RestProxyCall *rest_call;

        g_return_val_if_fail (GFBGRAPH_IS_AUTHORIZER (authorizer), NULL);

        proxy = rest_proxy_new (FACEBOOK_ENDPOINT, FALSE);
        rest_call = rest_proxy_new_call (proxy);

        gfbgraph_authorizer_process_call (authorizer, rest_call);

        g_object_unref (proxy);

        return rest_call;
}
コード例 #9
0
ファイル: test.c プロジェクト: initlove/fuse-ocs
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;
}
コード例 #10
0
static gboolean
sw_service_plurk_initable (GInitable    *initable,
                           GCancellable *cancellable,
                           GError      **error)
{
  /* Initialize the service and return TRUE if everything is OK.
     Otherwise, return FALSE */
  SwServicePlurk *plurk = SW_SERVICE_PLURK (initable);
  SwServicePlurkPrivate *priv = GET_PRIVATE (plurk);
  const char *key = NULL;

  if (priv->inited)
    return TRUE;

  sw_keystore_get_key_secret ("plurk", &key, NULL);
  if (key == NULL) {
    g_set_error_literal (error,
                         SW_SERVICE_ERROR,
                         SW_SERVICE_ERROR_NO_KEYS,
                         "No API key configured");
    return FALSE;
  }

  priv->api_key = g_strdup (key);

  priv->credentials = OFFLINE;

  priv->proxy = rest_proxy_new ("http://www.plurk.com/API/", FALSE); 

  sw_online_add_notify (online_notify, plurk);

  refresh_credentials (plurk);

  priv->inited = TRUE;

  return TRUE;

}