Yu.ding 4 лет назад
Родитель
Сommit
f11344d44c


+ 18 - 0
usr/src/createlicense.sh

@@ -0,0 +1,18 @@
+#!/bin/sh
+#set license
+licensefile='/app/broadcast-system/data/zycoo_init/sql/.limited'
+cid=`cat /sys/block/mmcblk1/device/cid`e845116521d590069f285ddde46ee2cf
+openssl rand -hex 32 > $licensefile
+openssl rand -hex 32 >> $licensefile
+openssl rand -hex 32 >> $licensefile
+openssl rand -hex 32 >> $licensefile
+openssl rand -hex 32 >> $licensefile
+openssl rand -hex 32 >> $licensefile
+openssl rand -hex 32 >> $licensefile
+echo `openssl rand -hex 5``echo -n $cid |md5sum|awk '{print $1}'``openssl rand -hex 11` >> $licensefile
+openssl rand -hex 32 >> $licensefile
+openssl rand -hex 32 >> $licensefile
+openssl rand -hex 32 >> $licensefile
+openssl rand -hex 32 >> $licensefile
+
+rm -f /createlicense.sh

+ 3 - 1
usr/src/extension_gen.c

@@ -18,6 +18,7 @@
 #include<mysql/mysql.h>
 #include<mysql/mysqld_error.h>
 #include<mysql/errmsg.h>
+#include <ctype.h>
 
 #define EXTEN_GEN_CFG "/etc/asterisk/exten_gen.ini"
 #define USER_WEBRTC_CONFIG_FILE "/etc/asterisk/users_webrtc.conf" 
