iswydt.vala
changeset 7 a49fb1ec5e2a
parent 3 dd7a02c6d476
child 12 d3e36b368fc5
equal deleted inserted replaced
6:0d97b0d61ed2 7:a49fb1ec5e2a
   125         } catch (Error e) {
   125         } catch (Error e) {
   126             stderr.printf("Error: %s\n", e.message);
   126             stderr.printf("Error: %s\n", e.message);
   127             _change_state(State.DISCONNECTED, e.message);
   127             _change_state(State.DISCONNECTED, e.message);
   128         }
   128         }
   129     }
   129     }
   130     public void close() {
   130     public void close(string reason) {
       
   131         if ((state==State.CONNECTED)&&(reason != null)) {
       
   132             var prs = new Lm.Message(null, Lm.MessageType.PRESENCE);
       
   133             prs.node.set_attribute("type","unavailable");
       
   134             prs.node.add_child("status",reason);
       
   135             cn.send(prs);
       
   136         }
   131         cn.close();
   137         cn.close();
   132     }
   138     }
   133 }
   139 }
   134     
   140     
   135 
   141 
   171         else {
   177         else {
   172             account.state_changed.connect( (olds, news, desc) => {
   178             account.state_changed.connect( (olds, news, desc) => {
   173                 if (news == Connection.State.DISCONNECTED)
   179                 if (news == Connection.State.DISCONNECTED)
   174                     loop.quit();
   180                     loop.quit();
   175             });
   181             });
   176             account.close();
   182             account.close("Received SIGINT");
   177         }
   183         }
   178     });
   184     });
   179     Posix.sigaction(Posix.SIGINT, action, null);
   185     Posix.sigaction(Posix.SIGINT, action, null);
   180 
   186 
   181     loop.run();
   187     loop.run();