Author: sayer
Date: 2009-10-13 22:07:07 +0200 (Tue, 13 Oct 2009)
New Revision: 1539

Modified:
   trunk/apps/registrar_client/SIPRegistrarClient.cpp
   trunk/apps/registrar_client/SIPRegistrarClient.h
Log:
listRegistrations method (useful via xmlrpc)



Modified: trunk/apps/registrar_client/SIPRegistrarClient.cpp
===================================================================
--- trunk/apps/registrar_client/SIPRegistrarClient.cpp  2009-10-13 20:05:33 UTC 
(rev 1538)
+++ trunk/apps/registrar_client/SIPRegistrarClient.cpp  2009-10-13 20:07:07 UTC 
(rev 1539)
@@ -45,8 +45,6 @@
     SIPRegistrarClient* reg_c = SIPRegistrarClient::instance();
     assert(dynamic_cast<AmDynInvokeFactory*>(reg_c));
 
-    DBG("Hallo, alles in ordnung!\n");
-
     return (AmPluginFactory*)reg_c;
 }
 
@@ -630,6 +628,26 @@
   return res;
 }
 
+void SIPRegistrarClient::listRegistrations(AmArg& res) {
+  reg_mut.lock();
+
+  for (map<string, SIPRegistration*>::iterator it = 
+        registrations.begin(); it != registrations.end(); it++) {
+    AmArg r;
+    r["handle"] = it->first;
+    r["domain"] = it->second->getInfo().domain;
+    r["user"] = it->second->getInfo().user;
+    r["name"] = it->second->getInfo().name;
+    r["auth_user"] = it->second->getInfo().auth_user;
+    r["proxy"] = it->second->getInfo().proxy;
+    r["event_sink"] = it->second->getEventSink();
+    res.push(r);
+  }
+
+  reg_mut.unlock();
+}
+
+
 void SIPRegistrarClient::invoke(const string& method, const AmArg& args, 
                                AmArg& ret)
 {
@@ -649,8 +667,7 @@
   }
   else if(method == "removeRegistration"){
     removeRegistration(args.get(0).asCStr());
-  } 
-  else if(method == "getRegistrationState"){
+  } else if(method == "getRegistrationState"){
     unsigned int state;
     unsigned int expires;
     if (instance()->getRegistrationState(args.get(0).asCStr(), 
@@ -661,10 +678,13 @@
     } else {
       ret.push(AmArg((int)0));
     }
+  } else if(method == "listRegistrations"){
+    listRegistrations(ret);
   } else if(method == "_list"){ 
     ret.push(AmArg("createRegistration"));
     ret.push(AmArg("removeRegistration"));
     ret.push(AmArg("getRegistrationState"));
+    ret.push(AmArg("listRegistrations"));
   }  else
     throw AmDynInvoke::NotImplemented(method);
 }

Modified: trunk/apps/registrar_client/SIPRegistrarClient.h
===================================================================
--- trunk/apps/registrar_client/SIPRegistrarClient.h    2009-10-13 20:05:33 UTC 
(rev 1538)
+++ trunk/apps/registrar_client/SIPRegistrarClient.h    2009-10-13 20:07:07 UTC 
(rev 1539)
@@ -140,6 +140,9 @@
   RegistrationState getState(); 
   /** return the expires left for the registration */
   unsigned int getExpiresLeft(); 
+
+  SIPRegistrationInfo& getInfo() { return info; }
+  const string& getEventSink() { return sess_link; }
 };
 
 class SIPNewRegistrationEvent;
@@ -165,6 +168,7 @@
   void onSipReplyEvent(AmSipReplyEvent* ev);   
   void onNewRegistration(SIPNewRegistrationEvent* new_reg);
   void onRemoveRegistration(SIPRemoveRegistrationEvent* new_reg);
+  void listRegistrations(AmArg& res);
 
   static SIPRegistrarClient* _instance;
 

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to