@@ -107,7 +108,8 @@ int main(int argc, char *argv[]){
 	if(NULL != argv[1]){
 		switch(*argv[1]){
 			case '0':
-				res	= mysql_query(&conn,"SELECT * from t_pbx_users_extension order by exten asc");
+				//res	= mysql_query(&conn,"SELECT * from t_pbx_users_extension order by exten asc");
+				res	= mysql_query(&conn,"SELECT * from t_pbx_users_extension order by exten asc limit 500");
 				if(res){
 					fprintf(stderr,"SELECT error: %s\n",mysql_error(&conn));
 					return -1;

+ 7 - 20
usr/src/generate_context_conf.c

@@ -349,34 +349,21 @@ mytime()\
         }
 
         memset(sql_tmp,0,sizeof(sql_tmp));
-        sprintf(sql_tmp,"select exten,t_paging_userServices.tPagingServiceId as service_id from t_paging_groups\
-        JOIN t_paging_userGroups on t_paging_groups.id = t_paging_userGroups.GroupId\
-        JOIN t_paging_userServices on t_paging_userServices.UserId = t_paging_userGroups.UserId\
-        where t_paging_userServices.tPagingServiceId in(1,4,9) and t_paging_userGroups.UserId\
-        in(select t_paging_users.id from t_paging_users join t_paging_devices on t_paging_users.id = t_paging_devices.user_id\
-        where t_paging_devices.exten=%s) order by t_paging_userServices.tPagingServiceId",g_row[1]);
+        sprintf(sql_tmp,"select exten from t_paging_groups JOIN t_paging_userGroups on\
+        t_paging_groups.id = t_paging_userGroups.GroupId where t_paging_userGroups.UserId\
+        in(select UserId from t_paging_deviceGroups JOIN t_paging_userGroups on\
+        t_paging_deviceGroups.GroupId = t_paging_userGroups.GroupId where DeviceId = %s) group by exten",g_row[0]);
         if (executesql(sql_tmp)){
             print_mysql_error(NULL);
             exit(1);
         }
         d_res = mysql_store_result(g_conn); // 从服务器传送结果集至本地,mysql_use_result直接使用服务器上的记录集
         while ((d_row=mysql_fetch_row(d_res))){ // 打印结果集
-            if (d_row[0] == NULL || d_row[1] == NULL){
+            if (d_row[0] == NULL){
                 printf("some feild is empty!\n");
                 continue;
             }
-            int id = atoi(d_row[1]);
-            switch(id){
-                case 1:
-                    fprintf(conf_fp, "include => paging-group-%s\n", d_row[0]);
-                    break;
-                case 9:
-                    if(setout){
-                        fprintf(conf_fp, "include => CallingRule_OutCall\n");
-                        setout = 0;
-                    }
-                    break;
-            }
+            fprintf(conf_fp, "include => paging-group-%s\n", d_row[0]);
         }
 
     }
@@ -397,6 +384,7 @@ mytime()\
         int setout = 1;
         fprintf(conf_fp, "[DialRule_%s]\n",g_row[1]);
         fprintf(conf_fp, "include => call-trigger\n");
+        fprintf(conf_fp, "include => featurecodes\n");
         if(g_row[2]){
             memset(sql_tmp,0,sizeof(sql_tmp));
             sprintf(sql_tmp,"select exten,t_paging_userServices.tPagingServiceId as service_id from t_paging_groups\
@@ -445,7 +433,6 @@ mytime()\
                     continue;
                 }
                 fprintf(conf_fp, "include => DialRule_users\n");
-                fprintf(conf_fp, "include => featurecodes\n");
                 fprintf(conf_users_fp, "exten => %s,1,Macro(stdexten,%s,SIP/%s)\n",g_row[1],g_row[1],g_row[1]);
                 fprintf(global_fp, "USER_ID_%s = %s\n",g_row[1],d_row[0]);
                 fprintf(global_fp, "USER_LEVEL_%s = %s\n",g_row[1],d_row[1]);

+ 72 - 2
usr/src/generate_extension_conf.c

@@ -31,6 +31,7 @@ MYSQL_ROW g_row; // 字符串数组,mysql 记录行
 #define EXTEN_INBOUND_FILE "/etc/asterisk/extensions_inbound_custom.conf"
 #define EXTEN_GLOBAL_FILE "/etc/asterisk/extensions_global_custom.conf"
 #define EXTEN_CALLTRIGGER_FILE "/etc/asterisk/extensions_call_trigger_custom.conf"
+#define EXTEN_FEATURECODES_FILE "/etc/asterisk/extensions_featurecodes_custom.conf"
 #define KEYVALLEN 100
 #define VERSION "V1.0.1"
 
@@ -376,7 +377,7 @@ fputs("[CallingRule_OutCall]\n",conf_dialrule_fp);
         }
 
         memset(dialrule,0,sizeof(dialrule));
-        sprintf(dialrule, "exten => _%s,1,Macro(trunkdial-failover,${EXTEN},%s/",g_row[1], g_row[0]);
+        sprintf(dialrule, "exten => _%s,1,Macro(trunkdial-failover,${EXTEN},${%s}",g_row[1], g_row[0]);
         if(g_row[3] != NULL){
             strcat(dialrule,g_row[3]);
         }
@@ -403,6 +404,7 @@ g_res = mysql_store_result(g_conn); // 从服务器传送结果集至本地,my
 FILE *conf_inbound_fp = fopen(EXTEN_INBOUND_FILE, "w+");
 FILE *conf_global_fp = fopen(EXTEN_GLOBAL_FILE, "w+");
 FILE *conf_calltrigger_fp = fopen(EXTEN_CALLTRIGGER_FILE, "w+");
+FILE *conf_featurecodes_fp = fopen(EXTEN_FEATURECODES_FILE, "w+");
 
 if (conf_inbound_fp == NULL){
         perror("Open paging conf file Error: ");
@@ -419,6 +421,11 @@ if (conf_calltrigger_fp == NULL){
         exit(1);
     }
 
+if (conf_featurecodes_fp == NULL){
+        perror("Open paging conf file Error: ");
+        exit(1);
+    }
+
     fprintf(conf_inbound_fp, ";!\n\
 ;! Automatically generated configuration file\n\
 ;! Filename: extensions_inbound_custom.conf (/etc/asterisk/extensions_inbound_custom.conf)\n\
@@ -438,17 +445,34 @@ mytime()\
 ",\
 mytime()\
 );
+fprintf(conf_global_fp, "\
+AGISERVERHOST = %s\n\
+AGISERVERPORT = %s\n\
+",\
+getenv("BROADCAST_GATEWAY"),\
+getenv("AGI_SERVER_PORT")\
+);
 
     fprintf(conf_calltrigger_fp, ";!\n\
 ;! Automatically generated configuration file\n\
 ;! Filename: extensions_call_trigger_custom.conf (/etc/asterisk/extensions_call_trigger_custom.conf)\n\
-;! Generator: Generator GLOBAL\n\
+;! Generator: Generator TRIGGER\n\
 ;! Creation Date: %s\n\
 ;!\n\n\
 ",\
 mytime()\
 );
 
+    fprintf(conf_featurecodes_fp, ";!\n\
+;! Automatically generated configuration file\n\
+;! Filename: extensions_featurecodes_custom.conf (/etc/asterisk/extensions_featurecodes_custom.conf)\n\
+;! Generator: Generator FEATURECODES\n\
+;! Creation Date: %s\n\
+;!\n\n\
+[featurecodes]\n",\
+mytime()\
+);
+
 //t_pbx_users_voiptrunk.trunk as trunk,rule,del_prefix,add_before,add_after
     while ((g_row=mysql_fetch_row(g_res))){ // 打印结果集
         if (g_row[0] == NULL || g_row[1] == NULL || g_row[2] == NULL){
@@ -511,11 +535,57 @@ cJSON_GetObjectItem(pJson, "start")->valuestring,\
 cJSON_GetObjectItem(pJson, "end")->valuestring\
 );
         }
+        else if(strcmp(g_row[1],"paging.featurecodes.config") == 0){
+            pJson = cJSON_Parse(g_row[2]);
+            pSub = cJSON_GetObjectItem(pJson, "bargein");
+            if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
+                fprintf(conf_featurecodes_fp, "exten = _%s.,1,Macro(spy-barge,${EXTEN:%d},${CALLERID(num)})\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
+            }
+            pSub = cJSON_GetObjectItem(pJson, "clear");
+            if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
+                fprintf(conf_featurecodes_fp, "exten = _%s.,1,Macro(exten-clear,${EXTEN:%d},${CALLERID(num)})\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
+            }
+            pSub = cJSON_GetObjectItem(pJson, "syp");
+            if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
+                fprintf(conf_featurecodes_fp, "exten = _%s.,1,Macro(spy-normal,${EXTEN:%d},${CALLERID(num)})\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
+            }
+            pSub = cJSON_GetObjectItem(pJson, "whisper");
+            if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
+                fprintf(conf_featurecodes_fp, "exten = _%s.,1,Macro(spy-whisper,${EXTEN:%d},${CALLERID(num)})\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
+            }
+            pSub = cJSON_GetObjectItem(pJson, "wakeup");
+            if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
+                fprintf(conf_featurecodes_fp, "exten = %s,1,Macro(wakeup-call,${CALLERID(num)})\n",cJSON_GetObjectItem(pSub, "code")->valuestring);
+            }
+            pSub = cJSON_GetObjectItem(pJson, "dnd");
+            if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
+                fprintf(conf_featurecodes_fp, "exten = %s,1,Goto(app-dnd-on,s,1)\n",cJSON_GetObjectItem(pSub, "code")->valuestring);
+            }
+            pSub = cJSON_GetObjectItem(pJson, "cf-alway");
+            if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
+                fprintf(conf_featurecodes_fp, "exten = _%s.,1,Goto(app-cf-on,cf-${EXTEN:%d},1)\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
+                fprintf(conf_featurecodes_fp, "exten = %s,1,Goto(app-cf-off,s,1)\n",cJSON_GetObjectItem(pSub, "code")->valuestring);
+            }
+            pSub = cJSON_GetObjectItem(pJson, "cf-busy");
+            if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
+                fprintf(conf_featurecodes_fp, "exten = _%s.,1,Goto(app-cfb-on,cf-${EXTEN:%d},1)\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
+                fprintf(conf_featurecodes_fp, "exten = %s,1,Goto(app-cfb-off,s,1)\n",cJSON_GetObjectItem(pSub, "code")->valuestring);
+            }
+            pSub = cJSON_GetObjectItem(pJson, "cf-noanswer");
+            if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
+                fprintf(conf_featurecodes_fp, "exten = _%s.,1,Goto(app-cfu-on,cf-${EXTEN:%d},1)\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
+                fprintf(conf_featurecodes_fp, "exten = %s,1,Goto(app-cfu-off,s,1)\n",cJSON_GetObjectItem(pSub, "code")->valuestring);
+            }
+        }
     }
 
 
 fclose(conf_dialrule_fp);
 fclose(conf_ivr_fp);
+fclose(conf_inbound_fp);
+fclose(conf_global_fp);
+fclose(conf_calltrigger_fp);
+fclose(conf_featurecodes_fp);
 mysql_free_result(g_res); // 释放结果集
 mysql_close(g_conn); // 关闭链接
 cJSON_Delete(pJson);

+ 8 - 3
usr/src/generate_group_conf.c

@@ -338,17 +338,22 @@ while ((g_row=mysql_fetch_row(g_res))){ // 打印结果集
     fprintf(conf_paging_fp, "\
 [paging-group-%s]\n\
 exten => %s,1,NoOp(%s)\n\
-same => n,MSet(__SRCEXTEN=${CALLERID(num)},DATE=${STRFTIME(${EPOCH},,%%Y%%m%%d)},__UUID=${UNIQUEID},ALERTINFO=Alert-Info: Ring Answer,CALLINFO=Call-Info: <uri>\\;answer-after=0)\n\
+same => n,MSet(__SRCEXTEN=${CALLERID(num)},__DESTS=%s,DATE=${STRFTIME(${EPOCH},,%%Y%%m%%d)},__UUID=${UNIQUEID},ALERTINFO=Alert-Info: Ring Answer,CALLINFO=Call-Info: <uri>\\;answer-after=0)\n\
 same => n,SIPAddHeader(${ALERTINFO})\n\
 same => n,SIPAddHeader(${CALLINFO})\n\
 same => n,System(/bin/sh /etc/scripts/shell_scripts.sh mkrcdir paging ${DATE})\n\
 same => n,Set(FILENAME=paging/${DATE}/paging-${SRCEXTEN}-${UUID}.wav)\n\
 same => n,MixMonitor(${FILENAME},b)\n\
 same => n,Macro(get-user-level,${SRCEXTEN},)\n\
+same => n,AGI(agi://${AGISERVERHOST}:${AGISERVERPORT},paging,${DESTS},${SESSION_LEVEL},${SESSION_USERID})\n\
+same => n,ExecIf(${ISNULL(${DESTS})}?Hangup())\n\
 same => n,ExecIf($['foo${enPaging_prompt_start}'='fooyes']?Set(STARTPROMPT=qA(start)))\n\
-same => n,UserEvent(controlEvent,sessionlevel:${SESSION_LEVEL},sessionuserid:${SESSION_USERID},src:${SRCEXTEN},dest:%s,uuid:${UUID},status:stop)\n\
+same => n,UserEvent(controlEvent,sessionlevel:${SESSION_LEVEL},sessionuserid:${SESSION_USERID},src:${SRCEXTEN},dest:${DESTS},uuid:${UUID},status:stop)\n\
 same => n,Wait(1)\n\
-same => n,Page(%s,b(paging-update-status^s^1)${STARTPROMPT})\n\
+same => n,GotoIf(${ISNULL(${DESTCHANS})}?default)\n\
+same => n,Page(${DESTCHANS},b(paging-update-status^s^1)${STARTPROMPT})\n\
+same => n,Hangup\n\
+same => n(default),Page(%s,b(paging-update-status^s^1)${STARTPROMPT})\n\
 same => n,Hangup\
 \n\n", \
 g_row[2],\

+ 16 - 7
usr/src/generate_user_conf.c

@@ -293,7 +293,7 @@ while ((g_row=mysql_fetch_row(g_res))){ // 打印结果集
 setinterfacevar = yes\n\
 setqueueentryvar = yes\n\
 strategy = %s\n\
-timeout = 20\n\
+timeout = 60\n\
 wrapuptime = 0\n\
 autofill = yes\n\
 autopause = no\n\
@@ -314,12 +314,21 @@ queue-minutes =\n\
 queue-thankyou =\n\
 musicclass = queuemusic\n\
 \n",q,g_row[2]);
-
-            for(int i = 0;i < iCount;i++){
-                pSub = cJSON_GetArrayItem(pJson,i);
-                if(pSub != NULL){
-                    fprintf(conf_queues_fp, "member => SIP/%s,%d\n",pSub->valuestring,i);
-                    fprintf(conf_user_queue_fp, "exten => %s,1,Macro(queue,Q%d,${EXTEN})\n", pSub->valuestring,q);
+            if(strcmp(g_row[2],"ringall") == 0){
+                for(int i = 0;i < iCount;i++){
+                    pSub = cJSON_GetArrayItem(pJson,i);
+                    if(pSub != NULL){
+                        fprintf(conf_queues_fp, "member => SIP/%s\n",pSub->valuestring);
+                        fprintf(conf_user_queue_fp, "exten => %s,1,Macro(queue,Q%d,${EXTEN})\n", pSub->valuestring,q);
+                    }
+                }
+            }else{
+                for(int i = 0;i < iCount;i++){
+                    pSub = cJSON_GetArrayItem(pJson,i);
+                    if(pSub != NULL){
+                        fprintf(conf_queues_fp, "member => SIP/%s,%d\n",pSub->valuestring,i);
+                        fprintf(conf_user_queue_fp, "exten => %s,1,Macro(queue,Q%d,${EXTEN})\n", pSub->valuestring,q);
+                    }
                 }
             }
         }