提交 a93ddbd2 authored 作者: Anthony Minessale's avatar Anthony Minessale

presence crap

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6048 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 5b3f19fb
...@@ -4424,6 +4424,7 @@ static switch_status_t chat_send(char *proto, char *from, char *to, char *subjec ...@@ -4424,6 +4424,7 @@ static switch_status_t chat_send(char *proto, char *from, char *to, char *subjec
} else { } else {
switch_copy_string(name, to, sizeof(name)); switch_copy_string(name, to, sizeof(name));
} }
if (!(conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, name))) { if (!(conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, name))) {
ci->chat_send(CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", "Conference not active.", NULL); ci->chat_send(CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", "Conference not active.", NULL);
...@@ -4433,18 +4434,21 @@ static switch_status_t chat_send(char *proto, char *from, char *to, char *subjec ...@@ -4433,18 +4434,21 @@ static switch_status_t chat_send(char *proto, char *from, char *to, char *subjec
SWITCH_STANDARD_STREAM(stream); SWITCH_STANDARD_STREAM(stream);
if (body != NULL && (lbuf = strdup(body))) { if (body != NULL && (lbuf = strdup(body))) {
int argc; //int argc;
char *argv[25]; //char *argv[25];
memset(argv, 0, sizeof(argv));
argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
//memset(argv, 0, sizeof(argv));
//argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
/* try to find a command to execute */ /* try to find a command to execute */
if (argc) { //if (argc) {
/* special case list */ /* special case list */
if (strcasecmp(argv[0], "list") == 0) { if (switch_stristr("list", lbuf)) {
conference_list_pretty(conference, &stream); conference_list_pretty(conference, &stream);
/* provide help */ /* provide help */
}
else {
return SWITCH_STATUS_SUCCESS;
} }
#if 0 #if 0
else { else {
...@@ -4456,12 +4460,11 @@ static switch_status_t chat_send(char *proto, char *from, char *to, char *subjec ...@@ -4456,12 +4460,11 @@ static switch_status_t chat_send(char *proto, char *from, char *to, char *subjec
} }
} }
#endif #endif
} else { //} else {
stream.write_function(&stream, "No parameters specified.\nTry 'help'\n"); //stream.write_function(&stream, "No parameters specified.\nTry 'help'\n");
} //}
} }
switch_safe_free(lbuf); switch_safe_free(lbuf);
ci->chat_send(CONF_CHAT_PROTO, to, from, "", stream.data, NULL); ci->chat_send(CONF_CHAT_PROTO, to, from, "", stream.data, NULL);
switch_safe_free(stream.data); switch_safe_free(stream.data);
......
...@@ -1710,7 +1710,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sofia_shutdown) ...@@ -1710,7 +1710,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sofia_shutdown)
{ {
int sanity = 0; int sanity = 0;
sofia_presence_cancel(); //sofia_presence_cancel();
switch_mutex_lock(mod_sofia_globals.mutex); switch_mutex_lock(mod_sofia_globals.mutex);
if (mod_sofia_globals.running == 1) { if (mod_sofia_globals.running == 1) {
......
...@@ -248,7 +248,7 @@ struct sofia_profile { ...@@ -248,7 +248,7 @@ struct sofia_profile {
switch_mutex_t *gateway_mutex; switch_mutex_t *gateway_mutex;
sofia_gateway_t *gateways; sofia_gateway_t *gateways;
su_home_t *home; su_home_t *home;
switch_hash_t *profile_hash; switch_hash_t *sub_hash;
switch_hash_t *chat_hash; switch_hash_t *chat_hash;
switch_core_db_t *master_db; switch_core_db_t *master_db;
switch_thread_rwlock_t *rwlock; switch_thread_rwlock_t *rwlock;
......
...@@ -42,12 +42,24 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, ...@@ -42,12 +42,24 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
char const *phrase, char const *phrase,
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]); nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
void sofia_handle_sip_r_notify(switch_core_session_t *session, int status,
char const *phrase,
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
{
#if 0
if (status > 299) {
nua_handle_destroy(nh);
switch_core_hash_delete(profile->sub_hash, sip->sip_call_id->i_id);
}
#endif
}
void sofia_handle_sip_i_notify(switch_core_session_t *session, int status, void sofia_handle_sip_i_notify(switch_core_session_t *session, int status,
char const *phrase, char const *phrase,
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]) nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
{ {
switch_channel_t *channel = NULL; switch_channel_t *channel = NULL;
if (sip && sip->sip_event) { if (sip && sip->sip_event) {
char *type = (char *)sip->sip_event->o_type; char *type = (char *)sip->sip_event->o_type;
...@@ -177,7 +189,6 @@ void sofia_event_callback(nua_event_t event, ...@@ -177,7 +189,6 @@ void sofia_event_callback(nua_event_t event,
case nua_i_bye: case nua_i_bye:
case nua_r_unsubscribe: case nua_r_unsubscribe:
case nua_r_publish: case nua_r_publish:
case nua_r_notify:
case nua_i_cancel: case nua_i_cancel:
case nua_i_error: case nua_i_error:
case nua_i_active: case nua_i_active:
...@@ -185,6 +196,9 @@ void sofia_event_callback(nua_event_t event, ...@@ -185,6 +196,9 @@ void sofia_event_callback(nua_event_t event,
case nua_i_terminated: case nua_i_terminated:
case nua_r_set_params: case nua_r_set_params:
break; break;
case nua_r_notify:
sofia_handle_sip_r_notify(session, status, phrase, nua, profile, nh, sofia_private, sip, tags);
break;
case nua_i_notify: case nua_i_notify:
sofia_handle_sip_i_notify(session, status, phrase, nua, profile, nh, sofia_private, sip, tags); sofia_handle_sip_i_notify(session, status, phrase, nua, profile, nh, sofia_private, sip, tags);
break; break;
...@@ -462,6 +476,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void ...@@ -462,6 +476,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
sofia_glue_del_profile(profile); sofia_glue_del_profile(profile);
switch_core_hash_destroy(&profile->chat_hash); switch_core_hash_destroy(&profile->chat_hash);
switch_core_hash_destroy(&profile->sub_hash);
switch_thread_rwlock_unlock(profile->rwlock); switch_thread_rwlock_unlock(profile->rwlock);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write unlock %s\n", profile->name); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write unlock %s\n", profile->name);
...@@ -789,6 +804,7 @@ switch_status_t config_sofia(int reload, char *profile_name) ...@@ -789,6 +804,7 @@ switch_status_t config_sofia(int reload, char *profile_name)
profile->dbname = switch_core_strdup(profile->pool, url); profile->dbname = switch_core_strdup(profile->pool, url);
switch_core_hash_init(&profile->chat_hash, profile->pool); switch_core_hash_init(&profile->chat_hash, profile->pool);
switch_core_hash_init(&profile->sub_hash, profile->pool);
switch_thread_rwlock_create(&profile->rwlock, profile->pool); switch_thread_rwlock_create(&profile->rwlock, profile->pool);
switch_mutex_init(&profile->flag_mutex, SWITCH_MUTEX_NESTED, profile->pool); switch_mutex_init(&profile->flag_mutex, SWITCH_MUTEX_NESTED, profile->pool);
profile->dtmf_duration = 100; profile->dtmf_duration = 100;
......
...@@ -1684,7 +1684,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile) ...@@ -1684,7 +1684,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
switch_odbc_handle_exec(profile->master_odbc, reg_sql, NULL); switch_odbc_handle_exec(profile->master_odbc, reg_sql, NULL);
} }
if (switch_odbc_handle_exec(profile->master_odbc, "select contact from sip_subscriptions", NULL) != SWITCH_ODBC_SUCCESS) { if (switch_odbc_handle_exec(profile->master_odbc, "delete from sip_subscriptions", NULL) != SWITCH_ODBC_SUCCESS) {
switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_subscriptions", NULL); switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_subscriptions", NULL);
switch_odbc_handle_exec(profile->master_odbc, sub_sql, NULL); switch_odbc_handle_exec(profile->master_odbc, sub_sql, NULL);
} }
...@@ -1700,7 +1700,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile) ...@@ -1700,7 +1700,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
} }
switch_core_db_test_reactive(profile->master_db, "select call_id from sip_registrations", "DROP TABLE sip_registrations", reg_sql); switch_core_db_test_reactive(profile->master_db, "select call_id from sip_registrations", "DROP TABLE sip_registrations", reg_sql);
switch_core_db_test_reactive(profile->master_db, "select contact from sip_subscriptions", "DROP TABLE sip_subscriptions", sub_sql); switch_core_db_test_reactive(profile->master_db, "delete from sip_subscriptions", "DROP TABLE sip_subscriptions", sub_sql);
switch_core_db_test_reactive(profile->master_db, "select * from sip_authentication", "DROP TABLE sip_authentication", auth_sql); switch_core_db_test_reactive(profile->master_db, "select * from sip_authentication", "DROP TABLE sip_authentication", auth_sql);
#ifdef SWITCH_HAVE_ODBC #ifdef SWITCH_HAVE_ODBC
......
...@@ -344,7 +344,7 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han ...@@ -344,7 +344,7 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
char *register_gateway = NULL; char *register_gateway = NULL;
int network_port; int network_port;
int cd = 0; int cd = 0;
char *call_id = NULL; const char *call_id = NULL;
/* all callers must confirm that sip, sip->sip_request and sip->sip_contact are not NULL */ /* all callers must confirm that sip, sip->sip_request and sip->sip_contact are not NULL */
assert(sip != NULL && sip->sip_contact != NULL && sip->sip_request != NULL); assert(sip != NULL && sip->sip_contact != NULL && sip->sip_request != NULL);
...@@ -475,7 +475,7 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han ...@@ -475,7 +475,7 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
return 0; return 0;
} }
call_id = sip_header_as_string(profile->home, (void *) sip->sip_call_id); call_id = sip->sip_call_id->i_id; //sip_header_as_string(profile->home, (void *) sip->sip_call_id);
assert(call_id); assert(call_id);
...@@ -582,9 +582,11 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han ...@@ -582,9 +582,11 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
} }
/*
if (call_id) { if (call_id) {
su_free(profile->home, call_id); su_free(profile->home, call_id);
} }
*/
if (regtype == REG_REGISTER) { if (regtype == REG_REGISTER) {
char *new_contact = NULL; char *new_contact = NULL;
......
...@@ -199,22 +199,21 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(char *to, char *from, char *he ...@@ -199,22 +199,21 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(char *to, char *from, char *he
SWITCH_DECLARE(const char *) switch_stristr(const char *str, const char *instr) SWITCH_DECLARE(const char *) switch_stristr(const char *str, const char *instr)
{ {
switch_size_t score = strlen(str), x = 0; switch_size_t score = strlen(str), x = 0;
const char *a = str, *b = instr, *p = NULL; const char *a = str, *b = instr, *p = NULL;
while(*a && *b) {
while(*a && *b) { if (tolower(*b) == tolower(*a)) {
if (tolower(*b) == tolower(*a)) { if (++x == score) {
if (++x == score) { return b - x + 1;
return b - x + 1; }
} a++;
a++; } else {
} else { a = str;
a = str; p = b+1;
p = b+1;
x = 0; x = 0;
} }
b++; b++;
} }
return NULL; return NULL;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论