Imported Upstream version 0.2.85
[debian/pino.git] / src / twitter_recursive_reply.vala
index 94994fa..6ba3f09 100644 (file)
@@ -1,23 +1,23 @@
 using RestCustom;
+using Gee;
 
 namespace Twitter {
 
 public class RecursiveReply : GLib.Object  {
        
-       public signal void new_reply(Status status, string stream_hash, string sid);
+       public signal void new_reply(Status status, string sid);
        
        private Rest.Proxy proxy;
        private string s_name = "";
        private Status fstatus;
-       private string stream_hash = "";
+       //private string stream_hash = "";
        
-       public RecursiveReply(Rest.Proxy proxy, Status fstatus, string s_name,
-               string stream_hash) {
+       public RecursiveReply(Rest.Proxy proxy, Status fstatus, string s_name) {
                
                this.proxy = proxy;
                this.fstatus = fstatus;
                this.s_name = s_name;
-               this.stream_hash = stream_hash;
+               //this.stream_hash = stream_hash;
        }
        
        public void run() {
@@ -26,25 +26,34 @@ public class RecursiveReply : GLib.Object  {
        }
        
        private void get_reply(Status status) {
-               if(status.reply == null)
+               if(status.reply == null) {
+                       debug("the end");
+                       fstatus.end_reply();
                        return;
+               }
                
                Rest.ProxyCall call = proxy.new_call();
                call.set_function("statuses/show/%s.xml".printf(status.reply.status_id));
                call.set_method("GET");
-               debug("statuses/show/%s.xml".printf(status.id));
+               //debug("statuses/show/%s.xml".printf(status.id));
                Rest.ProxyCallAsyncCallback callback = status_get_respose;
                call.run_async(callback, this);
        }
        
        protected void status_get_respose(Rest.ProxyCall call, Error? error, Object? obj) {
-               debug(call.get_status_code().to_string());
+               //debug(call.get_status_code().to_string());
                Status? status = Parser.get_status_from_string(call.get_payload(), s_name);
                
                if(status == null)
                        return;
                
-               new_reply(status, stream_hash, fstatus.id);
+               new_reply(status, fstatus.id);
+               
+               if(fstatus.conversation == null)
+                       fstatus.conversation = new ArrayList<Status>();
+               
+               fstatus.conversation.add(status);
+               fstatus.new_reply(status); //signal
                
                get_reply(status);
        }