Freeswitch-branches
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
December 2006
- 8 participants
- 101 discussions
[commit] r3851 - in freeswitch/branches/knhor/trunk: . libs/libresample libs/libresample/libresample.xcodeproj libs/libteletone libs/libteletone/libteletone.xcodeproj src/mod/endpoints/mod_dingaling src/mod/endpoints/mod_sofia
by Freeswitch SVN 27 Dec '06
by Freeswitch SVN 27 Dec '06
27 Dec '06
Author: knhor
Date: Wed Dec 27 13:49:11 2006
New Revision: 3851
Added:
freeswitch/branches/knhor/trunk/libs/libresample/libresample-Info.plist
- copied unchanged from r3850, /freeswitch/trunk/libs/libresample/libresample-Info.plist
freeswitch/branches/knhor/trunk/libs/libresample/libresample.xcodeproj/
- copied from r3850, /freeswitch/trunk/libs/libresample/libresample.xcodeproj/
freeswitch/branches/knhor/trunk/libs/libresample/libresample.xcodeproj/project.pbxproj
- copied unchanged from r3850, /freeswitch/trunk/libs/libresample/libresample.xcodeproj/project.pbxproj
freeswitch/branches/knhor/trunk/libs/libteletone/libteletone-Info.plist
- copied unchanged from r3850, /freeswitch/trunk/libs/libteletone/libteletone-Info.plist
freeswitch/branches/knhor/trunk/libs/libteletone/libteletone.xcodeproj/
- copied from r3850, /freeswitch/trunk/libs/libteletone/libteletone.xcodeproj/
freeswitch/branches/knhor/trunk/libs/libteletone/libteletone.xcodeproj/project.pbxproj
- copied unchanged from r3850, /freeswitch/trunk/libs/libteletone/libteletone.xcodeproj/project.pbxproj
Modified:
freeswitch/branches/knhor/trunk/ (props changed)
freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
Log:
Merged revisions 3841-3850 via svnmerge from trunk
Modified: freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c (original)
+++ freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Wed Dec 27 13:49:11 2006
@@ -391,7 +391,7 @@
static switch_status_t chat_send(char *proto, char *from, char *to, char *subject, char *body, char *hint)
{
- char *user, *host, *f_user = NULL, *ffrom = NULL, *f_host = NULL;
+ char *user, *host, *f_user = NULL, *ffrom = NULL, *f_host = NULL, *f_resource = NULL;
struct mdl_profile *profile = NULL;
assert(proto != NULL);
@@ -399,6 +399,9 @@
if (from && (f_user = strdup(from))) {
if ((f_host = strchr(f_user, '@'))) {
*f_host++ = '\0';
+ if ((f_resource = strchr(f_host, '/'))) {
+ *f_resource++ = '\0';
+ }
}
}
Modified: freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Wed Dec 27 13:49:11 2006
@@ -1612,13 +1612,13 @@
if (tech_pvt->read_frame.datalen > 0) {
size_t bytes = 0;
- int frames = 0;
+ int frames = 1;
//tech_pvt->last_read = switch_time_now();
if (!switch_test_flag((&tech_pvt->read_frame), SFF_CNG)) {
if ((bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame)) {
frames = (tech_pvt->read_frame.datalen / bytes);
- tech_pvt->read_frame.samples = (int) (frames * tech_pvt->read_codec.implementation->samples_per_frame);
}
+ tech_pvt->read_frame.samples = (int) (frames * tech_pvt->read_codec.implementation->samples_per_frame);
}
break;
}
1
0
[commit] r3841 - in freeswitch/branches/knhor/trunk: . mac/xcode mac/xcode/FreeSWITCH.xcodeproj src src/mod/languages/mod_perl
by Freeswitch SVN 27 Dec '06
by Freeswitch SVN 27 Dec '06
27 Dec '06
Author: knhor
Date: Wed Dec 27 01:20:37 2006
New Revision: 3841
Removed:
freeswitch/branches/knhor/trunk/mac/xcode/FreeSWITCH.xcodeproj/
freeswitch/branches/knhor/trunk/mac/xcode/Loadable Bundle.trgttmpl
freeswitch/branches/knhor/trunk/mac/xcode/apr.plist
freeswitch/branches/knhor/trunk/mac/xcode/aprutil.plist
freeswitch/branches/knhor/trunk/mac/xcode/dingaling.plist
freeswitch/branches/knhor/trunk/mac/xcode/exosip2.plist
freeswitch/branches/knhor/trunk/mac/xcode/gsm.plist
freeswitch/branches/knhor/trunk/mac/xcode/iax.plist
freeswitch/branches/knhor/trunk/mac/xcode/iksemel.plist
freeswitch/branches/knhor/trunk/mac/xcode/ilbc.plist
freeswitch/branches/knhor/trunk/mac/xcode/libfreeswitch.plist
freeswitch/branches/knhor/trunk/mac/xcode/osip2.plist
freeswitch/branches/knhor/trunk/mac/xcode/osipparser2.plist
freeswitch/branches/knhor/trunk/mac/xcode/pcre.plist
freeswitch/branches/knhor/trunk/mac/xcode/portaudio.plist
freeswitch/branches/knhor/trunk/mac/xcode/resample.plist
freeswitch/branches/knhor/trunk/mac/xcode/sndfile.plist
freeswitch/branches/knhor/trunk/mac/xcode/speakup.plist
freeswitch/branches/knhor/trunk/mac/xcode/speex.plist
freeswitch/branches/knhor/trunk/mac/xcode/sqlite.plist
freeswitch/branches/knhor/trunk/mac/xcode/srtp.plist
freeswitch/branches/knhor/trunk/mac/xcode/teletone.plist
Modified:
freeswitch/branches/knhor/trunk/ (props changed)
freeswitch/branches/knhor/trunk/src/mod/languages/mod_perl/switch_swig_wrap.c
freeswitch/branches/knhor/trunk/src/switch_swig.c
Log:
Merged revisions 3826-3840 via svnmerge from trunk
Modified: freeswitch/branches/knhor/trunk/src/mod/languages/mod_perl/switch_swig_wrap.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/mod/languages/mod_perl/switch_swig_wrap.c (original)
+++ freeswitch/branches/knhor/trunk/src/mod/languages/mod_perl/switch_swig_wrap.c Wed Dec 27 01:20:37 2006
@@ -15,6 +15,7 @@
* clashes if multiple interpreters are included
*
************************************************************************/
+#include <switch.h>
#define SWIG_TypeRegister SWIG_Perl_TypeRegister
#define SWIG_TypeCheck SWIG_Perl_TypeCheck
Modified: freeswitch/branches/knhor/trunk/src/switch_swig.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/switch_swig.c (original)
+++ freeswitch/branches/knhor/trunk/src/switch_swig.c Wed Dec 27 01:20:37 2006
@@ -158,29 +158,26 @@
*/
int fs_ivr_play_file(switch_core_session_t *session,
- char *file)
+ switch_file_handle_t *fh,
+ char *file,
+ switch_input_args_t *args)
{
switch_status_t status;
- if (switch_strlen_zero(timer_name)) {
- timer_name = NULL;
- }
- status = switch_ivr_play_file(session, NULL, file, NULL);
+ status = switch_ivr_play_file(session, fh, file, args);
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
int fs_switch_ivr_record_file(switch_core_session_t *session,
switch_file_handle_t *fh,
char *file,
- switch_input_callback_function_t dtmf_callback,
- void *buf,
- unsigned int buflen,
+ switch_input_args_t *args,
unsigned int limit
)
{
switch_status_t status;
- status = switch_ivr_record_file(session, fh, file, dtmf_callback, buf, buflen, limit);
+ status = switch_ivr_record_file(session, fh, file, args, limit);
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
@@ -198,20 +195,18 @@
{
switch_status_t status;
- status = switch_ivr_play_file(session, NULL, file, NULL, NULL);
+ status = switch_ivr_play_file(session, NULL, file, NULL);
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
int fs_switch_ivr_collect_digits_callback (switch_core_session_t *session,
- switch_input_callback_function_t dtmf_callback,
- void *buf,
- unsigned int buflen,
+ switch_input_args_t *args,
unsigned int timeout)
{
switch_status_t status;
- status = switch_ivr_collect_digits_callback(session, dtmf_callback, buf, buflen, timeout);
+ status = switch_ivr_collect_digits_callback(session, args, timeout);
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
1
0
27 Dec '06
Author: knhor
Date: Wed Dec 27 01:12:20 2006
New Revision: 3840
Modified:
freeswitch/branches/knhor/trunk/libs/libdingaling/src/libdingaling.c
Log:
define STRIP_HTML_TAGS if you want to always strip html tags from the msg body
Modified: freeswitch/branches/knhor/trunk/libs/libdingaling/src/libdingaling.c
==============================================================================
--- freeswitch/branches/knhor/trunk/libs/libdingaling/src/libdingaling.c (original)
+++ freeswitch/branches/knhor/trunk/libs/libdingaling/src/libdingaling.c Wed Dec 27 01:12:20 2006
@@ -1649,6 +1649,8 @@
}
+/* define this if you want to always strip html tags from the msg body */
+/* #define STRIP_HTML_TAGS */
void ldl_handle_send_msg(ldl_handle_t *handle, char *from, char *to, char *subject, char *body)
{
iks *msg;
@@ -1658,7 +1660,8 @@
int len = 0;
assert(handle != NULL);
assert(body != NULL);
-
+
+#ifdef STRIP_HTML_TAGS
if (strchr(body, '<')) {
len = (int) strlen(body);
if (!(bdup = malloc(len))) {
@@ -1682,6 +1685,7 @@
}
body = bdup;
}
+#endif
msg = iks_make_msg(IKS_TYPE_NONE, to, body);
iks_insert_attrib(msg, "type", "chat");
1
0
[commit] r3839 - freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference
by Freeswitch SVN 27 Dec '06
by Freeswitch SVN 27 Dec '06
27 Dec '06
Author: knhor
Date: Wed Dec 27 01:02:24 2006
New Revision: 3839
Modified:
freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c
Log:
clean up the conf_api_dispatch and conf_api_sub_xxx argument handling.
commonize the code to get xml section pointers.
enhance chat's list output w/ more caller info.
reformatted the conf_api_sub_commands table so that it is readable, please leave it that way.
alphabetically sorted the conf_api_sub_commands table.
Modified: freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c Wed Dec 27 01:02:24 2006
@@ -54,6 +54,9 @@
/* this doesn't work correctly yet, don't bother trying! */
//#define OPTION_IVR_MENU_SUPPORT */
+/* define this if you want your xmpp users to be able to admin the conferences via chat */
+//#define ENABLE_CHAT_ADMIN
+
typedef enum {
FILE_STOP_CURRENT,
FILE_STOP_ALL
@@ -149,11 +152,13 @@
/* conference xml config sections */
typedef struct conf_xml_cfg {
+ switch_xml_t cxml;
switch_xml_t profile;
switch_xml_t controls;
#ifdef OPTION_IVR_MENU_SUPPORT
switch_xml_t menus;
#endif
+// switch_xml_t chat_admin;
} conf_xml_cfg_t;
/* Conference Object */
@@ -193,6 +198,8 @@
uint32_t count;
int32_t energy_level;
uint8_t min;
+// switch_hash_t *chat_admin;
+// switch_hash_t *chat_id;
} conference_obj_t;
/* Relationship with another member */
@@ -312,6 +319,7 @@
static switch_status_t conf_api_sub_undeaf(conference_member_t *member,
switch_stream_handle_t *stream,
void *data);
+static switch_status_t conference_get_xml_sections(char *profile_name, conf_xml_cfg_t *xml_cfg);
/* Return a Distinct ID # */
static uint32_t next_member_id(void)
@@ -368,17 +376,18 @@
conference_member_t *member = NULL;
assert(conference != NULL);
- assert(id != 0);
- for(member = conference->members; member; member = member->next) {
-
- if (switch_test_flag(member, MFLAG_NOCHANNEL)) {
- continue;
- }
-
- if (member->id == id) {
- break;
- }
+ if (id != 0) {
+ for(member = conference->members; member; member = member->next) {
+
+ if (switch_test_flag(member, MFLAG_NOCHANNEL)) {
+ continue;
+ }
+
+ if (member->id == id) {
+ break;
+ }
+ }
}
@@ -394,7 +403,7 @@
assert (conference != NULL);
for(member = conference->members; member; member = member->next) {
- if (switch_test_flag(member, MFLAG_NOCHANNEL) && (!path || !strcmp(path, member->rec_path))) {
+ if (switch_test_flag(member, MFLAG_NOCHANNEL) && (path == NULL || !strcmp(path, member->rec_path))) {
switch_clear_flag_locked(member, MFLAG_RUNNING);
count++;
}
@@ -521,9 +530,6 @@
assert(conference != NULL);
assert(member != NULL);
-
-
-
switch_mutex_lock(conference->mutex);
switch_mutex_lock(conference->member_mutex);
@@ -1202,8 +1208,6 @@
if (lbuf != NULL) {
memset(argv, 0, sizeof(argv));
argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "dial argc %u 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
- argc, argv[0], argv[1], argv[2], argv[3]);
if (argc >= 4) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "executing conference outcall\n");
conference_outcall(member->conference, NULL, argv[0], atoi(argv[1]), NULL, argv[3], argv[2]);
@@ -2122,7 +2126,6 @@
assert(stream != NULL);
switch_mutex_lock(conference->member_mutex);
- // stream->write_function(stream, "<pre>Current Callers:\n");
for (member = conference->members; member; member = member->next) {
switch_channel_t *channel;
@@ -2135,11 +2138,15 @@
profile = switch_channel_get_caller_profile(channel);
- stream->write_function(stream, "%u) %s (%s)\n",
+ stream->write_function(stream, "%u) %s (%s) - %s/%s - %d/%d/%d\n",
member->id,
profile->caller_id_name,
- profile->caller_id_number
- );
+ profile->caller_id_number,
+ (switch_test_flag(member, MFLAG_CAN_HEAR) ? "hear" : "deaf"),
+ (switch_test_flag(member, MFLAG_CAN_SPEAK) ? "speak" : "mute"),
+ member->volume_in_level,
+ member->volume_out_level,
+ member->energy_level);
}
@@ -2481,11 +2488,10 @@
void *val;
char *d = ";";
int pretty = 0;
- int argofs = (argc >= 2 && strcasecmp(argv[1], "list") == 0); // detect being called from chat vs. api
- if (argv[1+argofs]) {
- if (argv[2+argofs] && !strcasecmp(argv[1+argofs], "delim")) {
- d = argv[2+argofs];
+ if (argv[1]) {
+ if (argv[2] && !strcasecmp(argv[1], "delim")) {
+ d = argv[2];
if (*d == '"') {
if (++d) {
@@ -2497,7 +2503,7 @@
d = ";";
}
}
- } else if (strcasecmp(argv[1+argofs], "pretty") == 0) {
+ } else if (strcasecmp(argv[1], "pretty") == 0) {
pretty = 1;
}
}
@@ -2507,10 +2513,12 @@
switch_hash_this(hi, NULL, NULL, &val);
conference = (conference_obj_t *) val;
- stream->write_function(stream, "Conference %s (%u member%s)\n",
+ stream->write_function(stream, "Conference %s (%u member%s, %s)\n",
conference->name,
conference->count,
- conference->count == 1 ? "" : "s");
+ conference->count == 1 ? "" : "s",
+ (switch_test_flag(conference, CFLAG_LOCKED) ? "locked" : "unlocked")
+ );
if (pretty) {
conference_list_pretty(conference, stream);
} else {
@@ -2539,35 +2547,35 @@
assert(stream != NULL);
- if (argc == 3) {
- if (conference_play_file(conference, argv[2], 0, NULL) == SWITCH_STATUS_SUCCESS) {
- stream->write_function(stream, "(play) Playing file %s\n", argv[2]);
+ if (argc == 1) {
+ if (conference_play_file(conference, argv[0], 0, NULL) == SWITCH_STATUS_SUCCESS) {
+ stream->write_function(stream, "(play) Playing file %s\n", argv[0]);
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "play-file");
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "File", argv[2]);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "File", argv[0]);
switch_event_fire(&event);
}
} else {
- stream->write_function(stream, "(play) File: %s not found.\n", argv[2] ? argv[2] : "(unspecified)");
+ stream->write_function(stream, "(play) File: %s not found.\n", argv[0] ? argv[0] : "(unspecified)");
}
ret_status = SWITCH_STATUS_SUCCESS;
- } else if (argc == 4) {
- uint32_t id = atoi(argv[3]);
+ } else if (argc >= 2) {
+ uint32_t id = atoi(argv[1]);
conference_member_t *member;
if ((member = conference_member_get(conference, id))) {
- if (conference_member_play_file(member, argv[2], 0) == SWITCH_STATUS_SUCCESS) {
- stream->write_function(stream, "(play) Playing file %s to member %u\n", argv[2], id);
+ if (conference_member_play_file(member, argv[0], 0) == SWITCH_STATUS_SUCCESS) {
+ stream->write_function(stream, "(play) Playing file %s to member %u\n", argv[0], id);
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", id);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "play-file-member");
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "File", argv[2]);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "File", argv[0]);
switch_event_fire(&event);
}
} else {
- stream->write_function(stream, "(play) File: %s not found.\n", argv[2] ? argv[2] : "(unspecified)");
+ stream->write_function(stream, "(play) File: %s not found.\n", argv[0] ? argv[0] : "(unspecified)");
}
ret_status = SWITCH_STATUS_SUCCESS;
} else {
@@ -2677,14 +2685,14 @@
assert(conference != NULL);
assert(stream != NULL);
- if (argc > 2) {
- current = strcasecmp(argv[2], "current") ? 0 : 1;
- all = strcasecmp(argv[2], "all") ? 0 : 1;
+ if (argc >= 1) {
+ current = strcasecmp(argv[0], "current") ? 0 : 1;
+ all = strcasecmp(argv[0], "all") ? 0 : 1;
}
if (current || all) {
- if (argc == 4) {
- uint32_t id = atoi(argv[3]);
+ if (argc >= 2) {
+ uint32_t id = atoi(argv[1]);
conference_member_t *member;
if ((member = conference_member_get(conference, id))) {
@@ -2711,14 +2719,10 @@
assert(conference != NULL);
assert(stream != NULL);
- if (argc > 4) {
- uint8_t nospeak = 0, nohear = 0, clear = 0;
- nospeak = strstr(argv[4], "nospeak") ? 1 : 0;
- nohear = strstr(argv[4], "nohear") ? 1 : 0;
-
- if (!strcasecmp(argv[4], "clear")) {
- clear = 1;
- }
+ if (argc > 2) {
+ uint8_t clear = (strcasecmp(argv[2], "clear") == 0);
+ uint8_t nospeak = (strstr(argv[2], "nospeak") != NULL);
+ uint8_t nohear = (strstr(argv[2], "nohear") != NULL);
if (!(clear || nospeak || nohear)) {
ret_status = SWITCH_STATUS_GENERR;
@@ -2728,8 +2732,8 @@
if (clear) {
conference_member_t *member = NULL;
- uint32_t id = atoi(argv[2]);
- uint32_t oid = atoi(argv[3]);
+ uint32_t id = atoi(argv[0]);
+ uint32_t oid = atoi(argv[1]);
switch_mutex_lock(conference->mutex);
switch_mutex_lock(conference->member_mutex);
@@ -2743,8 +2747,8 @@
switch_mutex_unlock(conference->mutex);
} else if (nospeak || nohear) {
conference_member_t *member = NULL, *other_member = NULL;
- uint32_t id = atoi(argv[2]);
- uint32_t oid = atoi(argv[3]);
+ uint32_t id = atoi(argv[0]);
+ uint32_t oid = atoi(argv[1]);
switch_mutex_lock(conference->mutex);
switch_mutex_lock(conference->member_mutex);
@@ -2788,7 +2792,7 @@
assert(stream != NULL);
switch_set_flag_locked(conference, CFLAG_LOCKED);
- stream->write_function(stream, "OK %s locked\n", argv[0]);
+ stream->write_function(stream, "OK %s locked\n", conference->name);
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "lock");
@@ -2806,7 +2810,7 @@
assert(stream != NULL);
switch_clear_flag_locked(conference, CFLAG_LOCKED);
- stream->write_function(stream, "OK %s unlocked\n", argv[0]);
+ stream->write_function(stream, "OK %s unlocked\n", conference->name);
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "unlock");
@@ -2824,8 +2828,8 @@
assert(conference != NULL);
assert(stream != NULL);
- if (argc > 2) {
- conference_outcall(conference, NULL, argv[2], 60, NULL, argv[4], argv[3]);
+ if (argc >= 1) {
+ conference_outcall(conference, NULL, argv[0], 60, NULL, (argc >= 3 ?argv[2] : NULL), (argc >=2 ? argv[1] : NULL));
stream->write_function(stream, "OK\n");
} else {
ret_status = SWITCH_STATUS_GENERR;
@@ -2841,17 +2845,15 @@
assert(conference != NULL);
assert(stream != NULL);
- if (argc > 3 && !switch_strlen_zero(argv[2])) {
+ if (argc >= 2 && !switch_strlen_zero(argv[0])) {
int x;
- for (x = 3; x<argc; x++) {
+ for (x = 1; x<argc; x++) {
conference_member_t *member = NULL;
uint32_t id = atoi(argv[x]);
conference_obj_t *new_conference = NULL;
switch_channel_t *channel;
switch_event_t *event;
- char *profile_name;
- switch_xml_t cxml = NULL, cfg = NULL, profiles = NULL;
if (!(member = conference_member_get(conference, id))) {
stream->write_function(stream, "No Member %u in conference %s.\n", id, conference->name);
@@ -2861,10 +2863,11 @@
channel = switch_core_session_get_channel(member->session);
/* build a new conference if it doesn't exist */
- if (!(new_conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, argv[2]))) {
+ if (!(new_conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, argv[0]))) {
switch_memory_pool_t *pool = NULL;
+ conf_xml_cfg_t xml_cfg = {0};
char *conf_name;
- conf_xml_cfg_t xml_cfg = {0};
+ char *profile_name;
/* Setup a memory pool to use. */
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
@@ -2872,35 +2875,26 @@
goto done;
}
- conf_name = switch_core_strdup(pool, argv[2]);
+ conf_name = switch_core_strdup(pool, argv[0]);
if ((profile_name = strchr(conf_name, '@'))) {
*profile_name++ = '\0';
- /* Open the config from the xml registry */
- if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, NULL))) {
+ /* get the xml config sections */
+ if (conference_get_xml_sections(profile_name, &xml_cfg) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
goto done;
}
-
- if ((profiles = switch_xml_child(cfg, "profiles"))) {
- xml_cfg.profile = switch_xml_find_child(profiles, "profile", "name", profile_name);
- }
- xml_cfg.controls = switch_xml_child(cfg, "caller-controls");
-#ifdef OPTION_IVR_MENU_SUPPORT
- xml_cfg.menus = switch_xml_child(cfg, "menus");
-#endif
}
- /* Release the config registry handle */
- if (cxml) {
- switch_xml_free(cxml);
- cxml = NULL;
- }
-
/* Create the conference object. */
new_conference = conference_new(conf_name, xml_cfg, pool);
+ /* Release the config registry handle */
+ if (xml_cfg.cxml) {
+ switch_xml_free(xml_cfg.cxml);
+ }
+
if (!new_conference) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
if (pool != NULL) {
@@ -2923,14 +2917,14 @@
conference_del_member(member->last_conference, member);
conference_add_member(new_conference, member);
- stream->write_function(stream, "OK Members sent to conference %s.\n", argv[2]);
+ stream->write_function(stream, "OK Member %u sent to conference %s.\n", member->id, argv[0]);
/* tell them what happened */
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(channel, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Old-Conference-Name", conference->name);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Conference-Name", argv[3]);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Conference-Name", argv[0]);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "transfer");
switch_event_fire(&event);
}
@@ -2949,8 +2943,8 @@
assert(conference != NULL);
assert(stream != NULL);
- if (argc > 2) {
- launch_conference_record_thread(conference, argv[2]);
+ if (argc >= 1) {
+ launch_conference_record_thread(conference, argv[0]);
} else {
ret_status = SWITCH_STATUS_GENERR;
}
@@ -2965,11 +2959,11 @@
assert(conference != NULL);
assert(stream != NULL);
- if (argc > 2) {
- int all = (strcasecmp(argv[2], "all") == 0 );
+ if (argc >= 1) {
+ int all = (strcasecmp(argv[0], "all") == 0 );
- if (!conference_record_stop(conference, all ? NULL : argv[2]) && !all) {
- stream->write_function(stream, "non-existant recording '%s'\n", argv[2]);
+ if (!conference_record_stop(conference, (all ? NULL : argv[0])) && !all) {
+ stream->write_function(stream, "non-existant recording '%s'\n", argv[0]);
}
} else {
ret_status = SWITCH_STATUS_GENERR;
@@ -2980,31 +2974,31 @@
/* API Interface Function sub-commands */
static api_command_t conf_api_sub_commands[] = {
- {"list", &conf_api_sub_list, CONF_API_SUB_ARGS_SPLIT, "<confname> list [delim <string>]"},
- {"energy", &conf_api_sub_energy, CONF_API_SUB_MEMBER_TARGET, "<confname> energy <member_id|all|last> [<newval>]"},
- {"volume_in", &conf_api_sub_volume_in, CONF_API_SUB_MEMBER_TARGET, "<confname> volume_in <member_id|all|last> [<newval>]"},
- {"volume_out", &conf_api_sub_volume_out, CONF_API_SUB_MEMBER_TARGET, "<confname> volume_out <member_id|all|last> [<newval>]"},
- {"play", &conf_api_sub_play, CONF_API_SUB_ARGS_SPLIT, "<confname> play <file_path> [<member_id>]"},
- {"say", &conf_api_sub_say, CONF_API_SUB_ARGS_AS_ONE, "<confname> say <text>"},
- {"saymember", &conf_api_sub_saymember, CONF_API_SUB_ARGS_AS_ONE, "<confname> saymember <member_id> <text>"},
- {"stop", &conf_api_sub_stop, CONF_API_SUB_MEMBER_TARGET, "<confname> stop <[current|all|last]> [<member_id>]"},
- {"kick", &conf_api_sub_kick, CONF_API_SUB_MEMBER_TARGET, "<confname> kick <[member_id|all|last]>"},
- {"mute", &conf_api_sub_mute, CONF_API_SUB_MEMBER_TARGET, "<confname> mute <[member_id|all]|last>"},
- {"unmute", &conf_api_sub_unmute, CONF_API_SUB_MEMBER_TARGET, "<confname> unmute <[member_id|all]|last>"},
- {"deaf", &conf_api_sub_deaf, CONF_API_SUB_MEMBER_TARGET, "<confname> deaf <[member_id|all]|last>"},
- {"undeaf", &conf_api_sub_undeaf, CONF_API_SUB_MEMBER_TARGET, "<confname> undeaf <[member_id|all]|last>"},
- {"relate", &conf_api_sub_relate, CONF_API_SUB_ARGS_SPLIT, "<confname> relate <member_id> <other_member_id> [nospeak|nohear|clear]"},
- {"lock", &conf_api_sub_lock, CONF_API_SUB_ARGS_SPLIT, "<confname> lock"},
- {"unlock", &conf_api_sub_unlock, CONF_API_SUB_ARGS_SPLIT, "<confname> unlock"},
- {"dial", &conf_api_sub_dial, CONF_API_SUB_ARGS_SPLIT, "<confname> dial <endpoint_module_name>/<destination> <callerid number> <callerid name>"},
- {"transfer", &conf_api_sub_transfer, CONF_API_SUB_ARGS_SPLIT, "<confname> transfer <conference_name> <member id> [...<member id>]"},
- {"record", &conf_api_sub_record, CONF_API_SUB_ARGS_SPLIT, "<confname> record <filename>"},
- {"norecord", &conf_api_sub_norecord, CONF_API_SUB_ARGS_SPLIT, "<confname> norecord <[filename|all]>"},
+ {"deaf", &conf_api_sub_deaf, CONF_API_SUB_MEMBER_TARGET, "<confname> deaf <[member_id|all]|last>"},
+ {"dial", &conf_api_sub_dial, CONF_API_SUB_ARGS_SPLIT, "<confname> dial <endpoint_module_name>/<destination> <callerid number> <callerid name>"},
+ {"energy", &conf_api_sub_energy, CONF_API_SUB_MEMBER_TARGET, "<confname> energy <member_id|all|last> [<newval>]"},
+ {"kick", &conf_api_sub_kick, CONF_API_SUB_MEMBER_TARGET, "<confname> kick <[member_id|all|last]>"},
+ {"list", &conf_api_sub_list, CONF_API_SUB_ARGS_SPLIT, "<confname> list [delim <string>]"},
+ {"lock", &conf_api_sub_lock, CONF_API_SUB_ARGS_SPLIT, "<confname> lock"},
+ {"mute", &conf_api_sub_mute, CONF_API_SUB_MEMBER_TARGET, "<confname> mute <[member_id|all]|last>"},
+ {"norecord", &conf_api_sub_norecord, CONF_API_SUB_ARGS_SPLIT, "<confname> norecord <[filename|all]>"},
+ {"play", &conf_api_sub_play, CONF_API_SUB_ARGS_SPLIT, "<confname> play <file_path> [<member_id>]"},
+ {"record", &conf_api_sub_record, CONF_API_SUB_ARGS_SPLIT, "<confname> record <filename>"},
+ {"relate", &conf_api_sub_relate, CONF_API_SUB_ARGS_SPLIT, "<confname> relate <member_id> <other_member_id> [nospeak|nohear|clear]"},
+ {"say", &conf_api_sub_say, CONF_API_SUB_ARGS_AS_ONE, "<confname> say <text>"},
+ {"saymember", &conf_api_sub_saymember, CONF_API_SUB_ARGS_AS_ONE, "<confname> saymember <member_id> <text>"},
+ {"stop", &conf_api_sub_stop, CONF_API_SUB_MEMBER_TARGET, "<confname> stop <[current|all|last]> [<member_id>]"},
+ {"transfer", &conf_api_sub_transfer, CONF_API_SUB_ARGS_SPLIT, "<confname> transfer <conference_name> <member id> [...<member id>]"},
+ {"undeaf", &conf_api_sub_undeaf, CONF_API_SUB_MEMBER_TARGET, "<confname> undeaf <[member_id|all]|last>"},
+ {"unlock", &conf_api_sub_unlock, CONF_API_SUB_ARGS_SPLIT, "<confname> unlock"},
+ {"unmute", &conf_api_sub_unmute, CONF_API_SUB_MEMBER_TARGET, "<confname> unmute <[member_id|all]|last>"},
+ {"volume_in", &conf_api_sub_volume_in, CONF_API_SUB_MEMBER_TARGET, "<confname> volume_in <member_id|all|last> [<newval>]"},
+ {"volume_out", &conf_api_sub_volume_out, CONF_API_SUB_MEMBER_TARGET, "<confname> volume_out <member_id|all|last> [<newval>]"},
};
#define CONFFUNCAPISIZE (sizeof(conf_api_sub_commands)/sizeof(conf_api_sub_commands[0]))
-switch_status_t conf_api_dispatch(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv, const char *cmdline, int argn)
+switch_status_t conf_api_dispatch(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv, const char *cmdline)
{
switch_status_t status = SWITCH_STATUS_FALSE;
uint32_t i, found = 0;
@@ -3013,7 +3007,7 @@
/* loop through the command table to find a match */
for (i = 0; i<CONFFUNCAPISIZE && !found; i++) {
- if (strcasecmp(argv[argn], conf_api_sub_commands[i].pname) == 0) {
+ if (strcasecmp(argv[0], conf_api_sub_commands[i].pname) == 0) {
found = 1;
switch(conf_api_sub_commands[i].fntype) {
@@ -3021,7 +3015,7 @@
case CONF_API_SUB_ARGS_SPLIT:
{ conf_api_args_cmd_t pfn = (conf_api_args_cmd_t)conf_api_sub_commands[i].pfnapicmd;
- if (pfn(conference, stream, argc, argv) != SWITCH_STATUS_SUCCESS) {
+ if (pfn(conference, stream, argc-1, argv+1) != SWITCH_STATUS_SUCCESS) {
/* command returned error, so show syntax usage */
stream->write_function(stream, conf_api_sub_commands[i].psyntax);
}
@@ -3030,20 +3024,19 @@
/* member specific command that can be itteratted */
case CONF_API_SUB_MEMBER_TARGET:
- {
- uint32_t id = atoi(argv[argn+1]);
- int all = ( id == 0 && strcasecmp(argv[argn+1], "all") == 0 );
- int last = ( id == 0 && strcasecmp(argv[argn+1], "last") == 0 );
+ if (argc > 1) {
+ uint32_t id = atoi(argv[1]);
+ int all = ( id == 0 && strcasecmp(argv[1], "all") == 0 );
+ int last = ( id == 0 && strcasecmp(argv[1], "last") == 0 );
if (all) {
- conference_member_itterator(conference, stream, conf_api_sub_commands[i].pfnapicmd, argv[argn+2]);
+ conference_member_itterator(conference, stream, conf_api_sub_commands[i].pfnapicmd, argv[2]);
} else if (last) {
conference_member_t *member = NULL;
conference_member_t *last_member = NULL;
+ /* find last (newest) member */
switch_mutex_lock(conference->member_mutex);
-
- /* find last (oldest) member */
member = conference->members;
while (member != NULL) {
if (last_member == NULL || member->id > last_member->id) {
@@ -3051,20 +3044,19 @@
}
member = member->next;
}
+ switch_mutex_unlock(conference->member_mutex);
- /* exec functio on last (oldest) member */
+ /* exec function on last (newest) member */
if (last_member != NULL) {
conf_api_member_cmd_t pfn = (conf_api_member_cmd_t)conf_api_sub_commands[i].pfnapicmd;
- pfn(last_member, stream, argv[argn+2]);
+ pfn(last_member, stream, (argc > 2 ? argv[2] : NULL));
}
-
- switch_mutex_unlock(conference->member_mutex);
} else {
conf_api_member_cmd_t pfn = (conf_api_member_cmd_t)conf_api_sub_commands[i].pfnapicmd;
conference_member_t *member = conference_member_get(conference, id);
if (member != NULL) {
- pfn(conference_member_get(conference, id), stream, argv[argn+2]);
+ pfn(member, stream, (argc > 2 ? argv[2] : NULL));
} else {
if (id == 0) {
stream->write_function(stream, conf_api_sub_commands[i].psyntax);
@@ -3073,7 +3065,9 @@
}
}
}
- }
+ } else {
+ stream->write_function(stream, conf_api_sub_commands[i].psyntax);
+ }
break;
/* commands that deals with all text after command */
@@ -3103,7 +3097,7 @@
}
if (!found) {
- stream->write_function(stream, "Confernece command '%s' not found.\n", argv[argn]);
+ stream->write_function(stream, "Confernece command '%s' not found.\n", argv[0]);
} else {
status = SWITCH_STATUS_SUCCESS;
}
@@ -3153,7 +3147,8 @@
}
if (argc >= 2) {
- conf_api_dispatch(conference, stream, argc, argv, (const char *)buf, 1);
+ /* call the command dispatcher after left shifting the command line */
+ conf_api_dispatch(conference, stream, argc-1, argv+1, (const char *)buf);
} else {
stream->write_function(stream, "Conference command, not specified.\nTry 'help'\n");
}
@@ -3164,8 +3159,10 @@
/* special case the list command, because it doesn't require a conference argument */
if (strcasecmp(argv[0], "list") == 0) {
conf_api_sub_list(NULL, stream, argc, argv);
+ /* provide help */
} else if (strcasecmp(argv[0], "help") == 0 || strcasecmp(argv[0], "commands") == 0) {
stream->write_function(stream, "%s\n", conf_api_interface.syntax);
+ /* failure */
} else {
stream->write_function(stream, "Conference %s not found\n", argv[0]);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Conference %s not found\n", argv[0]);
@@ -3334,6 +3331,31 @@
return status;
}
+static switch_status_t conference_get_xml_sections(char *profile_name, conf_xml_cfg_t *xml_cfg)
+{
+ switch_status_t status = SWITCH_STATUS_FALSE;
+
+ if (!switch_strlen_zero(profile_name) && xml_cfg != NULL) {
+ switch_xml_t cfg = NULL, profiles = NULL;
+
+ xml_cfg->cxml = switch_xml_open_cfg(global_cf_name, &cfg, NULL);
+
+ if (xml_cfg->cxml != NULL) {
+ if ((profiles = switch_xml_child(cfg, "profiles"))) {
+ xml_cfg->profile = switch_xml_find_child(profiles, "profile", "name", profile_name);
+ }
+ xml_cfg->controls = switch_xml_child(cfg, "caller-controls");
+#ifdef OPTION_IVR_MENU_SUPPORT
+ xml_cfg->menus = switch_xml_child(cfg, "menus");
+#endif
+// xml_cfg->chat_admin = switch_xml_child(cfg, "chat-admin");
+ status = SWITCH_STATUS_SUCCESS;
+ }
+ }
+
+ return status;
+}
+
/* Application interface function that is called from the dialplan to join the channel to a conference */
static void conference_function(switch_core_session_t *session, char *data)
{
@@ -3349,7 +3371,6 @@
char *flags_prefix = "+flags{";
char *bridgeto = NULL;
char *profile_name = NULL;
- switch_xml_t cxml = NULL, cfg = NULL, profiles = NULL;
char *flags_str;
member_flag_t uflags = MFLAG_CAN_SPEAK | MFLAG_CAN_HEAR;
switch_core_session_message_t msg = {0};
@@ -3411,20 +3432,11 @@
if ((profile_name = strchr(conf_name, '@'))) {
*profile_name++ = '\0';
- /* Open the config from the xml registry */
- if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, NULL))) {
+ /* get the xml config sections */
+ if (conference_get_xml_sections(profile_name, &xml_cfg) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
goto done;
}
-
- if ((profiles = switch_xml_child(cfg, "profiles"))) {
- xml_cfg.profile = switch_xml_find_child(profiles, "profile", "name", profile_name);
- }
-
- xml_cfg.controls = switch_xml_child(cfg, "caller-controls");
-#ifdef OPTION_IVR_MENU_SUPPORT
- xml_cfg.menus = switch_xml_child(cfg, "menus");
-#endif
}
/* if this is a bridging call, and it's not a duplicate, build a */
@@ -3557,9 +3569,9 @@
}
/* Release the config registry handle */
- if (cxml) {
- switch_xml_free(cxml);
- cxml = NULL;
+ if (xml_cfg.cxml) {
+ switch_xml_free(xml_cfg.cxml);
+ xml_cfg.cxml = NULL;
}
/* if we're using "bridge:" make an outbound call and bridge it in */
@@ -3693,8 +3705,8 @@
switch_buffer_destroy(&member.mux_buffer);
/* Release the config registry handle */
- if (cxml) {
- switch_xml_free(cxml);
+ if (xml_cfg.cxml) {
+ switch_xml_free(xml_cfg.cxml);
}
if (freepool) {
@@ -3816,16 +3828,20 @@
if (argc) {
/* special case list */
if (strcasecmp(argv[0], "list") == 0) {
+ stream.write_function(&stream, "(%u member%s, %s)\n",
+ conference->count,
+ conference->count == 1 ? "" : "s",
+ (switch_test_flag(conference, CFLAG_LOCKED) ? "locked" : "unlocked")
+ );
conference_list_pretty(conference, &stream);
- /* provide help */
- }
- else {
- if (strcasecmp(argv[0], "help") == 0 || strcasecmp(argv[0], "commands") == 0) {
+#ifdef ENABLE_CHAT_ADMIN
+ /* provide help */
+ } else if (strcasecmp(argv[0], "help") == 0 || strcasecmp(argv[0], "commands") == 0) {
stream.write_function(&stream, "%s\n", conf_api_interface.syntax);
- /* find a normal command */
- } else {
- conf_api_dispatch(conference, &stream, argc, argv, (const char *)body, 0);
- }
+ /* find a normal command */
+ } else {
+ conf_api_dispatch(conference, &stream, argc, argv, (const char *)body);
+#endif
}
} else {
stream.write_function(&stream, "No parameters specified.\nTry 'help'\n");
1
0
Author: knhor
Date: Tue Dec 26 23:28:49 2006
New Revision: 3838
Modified:
freeswitch/branches/knhor/trunk/conf/freeswitch.xml
Log:
explicit comments about the resrved caller control group names
Modified: freeswitch/branches/knhor/trunk/conf/freeswitch.xml
==============================================================================
--- freeswitch/branches/knhor/trunk/conf/freeswitch.xml (original)
+++ freeswitch/branches/knhor/trunk/conf/freeswitch.xml Tue Dec 26 23:28:49 2006
@@ -373,8 +373,10 @@
<room name="888(a)sub.mydomain.com" status="FreeSWITCH"/>
</advertise>
-<!-- These are the default keys that map when you do not specify a caller control group -->
-<!-- Note: none and default are reserved names for group names -->
+<!-- Below is the default key map that is used when you do not specify a caller -->
+<!-- control group or when you use the group named "default". -->
+<!-- Note: The group names "none" and "default" are resreved built-in group definitions, and -->
+<!-- any re-definitions of these groups WILL NOT take precedence over the built-in definitions! -->
<caller-controls>
<group name="default">
<control action="mute" digits="0"/>
1
0
Author: knhor
Date: Tue Dec 26 23:25:35 2006
New Revision: 3837
Modified:
freeswitch/branches/knhor/trunk/conf/freeswitch.xml
Log:
merge from trunk
Modified: freeswitch/branches/knhor/trunk/conf/freeswitch.xml
==============================================================================
--- freeswitch/branches/knhor/trunk/conf/freeswitch.xml (original)
+++ freeswitch/branches/knhor/trunk/conf/freeswitch.xml Tue Dec 26 23:25:35 2006
@@ -373,6 +373,25 @@
<room name="888(a)sub.mydomain.com" status="FreeSWITCH"/>
</advertise>
+<!-- These are the default keys that map when you do not specify a caller control group -->
+<!-- Note: none and default are reserved names for group names -->
+ <caller-controls>
+ <group name="default">
+ <control action="mute" digits="0"/>
+ <control action="deaf mute" digits="*"/>
+ <control action="energy up" digits="9"/>
+ <control action="energy equ" digits="8"/>
+ <control action="energy dn" digits="7"/>
+ <control action="vol talk up" digits="3"/>
+ <control action="vol talk zero" digits="2"/>
+ <control action="vol talk dn" digits="1"/>
+ <control action="vol listen up" digits="6"/>
+ <control action="vol listen zero" digits="5"/>
+ <control action="vol listen dn" digits="4"/>
+ <control action="hangup" digits="#"/>
+ </group>
+ </caller-controls>
+
<!-- Profiles are collections of settings you can reference by name. -->
<profiles>
<profile name="default">
@@ -384,6 +403,8 @@
<param name="interval" value="20"/>
<!-- Energy level required for audio to be sent to the other users -->
<param name="energy-level" value="300"/>
+ <!-- Name of the caller control group to use for this profile -->
+ <!-- <param name="caller-controls" value="some name"/> -->
<!-- TTS Engine to use -->
<!--<param name="tts-engine" value="cepstral"/>-->
<!-- TTS Voice to use -->
1
0
[commit] r3836 - freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr
by Freeswitch SVN 27 Dec '06
by Freeswitch SVN 27 Dec '06
27 Dec '06
Author: mishehu
Date: Tue Dec 26 22:45:26 2006
New Revision: 3836
Modified:
freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/README
freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/csvcdr.cpp
freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/sqlitecdr.cpp
freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/sqlitecdr.h
freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/xmlcdr.cpp
Log:
SqliteCDR compiles and appears to behave as expected. Welcome it to the list of CDR backends.
Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/README
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/README (original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/README Tue Dec 26 22:45:26 2006
@@ -82,6 +82,14 @@
<param name="chanvars_supp" value=""/> value is a comma separated list of supplemental channel variables to log. Can be a wildcard (*) (optional)
<param name="chanvars_supp_repeat_fixed" value=""/> value is 0 for no, 1 for yes, and determines whether or not to repeat any of the fixed channel variables as key / value pairs in the chanvars table.
<param name="timezone" value=""/> value is utc for utc time, local for localtime. If not specified or incorrectly specified, localtime is assumed.
+
+Class: SqliteCDR, located in sqlitecdr.h and sqlitecdr.cpp
+ This class uses the Sqlite3 library as included with FreeSWITCH's core. Sqlite is not strict in its handling of column types, and in theory you can toss any sort of data at any sort of column. That being said, this logger was designed to at least attempt to match the column types to the type of data being sent to it. It will warn you if the schema does not match what chanvars_fixed types you specify, but it will not fail on them. However, due to the use of prepared statements, it is likely that you will have unexpected results if you mismatch your chanvars_fixed logging to db schema. The is the first SQL logger to automatically create the db schema and even update it on its own.
+Configuration: Section <sqlitecdr>
+ <param name="path" value=""/> value is the path to the database to open or create (required)
+ <param name="chanvars_fixed" value=""/> Is a comma separated list of key=type pairs. Types are x for decimal, s for string (varchar), d for double, i for integer, t for tiny. If no type is provided, it defaults that column to string (varchar). It cannot accept wildcards (*). You must have a matching column of matching type in the main freeswitchcdr table. The logger will attempt to automatically update the schema, but it cannot if a column by that name already exists.(optional)
+ <param name="chanvars_supp" value=""/> value is a comma separated list of supplemental channel variables to log. Can be a wildcard (*) (optional)
+ <param name="chanvars_supp_repeat_fixed" value=""/> value is 0 for no, 1 for yes, and determines whether or not to repeat any of the fixed channel variables as key / value pairs in the chanvars table.
FAQ:
Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/csvcdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/csvcdr.cpp (original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/csvcdr.cpp Tue Dec 26 22:45:26 2006
@@ -179,7 +179,7 @@
if(outputfile.good())
{
activated = 1;
- switch_console_printf(SWITCH_CHANNEL_LOG,"CsvCDR activated, log rotation will occur at or after %d MB",(filesize_limit/1024/1024));
+ switch_console_printf(SWITCH_CHANNEL_LOG,"CsvCDR activated, log rotation will occur at or after %d MB\n",(filesize_limit/1024/1024));
}
}
else
@@ -329,7 +329,7 @@
chanvars_fixed_list.clear();
chanvars_supp_list.clear();
connectionstate = 0;
- switch_console_printf(SWITCH_CHANNEL_LOG,"Shutting down CsvCDR... Done!");
+ switch_console_printf(SWITCH_CHANNEL_LOG,"Shutting down CsvCDR... Done!\n");
}
AUTO_REGISTER_BASECDR(CsvCDR);
Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/sqlitecdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/sqlitecdr.cpp (original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/sqlitecdr.cpp Tue Dec 26 22:45:26 2006
@@ -200,7 +200,7 @@
if(sql_rc == SQLITE_OK)
{
- for(int i = 0; i < nrows; i++)
+ for(int i = 0; i < ((nrow+1)*ncol); i++)
{
std::string tablename = result[i];
if(tablename == "freeswitchcdr" || tablename == "chanvars")
@@ -212,14 +212,14 @@
else
switch_console_printf(SWITCH_CHANNEL_LOG,"There was an error in executing query %s: The error was %s.\n",sql_query_check_tables,errormessage);
- switch_core_db_free_table(&result);
+ switch_core_db_free_table(result);
if(!temp_sql_tables["freeswitchcdr"])
{
switch_console_printf(SWITCH_CHANNEL_LOG,"Creating the freeswitchcdr table in the SQLite mod_cdr database file.\n");
// Must create the missing freeswitchcdr table.
char sql_query_create_freeswitchcdr[] = "CREATE TABLE freeswitchcdr (\n"
- "callid INTEGER AUTOINCREMENT PRIMARY KEY,\n"
+ "callid INTEGER PRIMARY KEY AUTOINCREMENT,\n"
"callstartdate INTEGER NOT NULL,\n"
"callanswerdate INTEGER NOT NULL,\n"
"calltransferdate INTEGER NOT NULL,\n"
@@ -239,8 +239,8 @@
"lastapp TEXT default \"\",\n"
"lastdata TEXT default \"\",\n"
"billusec INTEGER default 0,\n"
- "disposition INTEGER default 0,\n" /* 0 = Busy or Unanswered, 1 = Answered */
- "hangupcause INTEGER default 0\n",
+ "disposition INTEGER default 0,\n"
+ "hangupcause INTEGER default 0,\n"
"amaflags INTEGER default 0\n"
");\n";
@@ -251,8 +251,8 @@
{
switch_console_printf(SWITCH_CHANNEL_LOG,"Creating the chanvars table in the SQLite mod_cdr database file.\n");
// Must create the missing chanvars table.
- sql_query_create_chanvars[] = "CREATE TABLE chanvars (\n"
- "callid INTEGER default 0,\n""
+ char sql_query_create_chanvars[] = "CREATE TABLE chanvars (\n"
+ "callid INTEGER default 0,\n"
"varname TEXT NOT NULL,\n"
"varvalue TEXT default \"\"\n"
");\n";
@@ -264,19 +264,23 @@
{
// Now to check if the freeswitchcdr schema matches
std::map<std::string,std::string> freeswitchcdr_columns;
- char sql_query_get_schema_of_freeswitchcdr[] = "SELECT * FROM SQLITE_MASTER WHERE name=\"freeswitchcdr\"";
+ char sql_query_get_schema_of_freeswitchcdr[] = "SELECT sql FROM SQLITE_MASTER WHERE name=\"freeswitchcdr\"";
char **result2;
nrow = 0;
ncol = 0;
char *errormessage2;
- sql_rc = switch_core_db_get_table(db,sql_query_get_schema_of_freeswitchcdr,&result2,&nrow,&ncol,&errormessage);
+ sql_rc = switch_core_db_get_table(db,sql_query_get_schema_of_freeswitchcdr,&result2,&nrow,&ncol,&errormessage2);
if(sql_rc == SQLITE_OK)
{
- for(int i = 0; i < nrows; i++)
+ for(int k = 0; k < nrow; k++)
{
- std::string resultstring = result2[i][4];
- std::string::size_type j = resultstring.find('(',i);
+ // Warning - this is slightly ugly for string parsing
+ std::string resultstring = result2[1];
+ std::string::size_type j = resultstring.find('(',0);
+ j = resultstring.find('\n',j);
+
+ std::string::size_type h = 0;
std::string tempstring1,tempstring2;
@@ -285,15 +289,29 @@
j = resultstring.find(' ',i);
if(j > 0)
{
- tempstring = resultstring.substr(i,(j-i));
+ if(j == i)
+ {
+ i++;
+ j = resultstring.find(' ',(i));
+ }
+
+ tempstring1 = resultstring.substr(i,(j-i));
i = j+1;
j =resultstring.find(',',i);
+
+ h = resultstring.find(' ',i);
if(j == std::string::npos)
tempstring2 = resultstring.substr(i,(resultstring.size() - i));
+ else if(j > h)
+ tempstring2 = resultstring.substr(i,(h-i));
else
tempstring2 = resultstring.substr(i,(j-i));
freeswitchcdr_columns[tempstring1] = tempstring2;
+ // switch_console_printf(SWITCH_CHANNEL_LOG,"tempstring1 = %s, tempstring2 = %s\n",tempstring1.c_str(),tempstring2.c_str());
+ if(resultstring.find('\n',j+1) == (j+1))
+ j++;
+ i = j+1;
}
else
switch_console_printf(SWITCH_CHANNEL_LOG,"There has been a parsing problem with the freeswitchcdr schema.\n");
@@ -301,7 +319,7 @@
}
}
- switch_core_db_free_table(&result2);
+ switch_core_db_free_table(result2);
// Now to actually compare what we have in the config against the db schema
std::map<std::string,std::string> freeswitchcdr_add_columns;
@@ -315,7 +333,8 @@
case CDR_TINY:
if(freeswitchcdr_columns.find(*iItr) != freeswitchcdr_columns.end())
{
- if(freeswitchcdr_columns[*iItr] != "INTEGER")
+ //switch_console_printf(SWITCH_CHANNEL_LOG,"freeswitchcdr_columns[%s] == %s.\n",iItr->c_str(),freeswitchcdr_columns[*iItr].c_str());
+ if(freeswitchcdr_columns[*iItr].find("INTEGER",0) == std::string::npos)
switch_console_printf(SWITCH_CHANNEL_LOG,"WARNING: SqliteCDR freeswitchcdr table column type mismatch: Column \"%s\" is not of an INTEGER type. This is not necessarily fatal, but may result in unexpected behavior.\n",iItr->c_str());
}
else
@@ -324,7 +343,7 @@
case CDR_DOUBLE:
if(freeswitchcdr_columns.find(*iItr) != freeswitchcdr_columns.end())
{
- if(freeswitchcdr_columns[*iItr] != "REAL")
+ if(freeswitchcdr_columns[*iItr].find("REAL",0) == std::string::npos)
switch_console_printf(SWITCH_CHANNEL_LOG,"WARNING: SqliteCDR freeswitchcdr table column type mismatch: Column \"%s\" is not of a REAL type. This is not necessarily fatal, but may result in unexpected behavior.\n",iItr->c_str());
}
else
@@ -334,21 +353,21 @@
case CDR_STRING:
if(freeswitchcdr_columns.find(*iItr) != freeswitchcdr_columns.end())
{
- if(freeswitchcdr_columns[*iItr] != "TEXT")
+ if(freeswitchcdr_columns[*iItr].find("TEXT",0) == std::string::npos)
switch_console_printf(SWITCH_CHANNEL_LOG,"WARNING: SqliteCDR freeswitchcdr table column type mismatch: Column \"%s\" is not of a TEXT type. This is not necessarily fatal, but may result in unexpected behavior.\n",iItr->c_str());
}
else
freeswitchcdr_add_columns[*iItr] = "TEXT";
break;
default:
- switch_console_printf("Oh bother, I should not have fallen into this hole in the switch/case statement. Please notify the author.\n");
+ switch_console_printf(SWITCH_CHANNEL_LOG,"Oh bother, I should not have fallen into this hole in the switch/case statement. Please notify the author.\n");
}
}
if(freeswitchcdr_add_columns.size())
{
switch_console_printf(SWITCH_CHANNEL_LOG,"Updating the freeswitchcdr table schema.\n");
- std::string tempsql_freeswitchcdr_alter_table = "ALTER TABLE freeswithcdr ADD ";
+ std::string tempsql_freeswitchcdr_alter_table = "ALTER TABLE freeswitchcdr ADD ";
std::map<std::string, std::string>::iterator iItr, iEnd;
for(iItr = freeswitchcdr_add_columns.begin(), iEnd = freeswitchcdr_add_columns.end(); iItr != iEnd; iItr++)
{
@@ -356,6 +375,7 @@
sql_query_freeswitchcdr_alter_table.append(iItr->first);
sql_query_freeswitchcdr_alter_table.append(" ");
sql_query_freeswitchcdr_alter_table.append(iItr->second);
+ switch_console_printf(SWITCH_CHANNEL_LOG,"Updating the freeswitchcdr table with the following SQL command: %s.\n",sql_query_freeswitchcdr_alter_table.c_str());
switch_core_db_exec(db, sql_query_freeswitchcdr_alter_table.c_str(), NULL, NULL, NULL);
}
}
@@ -391,11 +411,12 @@
{
int column = 1;
switch_core_db_step(stmt_begin);
+ switch_core_db_reset(stmt_begin);
switch_core_db_bind_int64(stmt, column++, (sqlite_int64) callstartdate);
switch_core_db_bind_int64(stmt, column++, (sqlite_int64) callanswerdate);
switch_core_db_bind_int64(stmt, column++, (sqlite_int64) calltransferdate);
switch_core_db_bind_int64(stmt, column++, (sqlite_int64) callenddate);
- switch_core_db_bind_int(stmt, column++, (sqlite_int) originated);
+ switch_core_db_bind_int(stmt, column++, (int) originated);
switch_core_db_bind_text(stmt, column++, clid,-1,SQLITE_STATIC);
switch_core_db_bind_text(stmt, column++, src,-1,SQLITE_STATIC);
switch_core_db_bind_text(stmt, column++, dst,-1,SQLITE_STATIC);
@@ -410,9 +431,55 @@
switch_core_db_bind_text(stmt, column++, lastapp,-1,SQLITE_STATIC);
switch_core_db_bind_text(stmt, column++, lastdata,-1,SQLITE_STATIC);
switch_core_db_bind_int64(stmt, column++, (sqlite_int64) billusec);
- switch_core_db_bind_int(stmt, column++, (sqlite_int) disposition);
- switch_core_db_bind_int(stmt, column++, (sqlite_int) hangupcause);
- switch_core_db_bind_int(stmt, column++, (sqlite_int) amaflags);
+ switch_core_db_bind_int(stmt, column++, disposition);
+ switch_core_db_bind_int(stmt, column++, (int) hangupcause);
+ switch_core_db_bind_int(stmt, column++, amaflags);
+
+ if(chanvars_fixed.size())
+ {
+ std::list< std::pair<std::string,std::string> >::iterator iItr, iEnd;
+ int count = 0;
+ for(iItr = chanvars_fixed.begin(), iEnd = chanvars_fixed.end(); iItr != iEnd; iItr++, count++)
+ {
+ switch(chanvars_fixed_types[count])
+ {
+ case CDR_INTEGER:
+ case CDR_TINY:
+ {
+ int x;
+ if(iItr->second.size() > 0)
+ {
+ std::istringstream istring(iItr->second);
+ istring >> x;
+ }
+ else
+ x = 0;
+ switch_core_db_bind_int(stmt,column++,x);
+ break;
+ }
+ case CDR_DOUBLE:
+ {
+ double x = 0;
+ if(iItr->second.size() > 0)
+ {
+ std::istringstream istring(iItr->second);
+ istring >> x;
+ }
+ switch_core_db_bind_double(stmt,column++,x);
+ break;
+ }
+ case CDR_DECIMAL:
+ case CDR_STRING:
+ {
+ switch_core_db_bind_text(stmt,column++,iItr->second.c_str(),-1,SQLITE_STATIC);
+ break;
+ }
+ default:
+ switch_console_printf(SWITCH_CHANNEL_LOG,"Oh bother, I should not have fallen into this hole in the switch/case statement. Please notify the author.\n");
+ }
+ }
+ }
+
int sql_rc = switch_core_db_step(stmt);
if(sql_rc != SQLITE_DONE)
{
@@ -422,6 +489,8 @@
switch_console_printf(SWITCH_CHANNEL_LOG,"There was an error executing switch_core_db_step on SqliteCDR::stmt. The error was: %s\n",switch_core_db_errmsg(db));
}
+ sql_rc = switch_core_db_reset(stmt);
+
if(logchanvars && chanvars_supp.size())
{
sqlite_int64 rowid = switch_core_db_last_insert_rowid(db);
@@ -429,22 +498,24 @@
std::map<std::string,std::string>::iterator iItr, iEnd;
for(iItr = chanvars_supp.begin(), iEnd = chanvars_supp.end(); iItr != iEnd; iItr++)
{
- switch_core_db_bind_int64(stmt_chanvars, column++, rowid);
- switch_core_db_bind_text(stmt_chanvars, column++, iItr->first.c_str(),-1,SQLITE_STATIC);
- switch_core_db_bind_text(stmt_chanvars, column++, iItr->second.c_str(),-1,SQLITE_STATIC);
- }
-
- int sql_rc = switch_core_db_step(stmt_chanvars);
- if(sql_rc != SQLITE_DONE)
- {
- if(sql_rc == SQLITE_BUSY)
- sql_rc = switch_core_db_step(stmt_chanvars);
- else if (sql_rc == SQLITE_ERROR || sql_rc == SQLITE_MISUSE)
- switch_console_printf(SWITCH_CHANNEL_LOG,"There was an error executing switch_core_db_step on SqliteCDR::stmt_chanvars. The error was: %s\n",switch_core_db_errmsg(db));
+ switch_core_db_bind_int64(stmt_chanvars, column2++, rowid);
+ switch_core_db_bind_text(stmt_chanvars, column2++, iItr->first.c_str(),-1,SQLITE_STATIC);
+ switch_core_db_bind_text(stmt_chanvars, column2++, iItr->second.c_str(),-1,SQLITE_STATIC);
+ int sql_rc = switch_core_db_step(stmt_chanvars);
+ if(sql_rc != SQLITE_DONE)
+ {
+ if(sql_rc == SQLITE_BUSY)
+ sql_rc = switch_core_db_step(stmt_chanvars);
+ else if (sql_rc == SQLITE_ERROR || sql_rc == SQLITE_MISUSE)
+ switch_console_printf(SWITCH_CHANNEL_LOG,"There was an error executing switch_core_db_step on SqliteCDR::stmt_chanvars. The error was: %s\n",switch_core_db_errmsg(db));
+ }
+
+ switch_core_db_reset(stmt_chanvars);
}
}
switch_core_db_step(stmt_commit);
+ switch_core_db_reset(stmt_commit);
return 1;
}
@@ -465,6 +536,12 @@
tmp_sql_query.clear();
}
+std::string SqliteCDR::get_display_name()
+{
+ return display_name;
+}
+
+
AUTO_REGISTER_BASECDR(SqliteCDR);
Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/sqlitecdr.h
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/sqlitecdr.h (original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/sqlitecdr.h Tue Dec 26 22:45:26 2006
@@ -59,7 +59,7 @@
static std::string tmp_sql_query; // Object must exist to bind the statement, this used for generating the sql
static char sql_query_chanvars[100];
static std::string db_filename;
- static switch_core_db *db;
+ static switch_core_db_t *db;
static switch_core_db_stmt_t *stmt;
static switch_core_db_stmt_t *stmt_chanvars;
static switch_core_db_stmt_t *stmt_begin;
Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/xmlcdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/xmlcdr.cpp (original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/xmlcdr.cpp Tue Dec 26 22:45:26 2006
@@ -171,7 +171,7 @@
switch_console_printf(SWITCH_CHANNEL_LOG, "XmlCDR::process_record(): Unable to open file %s to commit the call record to. Invalid path name, invalid permissions, or no space available?\n",outputfile_name.c_str());
else
{
- switch_console_printf(SWITCH_CHANNEL_LOG, "XmlCDR::process_record(): Preping the CDR to %s.\n",outputfile_name.c_str());
+ //switch_console_printf(SWITCH_CHANNEL_LOG, "XmlCDR::process_record(): Preping the CDR to %s.\n",outputfile_name.c_str());
// Format the call record and proceed from here...
outputfile << "<?xml version=\"1.0\"?>" << std::endl;
outputfile << "<document type=\"freeswitch-cdr/xml\">" << std::endl;
@@ -213,7 +213,7 @@
}
outputfile << "\t</chanvars>" << std::endl << "</document>" << std::endl << std::endl;
- switch_console_printf(SWITCH_CHANNEL_LOG, "XmlCDR::process_record(): Dumping the CDR to %s.\n",outputfile_name.c_str());
+ //switch_console_printf(SWITCH_CHANNEL_LOG, "XmlCDR::process_record(): Dumping the CDR to %s.\n",outputfile_name.c_str());
retval = 1;
}
1
0
[commit] r3835 - freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr
by Freeswitch SVN 26 Dec '06
by Freeswitch SVN 26 Dec '06
26 Dec '06
Author: mishehu
Date: Tue Dec 26 15:38:03 2006
New Revision: 3835
Modified:
freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp
freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/mysqlcdr.h
freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/odbccdr.cpp
freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/schema.sql
freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/sqlitecdr.cpp
Log:
Ack, no logging of network_addr in a couple of the SQL based logger backends. I believe this is now fixed. Still not tested.
Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp (original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/mysqlcdr.cpp Tue Dec 26 15:38:03 2006
@@ -62,6 +62,7 @@
dstchannel_length = (long unsigned int)strlen(dstchannel);
lastapp_length = (long unsigned int)strlen(lastapp);
lastdata_length = (long unsigned int)strlen(lastdata);
+ network_addr_length = (long unsigned int)strlen(network_addr);
if(chanvars_fixed_list.size() > 0)
process_channel_variables(chanvars_fixed_list,newchannel->channel);
@@ -195,7 +196,7 @@
if(activated)
{
- tmp_sql_query = "INSERT INTO freeswitchcdr (callstartdate,callanswerdate,calltransferdate,callenddate,originated,clid,src,dst,ani,aniii,dialplan,myuuid,destuuid,srcchannel,dstchannel,lastapp,lastdata,billusec,disposition,hangupcause,amaflags";
+ tmp_sql_query = "INSERT INTO freeswitchcdr (callstartdate,callanswerdate,calltransferdate,callenddate,originated,clid,src,dst,ani,aniii,dialplan,myuuid,destuuid,srcchannel,dstchannel,network_addr,lastapp,lastdata,billusec,disposition,hangupcause,amaflags";
int items_appended = 0;
@@ -213,7 +214,7 @@
}
}
- tmp_sql_query.append(") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?");
+ tmp_sql_query.append(") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?");
if(chanvars_fixed_list.size() > 0 )
{
@@ -353,6 +354,7 @@
add_string_parameter(destuuid,destuuid_length,MYSQL_TYPE_VAR_STRING,0);
add_string_parameter(srcchannel,srcchannel_length,MYSQL_TYPE_VAR_STRING,0);
add_string_parameter(dstchannel,dstchannel_length,MYSQL_TYPE_VAR_STRING,0);
+ add_string_parameter(network_addr,network_addr_length,MYSQL_TYPE_VAR_STRING,0);
add_string_parameter(lastapp,lastapp_length,MYSQL_TYPE_VAR_STRING,0);
add_string_parameter(lastdata,lastdata_length,MYSQL_TYPE_VAR_STRING,0);
add_parameter(billusec,MYSQL_TYPE_LONGLONG,0);
Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/mysqlcdr.h
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/mysqlcdr.h (original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/mysqlcdr.h Tue Dec 26 15:38:03 2006
@@ -95,6 +95,7 @@
long unsigned int aniii_length;
long unsigned int lastapp_length;
long unsigned int lastdata_length;
+ long unsigned int network_addr_length;
// Now a couple internal methods
template <typename T> void add_parameter(T& param, enum_field_types type, bool *is_null=0);
void add_string_parameter(char* param, long unsigned int& param_length, enum_field_types type, bool* is_null=0);
Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/odbccdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/odbccdr.cpp (original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/odbccdr.cpp Tue Dec 26 15:38:03 2006
@@ -222,7 +222,7 @@
{
tmp_sql_query = "INSERT INTO ";
tmp_sql_query.append(tablename);
- tmp_sql_query.append(" (callstartdate,callanswerdate,calltransferdate,callenddate,originated,clid,src,dst,ani,aniii,dialplan,myuuid,destuuid,srcchannel,dstchannel,lastapp,lastdata,billusec,disposition,hangupcause,amaflags");
+ tmp_sql_query.append(" (callstartdate,callanswerdate,calltransferdate,callenddate,originated,clid,src,dst,ani,aniii,dialplan,myuuid,destuuid,srcchannel,dstchannel,network_addr,lastapp,lastdata,billusec,disposition,hangupcause,amaflags");
int items_appended = 0;
@@ -240,7 +240,7 @@
}
}
- tmp_sql_query.append(") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?");
+ tmp_sql_query.append(") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?");
if(chanvars_fixed_list.size() > 0 )
{
@@ -422,6 +422,7 @@
SQLBindParameter(ODBC_stmt, index++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(destuuid), 0, destuuid, 0, 0);
SQLBindParameter(ODBC_stmt, index++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, sizeof(srcchannel), 0, srcchannel, 0, 0);
SQLBindParameter(ODBC_stmt, index++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, sizeof(dstchannel), 0, dstchannel, 0, 0);
+ SQLBindParameter(ODBC_stmt, index++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, sizeof(network_addr), 0, network_addr, 0, 0);
SQLBindParameter(ODBC_stmt, index++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, sizeof(lastapp), 0, lastapp, 0, 0);
SQLBindParameter(ODBC_stmt, index++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, sizeof(lastdata), 0, lastdata, 0, 0);
SQLBindParameter(ODBC_stmt, index++, SQL_PARAM_INPUT, SQL_C_UBIGINT, SQL_BIGINT, 0, 0, &billusec, 0, 0);
Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/schema.sql
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/schema.sql (original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/schema.sql Tue Dec 26 15:38:03 2006
@@ -15,6 +15,7 @@
destuuid char(36) NOT NULL,
srcchannel varchar(80) NOT NULL,
dstchannel varchar(80) NOT NULL, /* Need to decide - this might be redundant as you can link the records via uuid */
+ network_addr varchar(40) default "",
lastapp varchar(80) default "",
lastdata varchar(255) default "",
billusec bigint default 0,
Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/sqlitecdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/sqlitecdr.cpp (original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/sqlitecdr.cpp Tue Dec 26 15:38:03 2006
@@ -141,7 +141,7 @@
if(activated)
{
- tmp_sql_query = "INSERT INTO freeswitchcdr (callstartdate,callanswerdate,calltransferdate,callenddate,originated,clid,src,dst,ani,aniii,dialplan,myuuid,destuuid,srcchannel,dstchannel,lastapp,lastdata,billusec,disposition,hangupcause,amaflags";
+ tmp_sql_query = "INSERT INTO freeswitchcdr (callstartdate,callanswerdate,calltransferdate,callenddate,originated,clid,src,dst,ani,aniii,dialplan,myuuid,destuuid,srcchannel,dstchannel,network_addr,lastapp,lastdata,billusec,disposition,hangupcause,amaflags";
int items_appended = 0;
@@ -159,7 +159,7 @@
}
}
- tmp_sql_query.append(") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?");
+ tmp_sql_query.append(") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?");
if(chanvars_fixed_list.size() > 0 )
{
@@ -235,6 +235,7 @@
"destuuid TEXT NOT NULL,\n"
"srcchannel TEXT NOT NULL,\n"
"dstchannel TEXT NOT NULL,\n"
+ "network_addr TEXT,\n"
"lastapp TEXT default \"\",\n"
"lastdata TEXT default \"\",\n"
"billusec INTEGER default 0,\n"
@@ -405,6 +406,7 @@
switch_core_db_bind_text(stmt, column++, destuuid,36,SQLITE_STATIC);
switch_core_db_bind_text(stmt, column++, srcchannel,-1,SQLITE_STATIC);
switch_core_db_bind_text(stmt, column++, dstchannel,-1,SQLITE_STATIC);
+ switch_core_db_bind_text(stmt, column++, network_addr,-1,SQLITE_STATIC);
switch_core_db_bind_text(stmt, column++, lastapp,-1,SQLITE_STATIC);
switch_core_db_bind_text(stmt, column++, lastdata,-1,SQLITE_STATIC);
switch_core_db_bind_int64(stmt, column++, (sqlite_int64) billusec);
@@ -438,7 +440,7 @@
if(sql_rc == SQLITE_BUSY)
sql_rc = switch_core_db_step(stmt_chanvars);
else if (sql_rc == SQLITE_ERROR || sql_rc == SQLITE_MISUSE)
- switch_console_printf(SWITCH_CHANNEL_LOG,"There was an error executing switch_core_db_step on SqliteCDR::stmt. The error was: %s\n",switch_core_db_errmsg(db));
+ switch_console_printf(SWITCH_CHANNEL_LOG,"There was an error executing switch_core_db_step on SqliteCDR::stmt_chanvars. The error was: %s\n",switch_core_db_errmsg(db));
}
}
@@ -451,6 +453,8 @@
{
switch_core_db_finalize(stmt_chanvars);
switch_core_db_finalize(stmt);
+ switch_core_db_finalize(stmt_begin);
+ switch_core_db_finalize(stmt_commit);
switch_core_db_close(db);
activated = 0;
logchanvars = 0;
1
0
[commit] r3834 - freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr
by Freeswitch SVN 26 Dec '06
by Freeswitch SVN 26 Dec '06
26 Dec '06
Author: mishehu
Date: Tue Dec 26 14:17:22 2006
New Revision: 3834
Modified:
freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/csvcdr.cpp
Log:
Added output of a header to CsvCDR so that folks know what the format is. Not yet tested either.
Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/csvcdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/csvcdr.cpp (original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/csvcdr.cpp Tue Dec 26 14:17:22 2006
@@ -228,7 +228,21 @@
switch_console_printf(SWITCH_CHANNEL_LOG,"Could not open the CSV file %s . CsvCDR logger will not be functional until this is resolved and a reload is issued. Failbit is set to %d.\n",filename.c_str(),outputfile.fail());
activated = 0;
}
+ else
+ {
+ outputfile << "callstartdate,formattedcallstartdate,callanswerdate,formattedcallanswerdate,calltransferdate,formattedcalltransferdate,callendate,formattedcallenddate,hangupcause_text,hangupcause,clid,originated,dialplan,myuuid,destuuid,src,dst,srcchannel,dstchannel,ani,aniii,network_address,lastapp,lastdata,billusec,disposition,amaflags";
+ if(chanvars_fixed_list.size())
+ {
+ std::list<std::string>::iterator iItr, iEnd;
+ for(iItr = chanvars_fixed_list.begin(),iEnd = chanvars_fixed_list.end(); iItr != iEnd; iItr++)
+ outputfile << "," << *iItr;
+ }
+
+ if(logchanvars)
+ outputfile << ",chanvars_supp";
+ outputfile << std::endl;
+ }
}
bool CsvCDR::process_record()
1
0
[commit] r3833 - freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr
by Freeswitch SVN 26 Dec '06
by Freeswitch SVN 26 Dec '06
26 Dec '06
Author: mishehu
Date: Tue Dec 26 13:54:12 2006
New Revision: 3833
Modified:
freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/sqlitecdr.cpp
Log:
Made more code updates to SqliteCDR. In theory it should be functional now, but it has not even been compiled yet. Surely there's at least one honorary typo in it somewhere...
Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/sqlitecdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/sqlitecdr.cpp (original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/sqlitecdr.cpp Tue Dec 26 13:54:12 2006
@@ -141,7 +141,7 @@
if(activated)
{
- tmp_sql_query = "INSERT INTO freeswitchcdr (callstartdate,callanswerdate,callenddate,originated,clid,src,dst,ani,aniii,dialplan,myuuid,destuuid,srcchannel,dstchannel,lastapp,lastdata,billusec,disposition,hangupcause,amaflags";
+ tmp_sql_query = "INSERT INTO freeswitchcdr (callstartdate,callanswerdate,calltransferdate,callenddate,originated,clid,src,dst,ani,aniii,dialplan,myuuid,destuuid,srcchannel,dstchannel,lastapp,lastdata,billusec,disposition,hangupcause,amaflags";
int items_appended = 0;
@@ -159,7 +159,7 @@
}
}
- tmp_sql_query.append(") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?");
+ tmp_sql_query.append(") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?");
if(chanvars_fixed_list.size() > 0 )
{
@@ -175,173 +175,196 @@
strncpy(sql_query,tmp_sql_query.c_str(),tmp_sql_query.size());
- switch_core_db_open(db_filename.c_str(),&db);
+ int sql_rc = switch_core_db_open(db_filename.c_str(),&db);
- char sql_query_check_tables[] = "SELECT name FROM sqlite_master WHERE type = \"table\"";
- char **result;
- int nrow = 0, ncol = 0;
- char *errormessage;
- int sql_rc = switch_core_db_get_table(db,sql_query_check_tables,&result,&nrow,&ncol,&errormessage);
-
- std::map<std::string,bool> temp_chanvars_map;
- // Now to copy out all the chanvars from the list into
-
- std::map<std::string,bool> temp_sql_tables;
- temp_sql_tables["freeswitchcdr"] = 0;
- temp_sql_tables["chanvars"] = 0;
+ if(sql_rc != SQLITE_OK)
+ {
+ switch_console_printf(SWITCH_CHANNEL_LOG,"There was an error opening database filename %s. The error was: %s. SqliteCDR logging has been disabled until the problem is resolved and modcdr_reload is initiated.\n",db_filename.c_str(),switch_core_db_errmsg(db));
+ activated = 0;
+ switch_core_db_close(db);
+ }
+ else
+ {
+ char sql_query_check_tables[] = "SELECT name FROM sqlite_master WHERE type = \"table\"";
+ char **result;
+ int nrow = 0, ncol = 0;
+ char *errormessage;
+ sql_rc = switch_core_db_get_table(db,sql_query_check_tables,&result,&nrow,&ncol,&errormessage);
+
+ std::map<std::string,bool> temp_chanvars_map;
+ // Now to copy out all the chanvars from the list into
+
+ std::map<std::string,bool> temp_sql_tables;
+ temp_sql_tables["freeswitchcdr"] = 0;
+ temp_sql_tables["chanvars"] = 0;
- if(sql_rc == SQLITE_OK)
- for(int i = 0; i < nrows; i++)
+ if(sql_rc == SQLITE_OK)
{
- std::string tablename = result[i];
- if(tablename == "freeswitchcdr" || tablename == "chanvars")
+ for(int i = 0; i < nrows; i++)
{
- temp_sql_tables[tablename] = 1;
+ std::string tablename = result[i];
+ if(tablename == "freeswitchcdr" || tablename == "chanvars")
+ {
+ temp_sql_tables[tablename] = 1;
+ }
}
}
- else
- switch_console_printf(SWITCH_CHANNEL_LOG,"There was an error in executing query %s: The error was %s.\n",sql_query_check_tables,errormessage);
-
- if(!temp_sql_tables["freeswitchcdr"])
- {
- switch_console_printf(SWITCH_CHANNEL_LOG,"Creating the freeswitchcdr table in the SQLite mod_cdr database file.\n");
- // Must create the missing freeswitchcdr table.
- char sql_query_create_freeswitchcdr[] = "CREATE TABLE freeswitchcdr (\n"
- "callid INTEGER AUTOINCREMENT PRIMARY KEY,\n"
- "callstartdate INTEGER NOT NULL,\n"
- "callanswerdate INTEGER NOT NULL,\n"
- "calltransferdate INTEGER NOT NULL,\n"
- "callenddate INTEGER NOT NULL,\n"
- "originated INTEGER default 0,\n"
- "clid TEXT default \"Freeswitch - Unknown\",\n"
- "src TEXT NOT NULL,\n"
- "dst TEXT NOT NULL,\n"
- "ani TEXT default \"\",\n"
- "aniii TEXT default \"\",\n"
- "dialplan TEXT default \"\",\n"
- "myuuid TEXT NOT NULL,\n"
- "destuuid TEXT NOT NULL,\n"
- "srcchannel TEXT NOT NULL,\n"
- "dstchannel TEXT NOT NULL,\n"
- "lastapp TEXT default \"\",\n"
- "lastdata TEXT default \"\",\n"
- "billusec INTEGER default 0,\n"
- "disposition INTEGER default 0,\n" /* 0 = Busy or Unanswered, 1 = Answered */
- "hangupcause INTEGER default 0\n",
- "amaflags INTEGER default 0\n"
- ");\n";
-
- switch_core_db_exec(db, sql_query_create_freeswitchcdr, NULL, NULL, NULL);
- }
-
- if(!temp_sql_tables["chanvars"])
- {
- switch_console_printf(SWITCH_CHANNEL_LOG,"Creating the chanvars table in the SQLite mod_cdr database file.\n");
- // Must create the missing chanvars table.
- sql_query_create_chanvars[] = "CREATE TABLE chanvars (\n"
- "callid INTEGER default 0,\n""
- "varname TEXT NOT NULL,\n"
- "varvalue TEXT default \"\"\n"
- ");\n";
+ else
+ switch_console_printf(SWITCH_CHANNEL_LOG,"There was an error in executing query %s: The error was %s.\n",sql_query_check_tables,errormessage);
- switch_core_db_exec(db, sql_query_create_chanvars, NULL, NULL, NULL);
- }
+ switch_core_db_free_table(&result);
- if(chanvars_fixed_list.size() > 0)
- {
- // Now to check if the freeswitchcdr schema matches
- std::map<std::string,std::string> freeswitchcdr_columns;
- char sql_query_get_schema_of_freeswitchcdr[] = "SELECT * FROM SQLITE_MASTER WHERE name=\"freeswitchcdr\"";
- char **result2;
- nrow = 0;
- ncol = 0;
- char *errormessage2;
- sql_rc = switch_core_db_get_table(db,sql_query_get_schema_of_freeswitchcdr,&result,&nrow,&ncol,&errormessage);
+ if(!temp_sql_tables["freeswitchcdr"])
+ {
+ switch_console_printf(SWITCH_CHANNEL_LOG,"Creating the freeswitchcdr table in the SQLite mod_cdr database file.\n");
+ // Must create the missing freeswitchcdr table.
+ char sql_query_create_freeswitchcdr[] = "CREATE TABLE freeswitchcdr (\n"
+ "callid INTEGER AUTOINCREMENT PRIMARY KEY,\n"
+ "callstartdate INTEGER NOT NULL,\n"
+ "callanswerdate INTEGER NOT NULL,\n"
+ "calltransferdate INTEGER NOT NULL,\n"
+ "callenddate INTEGER NOT NULL,\n"
+ "originated INTEGER default 0,\n"
+ "clid TEXT default \"Freeswitch - Unknown\",\n"
+ "src TEXT NOT NULL,\n"
+ "dst TEXT NOT NULL,\n"
+ "ani TEXT default \"\",\n"
+ "aniii TEXT default \"\",\n"
+ "dialplan TEXT default \"\",\n"
+ "myuuid TEXT NOT NULL,\n"
+ "destuuid TEXT NOT NULL,\n"
+ "srcchannel TEXT NOT NULL,\n"
+ "dstchannel TEXT NOT NULL,\n"
+ "lastapp TEXT default \"\",\n"
+ "lastdata TEXT default \"\",\n"
+ "billusec INTEGER default 0,\n"
+ "disposition INTEGER default 0,\n" /* 0 = Busy or Unanswered, 1 = Answered */
+ "hangupcause INTEGER default 0\n",
+ "amaflags INTEGER default 0\n"
+ ");\n";
+
+ switch_core_db_exec(db, sql_query_create_freeswitchcdr, NULL, NULL, NULL);
+ }
+
+ if(!temp_sql_tables["chanvars"])
+ {
+ switch_console_printf(SWITCH_CHANNEL_LOG,"Creating the chanvars table in the SQLite mod_cdr database file.\n");
+ // Must create the missing chanvars table.
+ sql_query_create_chanvars[] = "CREATE TABLE chanvars (\n"
+ "callid INTEGER default 0,\n""
+ "varname TEXT NOT NULL,\n"
+ "varvalue TEXT default \"\"\n"
+ ");\n";
+
+ switch_core_db_exec(db, sql_query_create_chanvars, NULL, NULL, NULL);
+ }
- if(sql_rc == SQLITE_OK)
- for(int i = 0; i < nrows; i++)
+ if(chanvars_fixed_list.size() > 0)
+ {
+ // Now to check if the freeswitchcdr schema matches
+ std::map<std::string,std::string> freeswitchcdr_columns;
+ char sql_query_get_schema_of_freeswitchcdr[] = "SELECT * FROM SQLITE_MASTER WHERE name=\"freeswitchcdr\"";
+ char **result2;
+ nrow = 0;
+ ncol = 0;
+ char *errormessage2;
+ sql_rc = switch_core_db_get_table(db,sql_query_get_schema_of_freeswitchcdr,&result2,&nrow,&ncol,&errormessage);
+
+ if(sql_rc == SQLITE_OK)
{
- std::string resultstring = result2[i][4];
- std::string::size_type j = resultstring.find('(',i);
-
- std::string tempstring1,tempstring2;
-
- for(std::string::size_type i = j+1 ; j != std::string::npos; )
+ for(int i = 0; i < nrows; i++)
{
- j = resultstring.find(' ',i);
- if(j > 0)
+ std::string resultstring = result2[i][4];
+ std::string::size_type j = resultstring.find('(',i);
+
+ std::string tempstring1,tempstring2;
+
+ for(std::string::size_type i = j+1 ; j != std::string::npos; )
{
- tempstring = resultstring.substr(i,(j-i));
- i = j+1;
- j =resultstring.find(',',i);
- if(j == std::string::npos)
- tempstring2 = resultstring.substr(i,(resultstring.size() - i));
+ j = resultstring.find(' ',i);
+ if(j > 0)
+ {
+ tempstring = resultstring.substr(i,(j-i));
+ i = j+1;
+ j =resultstring.find(',',i);
+ if(j == std::string::npos)
+ tempstring2 = resultstring.substr(i,(resultstring.size() - i));
+ else
+ tempstring2 = resultstring.substr(i,(j-i));
+
+ freeswitchcdr_columns[tempstring1] = tempstring2;
+ }
else
- tempstring2 = resultstring.substr(i,(j-i));
-
- freeswitchcdr_columns[tempstring1] = tempstring2;
+ switch_console_printf(SWITCH_CHANNEL_LOG,"There has been a parsing problem with the freeswitchcdr schema.\n");
}
- else
- switch_console_printf(SWITCH_CHANNEL_LOG,"There has been a parsing problem with the freeswitchcdr schema.\n");
}
}
-
- // Now to actually compare what we have in the config against the db schema
- std::map<std::string,std::string> freeswitchcdr_add_columns;
- std::list<std::string>::iterator iItr, iEnd;
- switch_size_t i = 0;
- for(iItr = chanvars_fixed_list.begin(), iEnd = chanvars_fixed_list.end(); iItr != iEnd; iItr++, i++)
- {
- switch(chanvars_fixed_types[i])
+
+ switch_core_db_free_table(&result2);
+
+ // Now to actually compare what we have in the config against the db schema
+ std::map<std::string,std::string> freeswitchcdr_add_columns;
+ std::list<std::string>::iterator iItr, iEnd;
+ switch_size_t i = 0;
+ for(iItr = chanvars_fixed_list.begin(), iEnd = chanvars_fixed_list.end(); iItr != iEnd; iItr++, i++)
{
- case CDR_INTEGER:
- case CDR_TINY:
- if(freeswitchcdr_columns.find(*iItr) != freeswitchcdr_columns.end())
- {
- if(freeswitchcdr_columns[*iItr] != "INTEGER")
- switch_console_printf(SWITCH_CHANNEL_LOG,"WARNING: SqliteCDR freeswitchcdr table column type mismatch: Column \"%s\" is not of an INTEGER type. This is not necessarily fatal, but may result in unexpected behavior.\n",iItr->c_str());
- }
- else
- freeswitchcdr_add_columns[*iItr] = "INTEGER";
- break;
- case CDR_DOUBLE:
- if(freeswitchcdr_columns.find(*iItr) != freeswitchcdr_columns.end())
- {
- if(freeswitchcdr_columns[*iItr] != "REAL")
- switch_console_printf(SWITCH_CHANNEL_LOG,"WARNING: SqliteCDR freeswitchcdr table column type mismatch: Column \"%s\" is not of a REAL type. This is not necessarily fatal, but may result in unexpected behavior.\n",iItr->c_str());
- }
- else
- freeswitchcdr_add_columns[*iItr] = "REAL";
- break;
- case CDR_DECIMAL:
- case CDR_STRING:
- if(freeswitchcdr_columns.find(*iItr) != freeswitchcdr_columns.end())
- {
- if(freeswitchcdr_columns[*iItr] != "TEXT")
- switch_console_printf(SWITCH_CHANNEL_LOG,"WARNING: SqliteCDR freeswitchcdr table column type mismatch: Column \"%s\" is not of a TEXT type. This is not necessarily fatal, but may result in unexpected behavior.\n",iItr->c_str());
- }
- else
- freeswitchcdr_add_columns[*iItr] = "TEXT";
- break;
- default:
- switch_console_printf("Oh bother, I should not have fallen into this hole in the switch/case statement. Please notify the author.\n");
+ switch(chanvars_fixed_types[i])
+ {
+ case CDR_INTEGER:
+ case CDR_TINY:
+ if(freeswitchcdr_columns.find(*iItr) != freeswitchcdr_columns.end())
+ {
+ if(freeswitchcdr_columns[*iItr] != "INTEGER")
+ switch_console_printf(SWITCH_CHANNEL_LOG,"WARNING: SqliteCDR freeswitchcdr table column type mismatch: Column \"%s\" is not of an INTEGER type. This is not necessarily fatal, but may result in unexpected behavior.\n",iItr->c_str());
+ }
+ else
+ freeswitchcdr_add_columns[*iItr] = "INTEGER";
+ break;
+ case CDR_DOUBLE:
+ if(freeswitchcdr_columns.find(*iItr) != freeswitchcdr_columns.end())
+ {
+ if(freeswitchcdr_columns[*iItr] != "REAL")
+ switch_console_printf(SWITCH_CHANNEL_LOG,"WARNING: SqliteCDR freeswitchcdr table column type mismatch: Column \"%s\" is not of a REAL type. This is not necessarily fatal, but may result in unexpected behavior.\n",iItr->c_str());
+ }
+ else
+ freeswitchcdr_add_columns[*iItr] = "REAL";
+ break;
+ case CDR_DECIMAL:
+ case CDR_STRING:
+ if(freeswitchcdr_columns.find(*iItr) != freeswitchcdr_columns.end())
+ {
+ if(freeswitchcdr_columns[*iItr] != "TEXT")
+ switch_console_printf(SWITCH_CHANNEL_LOG,"WARNING: SqliteCDR freeswitchcdr table column type mismatch: Column \"%s\" is not of a TEXT type. This is not necessarily fatal, but may result in unexpected behavior.\n",iItr->c_str());
+ }
+ else
+ freeswitchcdr_add_columns[*iItr] = "TEXT";
+ break;
+ default:
+ switch_console_printf("Oh bother, I should not have fallen into this hole in the switch/case statement. Please notify the author.\n");
+ }
}
- }
-
- if(freeswitchcdr_add_columns.size())
- {
- switch_console_printf(SWITCH_CHANNEL_LOG,"Updating the freeswitchcdr table schema.\n");
- std::string tempsql_freeswitchcdr_alter_table = "ALTER TABLE freeswithcdr ADD ";
- std::map<std::string, std::string>::iterator iItr, iEnd;
- for(iItr = freeswitchcdr_add_columns.begin(), iEnd = freeswitchcdr_add_columns.end(); iItr != iEnd; iItr++)
+
+ if(freeswitchcdr_add_columns.size())
{
- std::string sql_query_freeswitchcdr_alter_table = tempsql_freeswitchcdr_alter_table;
- sql_query_freeswitchcdr_alter_table.append(iItr->first);
- sql_query_freeswitchcdr_alter_table.append(" ");
- sql_query_freeswitchcdr_alter_table.append(iItr->second);
- switch_core_db_exec(db, sql_query_freeswitchcdr_alter_table.c_str(), NULL, NULL, NULL);
+ switch_console_printf(SWITCH_CHANNEL_LOG,"Updating the freeswitchcdr table schema.\n");
+ std::string tempsql_freeswitchcdr_alter_table = "ALTER TABLE freeswithcdr ADD ";
+ std::map<std::string, std::string>::iterator iItr, iEnd;
+ for(iItr = freeswitchcdr_add_columns.begin(), iEnd = freeswitchcdr_add_columns.end(); iItr != iEnd; iItr++)
+ {
+ std::string sql_query_freeswitchcdr_alter_table = tempsql_freeswitchcdr_alter_table;
+ sql_query_freeswitchcdr_alter_table.append(iItr->first);
+ sql_query_freeswitchcdr_alter_table.append(" ");
+ sql_query_freeswitchcdr_alter_table.append(iItr->second);
+ switch_core_db_exec(db, sql_query_freeswitchcdr_alter_table.c_str(), NULL, NULL, NULL);
+ }
}
}
+
+ switch_core_db_prepare(db,"BEGIN TRANSACTION SqliteCDR",-1,&stmt_begin,0);
+ switch_core_db_prepare(db,"COMMIT TRANSACTION SqliteCDR",-1,&stmt_commit,0);
+ switch_core_db_prepare(db,tmp_sql_query.c_str(),-1,&stmt,0);
+ if(chanvars_supp_list.size())
+ switch_core_db_prepare(db,sql_query_chanvars,-1,&stmt_chanvars,0);
}
}
}
@@ -365,237 +388,62 @@
bool SqliteCDR::process_record()
{
- std::list<void*> temp_chanvars_holder; // This is used for any fixed chanvars, as we don't want things out of scope
-
- if(chanvars_fixed_list.size() > 0)
+ int column = 1;
+ switch_core_db_step(stmt_begin);
+ switch_core_db_bind_int64(stmt, column++, (sqlite_int64) callstartdate);
+ switch_core_db_bind_int64(stmt, column++, (sqlite_int64) callanswerdate);
+ switch_core_db_bind_int64(stmt, column++, (sqlite_int64) calltransferdate);
+ switch_core_db_bind_int64(stmt, column++, (sqlite_int64) callenddate);
+ switch_core_db_bind_int(stmt, column++, (sqlite_int) originated);
+ switch_core_db_bind_text(stmt, column++, clid,-1,SQLITE_STATIC);
+ switch_core_db_bind_text(stmt, column++, src,-1,SQLITE_STATIC);
+ switch_core_db_bind_text(stmt, column++, dst,-1,SQLITE_STATIC);
+ switch_core_db_bind_text(stmt, column++, ani,-1,SQLITE_STATIC);
+ switch_core_db_bind_text(stmt, column++, aniii,-1,SQLITE_STATIC);
+ switch_core_db_bind_text(stmt, column++, dialplan,-1,SQLITE_STATIC);
+ switch_core_db_bind_text(stmt, column++, myuuid,36,SQLITE_STATIC);
+ switch_core_db_bind_text(stmt, column++, destuuid,36,SQLITE_STATIC);
+ switch_core_db_bind_text(stmt, column++, srcchannel,-1,SQLITE_STATIC);
+ switch_core_db_bind_text(stmt, column++, dstchannel,-1,SQLITE_STATIC);
+ switch_core_db_bind_text(stmt, column++, lastapp,-1,SQLITE_STATIC);
+ switch_core_db_bind_text(stmt, column++, lastdata,-1,SQLITE_STATIC);
+ switch_core_db_bind_int64(stmt, column++, (sqlite_int64) billusec);
+ switch_core_db_bind_int(stmt, column++, (sqlite_int) disposition);
+ switch_core_db_bind_int(stmt, column++, (sqlite_int) hangupcause);
+ switch_core_db_bind_int(stmt, column++, (sqlite_int) amaflags);
+ int sql_rc = switch_core_db_step(stmt);
+ if(sql_rc != SQLITE_DONE)
{
- switch_size_t i = 0; // temporary variable, i is current spot on the string of types
- std::list<std::pair<std::string,std::string> >::iterator iItr, iEnd;
- for(iItr = chanvars_fixed.begin(), iEnd = chanvars_fixed.end(); iItr != iEnd; iItr++)
- {
- switch(chanvars_fixed_types[i])
- {
- case CDR_INTEGER:
- {
- int* x = new int;
- *x = 0;
- bool* is_null = new bool;
- *is_null = 0;
-
- if(iItr->second.size() > 0)
- {
- std::istringstream istring(iItr->second);
- istring >> *x;
- }
- else
- *is_null = 1;
- temp_chanvars_holder.push_back(x);
- temp_chanvars_holder.push_back(is_null);
- add_parameter(*x,MYSQL_TYPE_LONG,is_null);
- break;
- }
- case CDR_DOUBLE:
- {
- double* x = new double;
- *x = 0;
- bool* is_null = new bool;
- *is_null = 0;
- if(iItr->second.size() > 0)
- {
- std::istringstream istring(iItr->second);
- istring >> *x;
- }
- else
- *is_null = 1;
- temp_chanvars_holder.push_back(x);
- temp_chanvars_holder.push_back(is_null);
- add_parameter(*x,MYSQL_TYPE_DOUBLE,is_null);
- break;
- }
- case CDR_TINY:
- {
- short* x = new short;
- *x = 0;
- bool* is_null = new bool;
- *is_null = 0;
- if(iItr->second.size() > 0)
- {
- std::istringstream istring(iItr->second);
- istring >> *x;
- }
- else
- *is_null = 1;
- temp_chanvars_holder.push_back(x);
- temp_chanvars_holder.push_back(is_null);
- add_parameter(*x,MYSQL_TYPE_TINY,is_null);
- break;
- }
- case CDR_STRING:
- case CDR_DECIMAL:
- {
- long unsigned int* stringlength = new long unsigned int;
- *stringlength = (long unsigned int)(iItr->second.size());
-
- char* x = new char[(*stringlength+1)];
- strncpy(x,iItr->second.c_str(),*stringlength);
-
- bool* is_null = new bool;
- *is_null = 0;
- add_string_parameter(x,*stringlength,MYSQL_TYPE_VAR_STRING,is_null);
-
- temp_chanvars_holder.push_back(stringlength);
- temp_chanvars_holder.push_back(x);
- temp_chanvars_holder.push_back(is_null);
- break;
- }
- default:
- switch_console_printf(SWITCH_CHANNEL_LOG,"We should not get to this point in this switch/case statement.\n");
- }
- i++;
- }
+ if(sql_rc == SQLITE_BUSY)
+ sql_rc = switch_core_db_step(stmt);
+ else if (sql_rc == SQLITE_ERROR || sql_rc == SQLITE_MISUSE)
+ switch_console_printf(SWITCH_CHANNEL_LOG,"There was an error executing switch_core_db_step on SqliteCDR::stmt. The error was: %s\n",switch_core_db_errmsg(db));
}
-
- MYSQL_BIND *bindmetemp;
- bindmetemp = new MYSQL_BIND[bindme.size()];
- copy(bindme.begin(), bindme.end(), bindmetemp);
- for(int mysql_ping_result = -1, count = 0, mysql_stmt_error_code = -1; mysql_ping_result != 0 && count < 5 && mysql_stmt_error_code != 0 ; count++)
+ if(logchanvars && chanvars_supp.size())
{
- mysql_ping_result = mysql_ping(conn);
- if(mysql_ping_result)
+ sqlite_int64 rowid = switch_core_db_last_insert_rowid(db);
+ int column2 = 1;
+ std::map<std::string,std::string>::iterator iItr, iEnd;
+ for(iItr = chanvars_supp.begin(), iEnd = chanvars_supp.end(); iItr != iEnd; iItr++)
{
- switch(mysql_ping_result)
- {
- case CR_SERVER_GONE_ERROR:
- case CR_SERVER_LOST:
- {
- switch_console_printf(SWITCH_CHANNEL_LOG,"We lost connection to the MySQL server. Trying to reconnect.\n");
- connect_to_database();
- break;
- }
- default:
- {
- switch_console_printf(SWITCH_CHANNEL_LOG,"We have encountered an unknown error when pinging the MySQL server. Attempting to reconnect anyways.\n");
- connect_to_database();
- }
- }
+ switch_core_db_bind_int64(stmt_chanvars, column++, rowid);
+ switch_core_db_bind_text(stmt_chanvars, column++, iItr->first.c_str(),-1,SQLITE_STATIC);
+ switch_core_db_bind_text(stmt_chanvars, column++, iItr->second.c_str(),-1,SQLITE_STATIC);
}
- else
+
+ int sql_rc = switch_core_db_step(stmt_chanvars);
+ if(sql_rc != SQLITE_DONE)
{
- mysql_stmt_bind_param(stmt,bindmetemp);
- mysql_stmt_error_code = mysql_stmt_execute(stmt);
-
- if(mysql_stmt_error_code != 0)
- {
- errorstate = 1;
- switch_console_printf(SWITCH_CHANNEL_LOG,"MysqlCDR::process_record() - Statement executed? Error: %d\n",mysql_stmt_error_code);
-
- const char* mysql_stmt_error_string = mysql_stmt_error(stmt);
- switch_console_printf(SWITCH_CHANNEL_LOG,"MySQL encountered error: %s\n",mysql_stmt_error_string);
- }
- else
- errorstate = 0;
-
- if(logchanvars && chanvars_supp.size() > 0 && errorstate == 0)
- {
- long long insertid = mysql_stmt_insert_id(stmt);
-
- std::map<std::string,std::string>::iterator iItr,iBeg,iEnd;
- iEnd = chanvars_supp.end();
- for(iItr = chanvars_supp.begin(); iItr != iEnd; iItr++)
- {
- MYSQL_BIND bindme_chanvars[3];
- memset(bindme_chanvars,0,sizeof(bindme_chanvars));
-
- bindme_chanvars[0].buffer_type = MYSQL_TYPE_LONGLONG;
- bindme_chanvars[0].buffer = &insertid;
-
- std::vector<char> tempfirstvector(iItr->first.begin(), iItr->first.end());
- tempfirstvector.push_back('\0');
- char* varname_temp = &tempfirstvector[0];
-
- bindme_chanvars[1].buffer_type = MYSQL_TYPE_VAR_STRING;
- long unsigned int varname_length = (long unsigned int)(iItr->first.size());
- bindme_chanvars[1].length = &varname_length;
- bindme_chanvars[1].buffer_length = varname_length;
- bindme_chanvars[1].buffer = varname_temp;
-
- std::vector<char> tempsecondvector(iItr->second.begin(), iItr->second.end());
- tempsecondvector.push_back('\0');
- char* varvalue_temp = &tempsecondvector[0];
-
- bindme_chanvars[2].buffer_type = MYSQL_TYPE_VAR_STRING;
- if(iItr->second.size() == 0)
- bindme_chanvars[2].is_null = (my_bool*)1;
- else
- {
- long unsigned int varvalue_length = (long unsigned int)(iItr->second.size());
- bindme_chanvars[2].length = &varvalue_length;
- bindme_chanvars[2].buffer_length = varvalue_length;
- bindme_chanvars[2].buffer = varvalue_temp;
- }
-
- mysql_stmt_bind_param(stmt_chanvars,bindme_chanvars);
- mysql_stmt_execute(stmt_chanvars);
- }
- }
-
- if(errorstate == 0)
- mysql_commit(conn);
- else
- mysql_rollback(conn);
+ if(sql_rc == SQLITE_BUSY)
+ sql_rc = switch_core_db_step(stmt_chanvars);
+ else if (sql_rc == SQLITE_ERROR || sql_rc == SQLITE_MISUSE)
+ switch_console_printf(SWITCH_CHANNEL_LOG,"There was an error executing switch_core_db_step on SqliteCDR::stmt. The error was: %s\n",switch_core_db_errmsg(db));
}
}
- delete [] bindmetemp;
- if(temp_chanvars_holder.size() > 0)
- {
- std::string::size_type i = 0, j = chanvars_fixed_types.size();
- for(; i < j ; i++)
- {
- switch(chanvars_fixed_types[i])
- {
- case CDR_STRING:
- case CDR_DECIMAL:
- {
- long unsigned int* stringlength = (long unsigned int*)temp_chanvars_holder.front();
- temp_chanvars_holder.pop_front();
- delete stringlength;
- char* tempstring = (char*) temp_chanvars_holder.front();
- temp_chanvars_holder.pop_front();
- delete [] tempstring;
- break;
- }
- case CDR_INTEGER:
- {
- int* tempint = (int*) temp_chanvars_holder.front();
- temp_chanvars_holder.pop_front();
- delete tempint;
- break;
- }
- case CDR_DOUBLE:
- {
- double* tempdouble = (double*) temp_chanvars_holder.front();
- temp_chanvars_holder.pop_front();
- delete tempdouble;
- break;
- }
- case CDR_TINY:
- {
- short* tempshort = (short*) temp_chanvars_holder.front();
- temp_chanvars_holder.pop_front();
- delete tempshort;
- break;
- }
- default:
- switch_console_printf(SWITCH_CHANNEL_LOG,"We should not get to this point in this switch/case statement.\n");
- }
-
- bool* tempbool = (bool*) temp_chanvars_holder.front();
- temp_chanvars_holder.pop_front();
- delete tempbool;
- }
- }
+ switch_core_db_step(stmt_commit);
+
return 1;
}
1
0