public
Description: A Clutter-based Twitter client
Homepage: http://live.gnome.org/Tweet
Clone URL: git://github.com/ebassi/tweet.git
Get the user from Twitter before the user's timeline

We need to keep the user around - for checking user preferences, location
and other stuff we might want to update and/or display. Also having the
user id would make looking up the archive and other data a lot easier.

Since it's better to serialize the requests to Twitter to avoid the
failwhale to fall on our heads followed by a vase of petunias, we get the
user info first and then we ask for the user's timeline if the action was
successfull.
Emmanuele Bassi (author)
Tue Jun 17 13:52:16 -0700 2008
commit  49df641a76dce0cdd3c8216ae11c0799dc852f8d
tree    f760270775b904ff702c13042b67132eb58a4821
parent  17255a573addd0144a64c619df034730d1de70df
...
84
85
86
 
87
88
89
...
119
120
121
 
 
 
 
 
 
122
123
124
...
187
188
189
190
 
191
192
193
...
515
516
517
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
518
519
520
...
611
612
613
614
 
615
616
617
 
 
 
618
619
620
621
622
623
 
 
624
625
626
...
84
85
86
87
88
89
90
...
120
121
122
123
124
125
126
127
128
129
130
131
...
194
195
196
 
197
198
199
200
...
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
...
648
649
650
 
651
652
 
 
653
654
655
656
 
 
 
 
 
657
658
659
660
661
0
@@ -84,6 +84,7 @@ struct _TweetWindowPrivate
0
   GtkActionGroup *action_group;
0
 
0
   TwitterClient *client;
0
+ TwitterUser *user;
0
 
0
   GTimeVal last_update;
0
 
0
@@ -119,6 +120,12 @@ tweet_window_dispose (GObject *gobject)
0
       priv->refresh_id = 0;
0
     }
0
 
0
+ if (priv->user)
0
+ {
0
+ g_object_unref (priv->user);
0
+ priv->user = NULL;
0
+ }
0
+
0
   if (priv->client)
0
     {
0
       twitter_client_end_session (priv->client);
0
@@ -187,7 +194,7 @@ on_status_received (TwitterClient *client,
0
       g_warning ("Unable to retrieve status from Twitter: %s", error->message);
0
     }
0
   else
0
- tweet_status_model_prepend_status (window->priv->status_model, status);
0
+ tweet_status_model_prepend_status (priv->status_model, status);
0
 }
0
 
0
 static void
0
@@ -515,6 +522,36 @@ refresh_timeout (gpointer data)
0
   return TRUE;
0
 }
0
 
0
+static void
0
+on_user_received (TwitterClient *client,
0
+ TwitterUser *user,
0
+ const GError *error,
0
+ TweetWindow *window)
0
+{
0
+ TweetWindowPrivate *priv = window->priv;
0
+ gint refresh_time;
0
+
0
+ if (error)
0
+ {
0
+ priv->user = NULL;
0
+ g_warning ("Unable to retrieve user `%s': %s",
0
+ tweet_config_get_username (priv->config),
0
+ error->message);
0
+ return;
0
+ }
0
+
0
+ /* keep a reference on ourselves */
0
+ priv->user = g_object_ref (user);
0
+
0
+ twitter_client_get_user_timeline (priv->client, NULL, 0, 0);
0
+
0
+ refresh_time = tweet_config_get_refresh_time (priv->config);
0
+ if (refresh_time > 0)
0
+ priv->refresh_id = g_timeout_add_seconds (refresh_time,
0
+ refresh_timeout,
0
+ window);
0
+}
0
+
0
 #ifdef HAVE_NM_GLIB
0
 static void
0
 nm_context_callback (libnm_glib_ctx *libnm_ctx,
0
@@ -611,16 +648,14 @@ tweet_window_constructed (GObject *gobject)
0
   nm_state = libnm_glib_get_network_state (priv->nm_context);
0
   if (nm_state == LIBNM_ACTIVE_NETWORK_CONNECTION)
0
     {
0
- gint refresh_time;
0
+ const gchar *email_address;
0
 
0
- /* get all updates */
0
- twitter_client_get_user_timeline (priv->client, NULL, 0, 0);
0
+ g_signal_connect (priv->client,
0
+ "user-received", G_CALLBACK (on_user_received),
0
+ window);
0
 
0
- refresh_time = tweet_config_get_refresh_time (priv->config);
0
- if (refresh_time > 0)
0
- priv->refresh_id = g_timeout_add_seconds (refresh_time,
0
- refresh_timeout,
0
- window);
0
+ email_address = tweet_config_get_username (priv->config);
0
+ twitter_client_show_user_from_email (priv->client, email_address);
0
     }
0
   else
0
     {

Comments

    No one has commented yet.