Fixed some minor bug. Also fixed problem with double setup for internal extensions.
[lcr.git] / joinpbx.cpp
index af070b1..5bad026 100644 (file)
@@ -853,14 +853,25 @@ void JoinPBX::message_epoint(unsigned int epoint_id, int message_type, union par
                switch(message_type) {
                        case MESSAGE_SETUP:
                        if (param->setup.dialinginfo.itype == INFO_ITYPE_ISDN_EXTENSION) {
+                               /* in case of keypad */
+                               numbers = param->setup.dialinginfo.keypad;
+                               if (numbers[0]) {
+                                       while((number = strsep(&numbers, ","))) {
+                                               if (out_setup(epoint_id, message_type, param, NULL, number))
+                                                       return; // join destroyed
+                                       }
+                                       /* after keypad finish dialing */
+                                       break;
+                               }
+                               /* dialed number */
                                numbers = param->setup.dialinginfo.id;
                                while((number = strsep(&numbers, ","))) {
-                                       if (out_setup(epoint_id, message_type, param, number))
+                                       if (out_setup(epoint_id, message_type, param, number, NULL))
                                                return; // join destroyed
                                }
                                break;
                        }
-                       if (out_setup(epoint_id, message_type, param, NULL))
+                       if (out_setup(epoint_id, message_type, param, NULL, NULL))
                                return; // join destroyed
                        break;
 
@@ -945,7 +956,7 @@ int track_notify(int oldstate, int notify)
  * if other outgoing endpoints already exists, they are release as well.
  * note: if this functions fails, it will destroy its own join object!
  */
-int JoinPBX::out_setup(unsigned int epoint_id, int message_type, union parameter *param, char *newnumber)
+int JoinPBX::out_setup(unsigned int epoint_id, int message_type, union parameter *param, char *newnumber, char *newkeypad)
 {
        struct join_relation *relation;
        struct lcr_msg *message;
@@ -974,7 +985,13 @@ int JoinPBX::out_setup(unsigned int epoint_id, int message_type, union parameter
        memcpy(&message->param, param, sizeof(union parameter));
        if (newnumber)
                SCPY(message->param.setup.dialinginfo.id, newnumber);
-       PDEBUG(DEBUG_JOIN, "setup message sent to ep %d with number='%s'.\n", relation->epoint_id, message->param.setup.dialinginfo.id);
+       else
+               message->param.setup.dialinginfo.id[0] = '\0';
+       if (newkeypad)
+               SCPY(message->param.setup.dialinginfo.keypad, newkeypad);
+       else
+               message->param.setup.dialinginfo.keypad[0] = '\0';
+       PDEBUG(DEBUG_JOIN, "setup message sent to ep %d with number='%s' keypad='%s'.\n", relation->epoint_id, message->param.setup.dialinginfo.id, message->param.setup.dialinginfo.keypad);
        message_put(message);
        return(0);
 }