[asterisk-commits] mogorman: branch mogorman/asterisk-jabber r43184
- in /team/mogorman/asterisk...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Mon Sep 18 09:29:29 MST 2006
Author: mogorman
Date: Mon Sep 18 11:29:28 2006
New Revision: 43184
URL: http://svn.digium.com/view/asterisk?rev=43184&view=rev
Log:
up to date
Added:
team/mogorman/asterisk-jabber/configs/users.conf.sample
- copied unchanged from r43166, trunk/configs/users.conf.sample
Modified:
team/mogorman/asterisk-jabber/ (props changed)
team/mogorman/asterisk-jabber/Makefile.moddir_rules
team/mogorman/asterisk-jabber/agi/Makefile
team/mogorman/asterisk-jabber/apps/app_directory.c
team/mogorman/asterisk-jabber/apps/app_meetme.c
team/mogorman/asterisk-jabber/apps/app_voicemail.c
team/mogorman/asterisk-jabber/channels/chan_iax2.c
team/mogorman/asterisk-jabber/channels/chan_sip.c
team/mogorman/asterisk-jabber/channels/chan_skinny.c
team/mogorman/asterisk-jabber/channels/chan_zap.c
team/mogorman/asterisk-jabber/configs/extensions.conf.sample
team/mogorman/asterisk-jabber/configs/func_odbc.conf.sample
team/mogorman/asterisk-jabber/configs/indications.conf.sample
team/mogorman/asterisk-jabber/configs/skinny.conf.sample
team/mogorman/asterisk-jabber/configs/voicemail.conf.sample
team/mogorman/asterisk-jabber/configs/zapata.conf.sample
team/mogorman/asterisk-jabber/configure
team/mogorman/asterisk-jabber/configure.ac
team/mogorman/asterisk-jabber/doc/mp3.txt
team/mogorman/asterisk-jabber/include/asterisk/autoconfig.h.in
team/mogorman/asterisk-jabber/include/asterisk/compat.h
team/mogorman/asterisk-jabber/include/asterisk/config.h
team/mogorman/asterisk-jabber/include/asterisk/pbx.h
team/mogorman/asterisk-jabber/include/asterisk/strings.h
team/mogorman/asterisk-jabber/include/asterisk/utils.h
team/mogorman/asterisk-jabber/main/Makefile
team/mogorman/asterisk-jabber/main/asterisk.c
team/mogorman/asterisk-jabber/main/config.c
team/mogorman/asterisk-jabber/main/loader.c
team/mogorman/asterisk-jabber/main/manager.c
team/mogorman/asterisk-jabber/main/pbx.c
team/mogorman/asterisk-jabber/main/strcompat.c
team/mogorman/asterisk-jabber/main/utils.c
team/mogorman/asterisk-jabber/pbx/pbx_config.c
team/mogorman/asterisk-jabber/res/res_config_pgsql.c
team/mogorman/asterisk-jabber/utils/Makefile
Propchange: team/mogorman/asterisk-jabber/
------------------------------------------------------------------------------
Binary property 'branch-1.2-blocked' - no diff available.
Propchange: team/mogorman/asterisk-jabber/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.
Propchange: team/mogorman/asterisk-jabber/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Sep 18 11:29:28 2006
@@ -1,1 +1,1 @@
-/trunk:1-42788
+/trunk:1-43181
Modified: team/mogorman/asterisk-jabber/Makefile.moddir_rules
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-jabber/Makefile.moddir_rules?rev=43184&r1=43183&r2=43184&view=diff
==============================================================================
--- team/mogorman/asterisk-jabber/Makefile.moddir_rules (original)
+++ team/mogorman/asterisk-jabber/Makefile.moddir_rules Mon Sep 18 11:29:28 2006
@@ -34,7 +34,7 @@
define module_so_template
$(1)=$(1).so
-$(1).so: CFLAGS+=-fPIC
+$(1).so: CFLAGS+=-fpic
$(1).so: LIBS+=$(foreach dep,$(MENUSELECT_DEPENDS_$(1)),$$(value $(dep)_LIB))
$(1).so: LDFLAGS+=$(foreach dep,$(MENUSELECT_DEPENDS_$(1)),$$(value $(dep)_LDFLAGS))
$(1).so: $(2)
Modified: team/mogorman/asterisk-jabber/agi/Makefile
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-jabber/agi/Makefile?rev=43184&r1=43183&r2=43184&view=diff
==============================================================================
--- team/mogorman/asterisk-jabber/agi/Makefile (original)
+++ team/mogorman/asterisk-jabber/agi/Makefile Mon Sep 18 11:29:28 2006
@@ -16,16 +16,18 @@
AGIS=agi-test.agi eagi-test eagi-sphinx-test jukebox.agi
ifeq ($(OSARCH),SunOS)
- LIBS+=-lsocket -lnsl ../main/strcompat.o
+ LIBS+=-lsocket -lnsl
endif
include $(ASTTOPDIR)/Makefile.rules
all: $(AGIS)
-eagi-test: eagi-test.o
+eagi-test: eagi-test.o strcompat.o
eagi-sphinx-test: eagi-sphinx-test.o
+
+$(eval $(call ast_make_o_c,strcompat.o,../main/strcompat.c))
install: all
mkdir -p $(DESTDIR)$(AGI_DIR)
Modified: team/mogorman/asterisk-jabber/apps/app_directory.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-jabber/apps/app_directory.c?rev=43184&r1=43183&r2=43184&view=diff
==============================================================================
--- team/mogorman/asterisk-jabber/apps/app_directory.c (original)
+++ team/mogorman/asterisk-jabber/apps/app_directory.c Mon Sep 18 11:29:28 2006
@@ -393,10 +393,10 @@
return cfg;
}
-static int do_directory(struct ast_channel *chan, struct ast_config *cfg, char *context, char *dialcontext, char digit, int last, int readext, int fromappvm)
+static int do_directory(struct ast_channel *chan, struct ast_config *cfg, struct ast_config *ucfg, char *context, char *dialcontext, char digit, int last, int readext, int fromappvm)
{
/* Read in the first three digits.. "digit" is the first digit, already read */
- char ext[NUMDIGITS + 1];
+ char ext[NUMDIGITS + 1], *cat;
char name[80] = "";
struct ast_variable *v;
int res;
@@ -411,7 +411,7 @@
return -1;
}
if (digit == '0') {
- if (!ast_goto_if_exists(chan, chan->context, "o", 1) ||
+ if (!ast_goto_if_exists(chan, dialcontext, "o", 1) ||
(!ast_strlen_zero(chan->macrocontext) &&
!ast_goto_if_exists(chan, chan->macrocontext, "o", 1))) {
return 0;
@@ -422,7 +422,7 @@
}
}
if (digit == '*') {
- if (!ast_goto_if_exists(chan, chan->context, "a", 1) ||
+ if (!ast_goto_if_exists(chan, dialcontext, "a", 1) ||
(!ast_strlen_zero(chan->macrocontext) &&
!ast_goto_if_exists(chan, chan->macrocontext, "a", 1))) {
return 0;
@@ -499,6 +499,58 @@
}
}
+ if (!res && ucfg) {
+ /* Search users.conf for all names which start with those digits */
+ for (cat = ast_category_browse(ucfg, NULL); cat && !res ; cat = ast_category_browse(ucfg, cat)) {
+ if (!strcasecmp(cat, "general"))
+ continue;
+ if (!ast_true(ast_config_option(ucfg, cat, "hasdirectory")))
+ continue;
+
+ /* Find all candidate extensions */
+ if ((pos = ast_variable_retrieve(ucfg, cat, "fullname"))) {
+ ast_copy_string(name, pos, sizeof(name));
+ /* Grab the last name */
+ if (last && strrchr(pos,' '))
+ pos = strrchr(pos, ' ') + 1;
+ conv = convert(pos);
+ if (conv) {
+ if (!strcmp(conv, ext)) {
+ /* Match! */
+ found++;
+ /* We have a match -- play a greeting if they have it */
+ res = play_mailbox_owner(chan, context, dialcontext, cat, name, readext, fromappvm);
+ switch (res) {
+ case -1:
+ /* user pressed '1' but extension does not exist, or
+ * user hungup
+ */
+ lastuserchoice = 0;
+ break;
+ case '1':
+ /* user pressed '1' and extensions exists;
+ play_mailbox_owner will already have done
+ a goto() on the channel
+ */
+ lastuserchoice = res;
+ break;
+ case '*':
+ /* user pressed '*' to skip something found */
+ lastuserchoice = res;
+ res = 0;
+ break;
+ default:
+ break;
+ }
+ free(conv);
+ break;
+ }
+ free(conv);
+ }
+ }
+ }
+ }
+
if (lastuserchoice != '1') {
res = ast_streamfile(chan, found ? "dir-nomore" : "dir-nomatch", chan->language);
if (!res)
@@ -514,7 +566,7 @@
{
int res = 0;
struct ast_module_user *u;
- struct ast_config *cfg;
+ struct ast_config *cfg, *ucfg;
int last = 1;
int readext = 0;
int fromappvm = 0;
@@ -554,6 +606,8 @@
ast_module_user_remove(u);
return -1;
}
+
+ ucfg = ast_config_load("users.conf");
dirintro = ast_variable_retrieve(cfg, args.vmcontext, "directoryintro");
if (ast_strlen_zero(dirintro))
@@ -571,7 +625,7 @@
if (!res)
res = ast_waitfordigit(chan, 5000);
if (res > 0) {
- res = do_directory(chan, cfg, args.vmcontext, args.dialcontext, res, last, readext, fromappvm);
+ res = do_directory(chan, cfg, ucfg, args.vmcontext, args.dialcontext, res, last, readext, fromappvm);
if (res > 0) {
res = ast_waitstream(chan, AST_DIGIT_ANY);
ast_stopstream(chan);
@@ -581,6 +635,8 @@
}
break;
}
+ if (ucfg)
+ ast_config_destroy(ucfg);
ast_config_destroy(cfg);
ast_module_user_remove(u);
return res;
Modified: team/mogorman/asterisk-jabber/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-jabber/apps/app_meetme.c?rev=43184&r1=43183&r2=43184&view=diff
==============================================================================
--- team/mogorman/asterisk-jabber/apps/app_meetme.c (original)
+++ team/mogorman/asterisk-jabber/apps/app_meetme.c Mon Sep 18 11:29:28 2006
@@ -1432,6 +1432,8 @@
}
}
} else if(currentmarked >= 1 && lastmarked == 0) {
+ /* Marked user entered, so cancel timeout */
+ timeout = 0;
if (confflags & CONFFLAG_MONITOR)
ztc.confmode = ZT_CONF_CONFMON | ZT_CONF_LISTENER;
else if (confflags & CONFFLAG_TALKER)
Modified: team/mogorman/asterisk-jabber/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-jabber/apps/app_voicemail.c?rev=43184&r1=43183&r2=43184&view=diff
==============================================================================
--- team/mogorman/asterisk-jabber/apps/app_voicemail.c (original)
+++ team/mogorman/asterisk-jabber/apps/app_voicemail.c Mon Sep 18 11:29:28 2006
@@ -404,6 +404,8 @@
#define tdesc "Comedian Mail (Voicemail System)"
#endif
+static char userscontext[AST_MAX_EXTENSION] = "default";
+
static char *addesc = "Comedian Mail";
static char *synopsis_vm =
@@ -641,9 +643,32 @@
}
}
+static void apply_options_full(struct ast_vm_user *retval, struct ast_variable *var)
+{
+ struct ast_variable *tmp;
+ tmp = var;
+ while (tmp) {
+ if (!strcasecmp(tmp->name, "password")) {
+ ast_copy_string(retval->password, tmp->value, sizeof(retval->password));
+ } else if (!strcasecmp(tmp->name, "uniqueid")) {
+ ast_copy_string(retval->uniqueid, tmp->value, sizeof(retval->uniqueid));
+ } else if (!strcasecmp(tmp->name, "pager")) {
+ ast_copy_string(retval->pager, tmp->value, sizeof(retval->pager));
+ } else if (!strcasecmp(tmp->name, "email")) {
+ ast_copy_string(retval->email, tmp->value, sizeof(retval->email));
+ } else if (!strcasecmp(tmp->name, "fullname")) {
+ ast_copy_string(retval->fullname, tmp->value, sizeof(retval->fullname));
+ } else if (!strcasecmp(tmp->name, "context")) {
+ ast_copy_string(retval->context, tmp->value, sizeof(retval->context));
+ } else
+ apply_option(retval, tmp->name, tmp->value);
+ tmp = tmp->next;
+ }
+}
+
static struct ast_vm_user *find_user_realtime(struct ast_vm_user *ivm, const char *context, const char *mailbox)
{
- struct ast_variable *var, *tmp;
+ struct ast_variable *var;
struct ast_vm_user *retval;
if ((retval = (ivm ? ivm : ast_calloc(1, sizeof(*retval))))) {
@@ -659,25 +684,7 @@
else
var = ast_load_realtime("voicemail", "mailbox", mailbox, "context", context, NULL);
if (var) {
- tmp = var;
- while (tmp) {
- printf("%s => %s\n", tmp->name, tmp->value);
- if (!strcasecmp(tmp->name, "password")) {
- ast_copy_string(retval->password, tmp->value, sizeof(retval->password));
- } else if (!strcasecmp(tmp->name, "uniqueid")) {
- ast_copy_string(retval->uniqueid, tmp->value, sizeof(retval->uniqueid));
- } else if (!strcasecmp(tmp->name, "pager")) {
- ast_copy_string(retval->pager, tmp->value, sizeof(retval->pager));
- } else if (!strcasecmp(tmp->name, "email")) {
- ast_copy_string(retval->email, tmp->value, sizeof(retval->email));
- } else if (!strcasecmp(tmp->name, "fullname")) {
- ast_copy_string(retval->fullname, tmp->value, sizeof(retval->fullname));
- } else if (!strcasecmp(tmp->name, "context")) {
- ast_copy_string(retval->context, tmp->value, sizeof(retval->context));
- } else
- apply_option(retval, tmp->name, tmp->value);
- tmp = tmp->next;
- }
+ apply_options_full(retval, var);
ast_variables_destroy(var);
} else {
if (!ivm)
@@ -6573,6 +6580,26 @@
return res;
}
+static struct ast_vm_user *find_or_create(char *context, char *mbox)
+{
+ struct ast_vm_user *vmu;
+ AST_LIST_TRAVERSE(&users, vmu, list) {
+ if (ast_test_flag((&globalflags), VM_SEARCH) && !strcasecmp(mbox, vmu->mailbox))
+ break;
+ if (context && (!strcasecmp(context, vmu->context)) && (!strcasecmp(mbox, vmu->mailbox)))
+ break;
+ }
+
+ if (!vmu) {
+ if ((vmu = ast_calloc(1, sizeof(*vmu)))) {
+ ast_copy_string(vmu->context, context, sizeof(vmu->context));
+ ast_copy_string(vmu->mailbox, mbox, sizeof(vmu->mailbox));
+ AST_LIST_INSERT_TAIL(&users, vmu, list);
+ }
+ }
+ return vmu;
+}
+
static int append_mailbox(char *context, char *mbox, char *data)
{
/* Assumes lock is already held */
@@ -6582,10 +6609,7 @@
struct ast_vm_user *vmu;
ast_copy_string(tmp, data, sizeof(tmp));
- if ((vmu = ast_calloc(1, sizeof(*vmu)))) {
- ast_copy_string(vmu->context, context, sizeof(vmu->context));
- ast_copy_string(vmu->mailbox, mbox, sizeof(vmu->mailbox));
-
+ if ((vmu = find_or_create(context, mbox))) {
populate_defaults(vmu);
stringp = tmp;
@@ -6599,8 +6623,6 @@
ast_copy_string(vmu->pager, s, sizeof(vmu->pager));
if (stringp && (s = strsep(&stringp, ",")))
apply_options(vmu, s);
-
- AST_LIST_INSERT_TAIL(&users, vmu, list);
}
return 0;
}
@@ -6813,7 +6835,7 @@
{
struct ast_vm_user *cur;
struct vm_zone *zcur;
- struct ast_config *cfg;
+ struct ast_config *cfg, *ucfg;
char *cat;
struct ast_variable *var;
char *notifystr = NULL;
@@ -6843,6 +6865,7 @@
char *thresholdstr;
char *fmt;
char *astemail;
+ char *ucontext;
char *astmailcmd = SENDMAIL;
char *astforcename;
char *astforcegreet;
@@ -6874,6 +6897,9 @@
if (cfg) {
/* General settings */
+ if (!(ucontext = ast_variable_retrieve(cfg, "general", "userscontext")))
+ ucontext = "default";
+ ast_copy_string(userscontext, ucontext, sizeof(userscontext));
/* Attach voice message to mail message ? */
if (!(astattach = ast_variable_retrieve(cfg, "general", "attach")))
astattach = "yes";
@@ -7159,6 +7185,18 @@
if (!(astdirfwd = ast_variable_retrieve(cfg, "general", "usedirectory")))
astdirfwd = "no";
ast_set2_flag((&globalflags), ast_true(astdirfwd), VM_DIRECFORWARD);
+ if ((ucfg = ast_config_load("users.conf"))) {
+ for (cat = ast_category_browse(ucfg, NULL); cat ; cat = ast_category_browse(ucfg, cat)) {
+ if (!ast_true(ast_config_option(ucfg, cat, "hasvoicemail")))
+ continue;
+ if ((cur = find_or_create(userscontext, cat))) {
+ populate_defaults(cur);
+ apply_options_full(cur, ast_variable_browse(ucfg, cat));
+ ast_copy_string(cur->context, userscontext, sizeof(cur->context));
+ }
+ }
+ ast_config_destroy(ucfg);
+ }
cat = ast_category_browse(cfg, NULL);
while (cat) {
if (strcasecmp(cat, "general")) {
@@ -7421,11 +7459,10 @@
int res = 0;
#ifdef IMAP_STORAGE
char origtimeS[256],cidS[256],contextS[256];
- char *header_content,*filename,*temp;
-#else
+ char *header_content,*temp;
+#endif
char filename[256];
struct ast_config *msg_cfg;
-#endif
char *origtime, *cid, *context, *name, *num;
int retries = 0;
@@ -7473,8 +7510,8 @@
origtimeS[0] = '\0';
origtime = &origtimeS[0];
-
- filename = "IMAP_STORAGE";
+
+ strcpy(filename, "IMAP_STORAGE");
#else
make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg);
Modified: team/mogorman/asterisk-jabber/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-jabber/channels/chan_iax2.c?rev=43184&r1=43183&r2=43184&view=diff
==============================================================================
--- team/mogorman/asterisk-jabber/channels/chan_iax2.c (original)
+++ team/mogorman/asterisk-jabber/channels/chan_iax2.c Mon Sep 18 11:29:28 2006
@@ -798,8 +798,9 @@
static int send_command_transfer(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int);
static struct ast_channel *iax2_request(const char *type, int format, void *data, int *cause);
static struct ast_frame *iax2_read(struct ast_channel *c);
-static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, int temponly);
-static struct iax2_user *build_user(const char *name, struct ast_variable *v, int temponly);
+static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly);
+static struct iax2_user *build_user(const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly);
+static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, time_t regtime);
static void destroy_user(struct iax2_user *user);
static void prune_peers(void);
@@ -2445,7 +2446,7 @@
if (!var)
return NULL;
- peer = build_peer(peername, var, ast_test_flag((&globalflags), IAX_RTCACHEFRIENDS) ? 0 : 1);
+ peer = build_peer(peername, var, NULL, ast_test_flag((&globalflags), IAX_RTCACHEFRIENDS) ? 0 : 1);
if (!peer)
return NULL;
@@ -2496,6 +2497,7 @@
time(&nowtime);
if ((nowtime - regseconds) > IAX_DEFAULT_REG_EXPIRE) {
memset(&peer->addr, 0, sizeof(peer->addr));
+ realtime_update_peer(peer->name, &peer->addr, 0);
if (option_debug)
ast_log(LOG_DEBUG, "realtime_peer: Bah, '%s' is expired (%d/%d/%d)!\n",
peername, (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
@@ -2532,7 +2534,7 @@
tmp = tmp->next;
}
- user = build_user(username, var, !ast_test_flag((&globalflags), IAX_RTCACHEFRIENDS));
+ user = build_user(username, var, NULL, !ast_test_flag((&globalflags), IAX_RTCACHEFRIENDS));
if (!user)
return NULL;
@@ -8214,17 +8216,20 @@
/*! \brief Create peer structure based on configuration */
-static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, int temponly)
+static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly)
{
struct iax2_peer *peer = NULL;
struct ast_ha *oldha = NULL;
int maskfound=0;
int found=0;
+ int firstpass=1;
AST_LIST_LOCK(&peers);
if (!temponly) {
AST_LIST_TRAVERSE(&peers, peer, entry) {
if (!strcmp(peer->name, name)) {
+ if (!ast_test_flag(peer, IAX_DELME))
+ firstpass = 0;
break;
}
}
@@ -8232,8 +8237,10 @@
peer = NULL;
if (peer) {
found++;
- oldha = peer->ha;
- peer->ha = NULL;
+ if (firstpass) {
+ oldha = peer->ha;
+ peer->ha = NULL;
+ }
AST_LIST_REMOVE(&peers, peer, entry);
AST_LIST_UNLOCK(&peers);
} else {
@@ -8249,25 +8256,29 @@
}
}
if (peer) {
- ast_copy_flags(peer, &globalflags, IAX_USEJITTERBUF | IAX_FORCEJITTERBUF);
- peer->encmethods = iax2_encryption;
- peer->adsi = adsi;
- /* NOT ANY MORE: peer->secret[0] = '\0'; */
- ast_string_field_set(peer,secret,"");
- if (!found) {
- ast_string_field_set(peer, name, name);
- peer->addr.sin_port = htons(IAX_DEFAULT_PORTNO);
- peer->expiry = min_reg_expire;
- }
- peer->prefs = prefs;
- peer->capability = iax2_capability;
- peer->smoothing = 0;
- peer->pokefreqok = DEFAULT_FREQ_OK;
- peer->pokefreqnotok = DEFAULT_FREQ_NOTOK;
- /* NO MORE: peer->context[0] = '\0';
- peer->peercontext[0] = '\0'; */
- ast_string_field_set(peer,context,"");
- ast_string_field_set(peer,peercontext,"");
+ if (firstpass) {
+ ast_copy_flags(peer, &globalflags, IAX_USEJITTERBUF | IAX_FORCEJITTERBUF);
+ peer->encmethods = iax2_encryption;
+ peer->adsi = adsi;
+ ast_string_field_set(peer,secret,"");
+ if (!found) {
+ ast_string_field_set(peer, name, name);
+ peer->addr.sin_port = htons(IAX_DEFAULT_PORTNO);
+ peer->expiry = min_reg_expire;
+ }
+ peer->prefs = prefs;
+ peer->capability = iax2_capability;
+ peer->smoothing = 0;
+ peer->pokefreqok = DEFAULT_FREQ_OK;
+ peer->pokefreqnotok = DEFAULT_FREQ_NOTOK;
+ ast_string_field_set(peer,context,"");
+ ast_string_field_set(peer,peercontext,"");
+ }
+
+ if (!v) {
+ v = alt;
+ alt = NULL;
+ }
while(v) {
if (!strcasecmp(v->name, "secret")) {
ast_string_field_set(peer, secret, v->value);
@@ -8374,6 +8385,12 @@
ast_string_field_set(peer, cid_name, name2);
ast_string_field_set(peer, cid_num, num2);
ast_set_flag(peer, IAX_HASCALLERID);
+ } else if (!strcasecmp(v->name, "fullname")) {
+ ast_string_field_set(peer, cid_name, v->value);
+ ast_set_flag(peer, IAX_HASCALLERID);
+ } else if (!strcasecmp(v->name, "cid_number")) {
+ ast_string_field_set(peer, cid_num, v->value);
+ ast_set_flag(peer, IAX_HASCALLERID);
} else if (!strcasecmp(v->name, "sendani")) {
ast_set2_flag(peer, ast_true(v->value), IAX_SENDANI);
} else if (!strcasecmp(v->name, "inkeys")) {
@@ -8405,7 +8422,11 @@
peer->adsi = ast_true(v->value);
}/* else if (strcasecmp(v->name,"type")) */
/* ast_log(LOG_WARNING, "Ignoring %s\n", v->name); */
- v=v->next;
+ v = v->next;
+ if (!v) {
+ v = alt;
+ alt = NULL;
+ }
}
if (!peer->authmethods)
peer->authmethods = IAX_AUTH_MD5 | IAX_AUTH_PLAINTEXT;
@@ -8419,13 +8440,14 @@
}
/*! \brief Create in-memory user structure from configuration */
-static struct iax2_user *build_user(const char *name, struct ast_variable *v, int temponly)
+static struct iax2_user *build_user(const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly)
{
struct iax2_user *user = NULL;
struct iax2_context *con, *conl = NULL;
struct ast_ha *oldha = NULL;
struct iax2_context *oldcon = NULL;
int format;
+ int firstpass=1;
int oldcurauthreq = 0;
char *varname = NULL, *varval = NULL;
struct ast_variable *tmpvar = NULL;
@@ -8434,18 +8456,22 @@
if (!temponly) {
AST_LIST_TRAVERSE(&users, user, entry) {
if (!strcmp(user->name, name)) {
+ if (!ast_test_flag(user, IAX_DELME))
+ firstpass = 0;
break;
}
}
} else
user = NULL;
-
+
if (user) {
- oldcurauthreq = user->curauthreq;
- oldha = user->ha;
- oldcon = user->contexts;
- user->ha = NULL;
- user->contexts = NULL;
+ if (firstpass) {
+ oldcurauthreq = user->curauthreq;
+ oldha = user->ha;
+ oldcon = user->contexts;
+ user->ha = NULL;
+ user->contexts = NULL;
+ }
/* Already in the list, remove it and it will be added back (or FREE'd) */
AST_LIST_REMOVE(&users, user, entry);
AST_LIST_UNLOCK(&users);
@@ -8453,22 +8479,30 @@
AST_LIST_UNLOCK(&users);
/* This is going to memset'd to 0 in the next block */
user = ast_calloc(sizeof(*user),1);
- if (ast_string_field_init(user, 32)) {
- free(user);
- user = NULL;
- }
}
if (user) {
- user->maxauthreq = maxauthreq;
- user->curauthreq = oldcurauthreq;
- user->prefs = prefs;
- user->capability = iax2_capability;
- user->encmethods = iax2_encryption;
- user->adsi = adsi;
- ast_string_field_set(user, name, name);
- ast_string_field_set(user, language, language);
- ast_copy_flags(user, &globalflags, IAX_USEJITTERBUF | IAX_FORCEJITTERBUF | IAX_CODEC_USER_FIRST | IAX_CODEC_NOPREFS | IAX_CODEC_NOCAP);
+ if (firstpass) {
+ ast_string_field_free_all(user);
+ memset(user, 0, sizeof(struct iax2_user));
+ if (ast_string_field_init(user, 32)) {
+ free(user);
+ user = NULL;
+ }
+ user->maxauthreq = maxauthreq;
+ user->curauthreq = oldcurauthreq;
+ user->prefs = prefs;
+ user->capability = iax2_capability;
+ user->encmethods = iax2_encryption;
+ user->adsi = adsi;
+ ast_string_field_set(user, name, name);
+ ast_string_field_set(user, language, language);
+ ast_copy_flags(user, &globalflags, IAX_USEJITTERBUF | IAX_FORCEJITTERBUF | IAX_CODEC_USER_FIRST | IAX_CODEC_NOPREFS | IAX_CODEC_NOCAP);
+ }
+ if (!v) {
+ v = alt;
+ alt = NULL;
+ }
while(v) {
if (!strcasecmp(v->name, "context")) {
con = build_context(v->value);
@@ -8548,6 +8582,12 @@
ast_string_field_set(user, cid_name, name2);
ast_string_field_set(user, cid_num, num2);
ast_set_flag(user, IAX_HASCALLERID);
+ } else if (!strcasecmp(v->name, "fullname")) {
+ ast_string_field_set(user, cid_name, v->value);
+ ast_set_flag(user, IAX_HASCALLERID);
+ } else if (!strcasecmp(v->name, "cid_number")) {
+ ast_string_field_set(user, cid_num, v->value);
+ ast_set_flag(user, IAX_HASCALLERID);
} else if (!strcasecmp(v->name, "accountcode")) {
ast_string_field_set(user, accountcode, v->value);
} else if (!strcasecmp(v->name, "mohinterpret")) {
@@ -8574,6 +8614,10 @@
}/* else if (strcasecmp(v->name,"type")) */
/* ast_log(LOG_WARNING, "Ignoring %s\n", v->name); */
v = v->next;
+ if (!v) {
+ v = alt;
+ alt = NULL;
+ }
}
if (!user->authmethods) {
if (!ast_strlen_zero(user->secret)) {
@@ -8720,7 +8764,7 @@
/*! \brief Load configuration */
static int set_config(char *config_file, int reload)
{
- struct ast_config *cfg;
+ struct ast_config *cfg, *ucfg;
int capability=iax2_capability;
struct ast_variable *v;
char *cat;
@@ -8973,13 +9017,71 @@
min_reg_expire = max_reg_expire;
}
iax2_capability = capability;
+
+ ucfg = ast_config_load("users.conf");
+ if (ucfg) {
+ struct ast_variable *gen;
+ int genhasiax;
+ int genregisteriax;
+ char *hasiax, *registeriax;
+
+ genhasiax = ast_true(ast_variable_retrieve(ucfg, "general", "hasiax"));
+ genregisteriax = ast_true(ast_variable_retrieve(ucfg, "general", "registeriax"));
+ gen = ast_variable_browse(ucfg, "general");
+ cat = ast_category_browse(ucfg, NULL);
+ while (cat) {
+ if (strcasecmp(cat, "general")) {
+ hasiax = ast_variable_retrieve(ucfg, cat, "hasiax");
+ registeriax = ast_variable_retrieve(ucfg, cat, "registeriax");
+ if (ast_true(hasiax) || (!hasiax && genhasiax)) {
+ /* Start with general parameters, then specific parameters, user and peer */
+ user = build_user(cat, gen, ast_variable_browse(ucfg, cat), 0);
+ if (user) {
+ AST_LIST_LOCK(&users);
+ AST_LIST_INSERT_HEAD(&users, user, entry);
+ AST_LIST_UNLOCK(&users);
+ }
+ peer = build_peer(cat, gen, ast_variable_browse(ucfg, cat), 0);
+ if (peer) {
+ AST_LIST_LOCK(&peers);
+ AST_LIST_INSERT_HEAD(&peers, peer, entry);
+ AST_LIST_UNLOCK(&peers);
+ if (ast_test_flag(peer, IAX_DYNAMIC))
+ reg_source_db(peer);
+ }
+ }
+ if (ast_true(registeriax) || (!registeriax && genregisteriax)) {
+ char tmp[256];
+ char *host = ast_variable_retrieve(ucfg, cat, "host");
+ char *username = ast_variable_retrieve(ucfg, cat, "username");
+ char *secret = ast_variable_retrieve(ucfg, cat, "secret");
+ if (!host)
+ host = ast_variable_retrieve(ucfg, "general", "host");
+ if (!username)
+ username = ast_variable_retrieve(ucfg, "general", "username");
+ if (!secret)
+ secret = ast_variable_retrieve(ucfg, "general", "secret");
+ if (!ast_strlen_zero(username) && !ast_strlen_zero(host)) {
+ if (!ast_strlen_zero(secret))
+ snprintf(tmp, sizeof(tmp), "%s:%s@%s", username, secret, host);
+ else
+ snprintf(tmp, sizeof(tmp), "%s@%s", username, host);
+ iax2_register(tmp, 0);
+ }
+ }
+ }
+ cat = ast_category_browse(ucfg, cat);
+ }
+ ast_config_destroy(ucfg);
+ }
+
cat = ast_category_browse(cfg, NULL);
while(cat) {
if (strcasecmp(cat, "general")) {
utype = ast_variable_retrieve(cfg, cat, "type");
if (utype) {
if (!strcasecmp(utype, "user") || !strcasecmp(utype, "friend")) {
- user = build_user(cat, ast_variable_browse(cfg, cat), 0);
+ user = build_user(cat, ast_variable_browse(cfg, cat), NULL, 0);
if (user) {
AST_LIST_LOCK(&users);
AST_LIST_INSERT_HEAD(&users, user, entry);
@@ -8987,7 +9089,7 @@
}
}
if (!strcasecmp(utype, "peer") || !strcasecmp(utype, "friend")) {
- peer = build_peer(cat, ast_variable_browse(cfg, cat), 0);
+ peer = build_peer(cat, ast_variable_browse(cfg, cat), NULL, 0);
if (peer) {
AST_LIST_LOCK(&peers);
AST_LIST_INSERT_HEAD(&peers, peer, entry);
Modified: team/mogorman/asterisk-jabber/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-jabber/channels/chan_sip.c?rev=43184&r1=43183&r2=43184&view=diff
==============================================================================
--- team/mogorman/asterisk-jabber/channels/chan_sip.c (original)
+++ team/mogorman/asterisk-jabber/channels/chan_sip.c Mon Sep 18 11:29:28 2006
@@ -1365,7 +1365,7 @@
/*--- Device object handling */
static struct sip_peer *temp_peer(const char *name);
-static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int realtime);
+static struct sip_peer *build_peer(const char *name, struct ast_variable *v, struct ast_variable *alt, int realtime);
static struct sip_user *build_user(const char *name, struct ast_variable *v, int realtime);
static int update_call_counter(struct sip_pvt *fup, int event);
static void sip_destroy_peer(struct sip_peer *peer);
@@ -2357,7 +2357,7 @@
}
/* Peer found in realtime, now build it in memory */
- peer = build_peer(newpeername, var, !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS));
+ peer = build_peer(newpeername, var, NULL, !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS));
if (!peer) {
ast_variables_destroy(var);
return NULL;
@@ -4776,9 +4776,8 @@
if ((sscanf(a, "T38FaxMaxBuffer:%d", &x) == 1)) {
found = 1;
if (option_debug > 2)
- ast_log(LOG_DEBUG,"MaxBufferSize:%d\n",x);
- }
- if ((sscanf(a, "T38MaxBitRate:%d", &x) == 1)) {
+ ast_log(LOG_DEBUG, "MaxBufferSize:%d\n",x);
+ } else if ((sscanf(a, "T38MaxBitRate:%d", &x) == 1)) {
found = 1;
if (option_debug > 2)
ast_log(LOG_DEBUG,"T38MaxBitRate: %d\n",x);
@@ -4802,57 +4801,51 @@
peert38capability |= T38FAX_RATE_2400;
break;
}
- }
- if ((sscanf(a, "T38FaxVersion:%d", &x) == 1)) {
+ } else if ((sscanf(a, "T38FaxVersion:%d", &x) == 1)) {
found = 1;
if (option_debug > 2)
- ast_log(LOG_DEBUG,"FaxVersion: %d\n",x);
+ ast_log(LOG_DEBUG, "FaxVersion: %d\n",x);
if (x == 0)
peert38capability |= T38FAX_VERSION_0;
else if (x == 1)
peert38capability |= T38FAX_VERSION_1;
- }
- if ((sscanf(a, "T38FaxMaxDatagram:%d", &x) == 1)) {
+ } else if ((sscanf(a, "T38FaxMaxDatagram:%d", &x) == 1)) {
found = 1;
if (option_debug > 2)
- ast_log(LOG_DEBUG,"FaxMaxDatagram: %d\n",x);
+ ast_log(LOG_DEBUG, "FaxMaxDatagram: %d\n",x);
ast_udptl_set_far_max_datagram(p->udptl, x);
ast_udptl_set_local_max_datagram(p->udptl, x);
- }
- if ((sscanf(a, "T38FaxFillBitRemoval:%d", &x) == 1)) {
+ } else if ((sscanf(a, "T38FaxFillBitRemoval:%d", &x) == 1)) {
found = 1;
if (option_debug > 2)
- ast_log(LOG_DEBUG,"FillBitRemoval: %d\n",x);
+ ast_log(LOG_DEBUG, "FillBitRemoval: %d\n",x);
if (x == 1)
peert38capability |= T38FAX_FILL_BIT_REMOVAL;
- }
- if ((sscanf(a, "T38FaxTranscodingMMR:%d", &x) == 1)) {
+ } else if ((sscanf(a, "T38FaxTranscodingMMR:%d", &x) == 1)) {
found = 1;
if (option_debug > 2)
- ast_log(LOG_DEBUG,"Transcoding MMR: %d\n",x);
+ ast_log(LOG_DEBUG, "Transcoding MMR: %d\n",x);
if (x == 1)
peert38capability |= T38FAX_TRANSCODING_MMR;
}
if ((sscanf(a, "T38FaxTranscodingJBIG:%d", &x) == 1)) {
found = 1;
if (option_debug > 2)
- ast_log(LOG_DEBUG,"Transcoding JBIG: %d\n",x);
+ ast_log(LOG_DEBUG, "Transcoding JBIG: %d\n",x);
if (x == 1)
peert38capability |= T38FAX_TRANSCODING_JBIG;
- }
- if ((sscanf(a, "T38FaxRateManagement:%s", s) == 1)) {
+ } else if ((sscanf(a, "T38FaxRateManagement:%s", s) == 1)) {
found = 1;
if (option_debug > 2)
- ast_log(LOG_DEBUG,"RateMangement: %s\n", s);
+ ast_log(LOG_DEBUG, "RateMangement: %s\n", s);
if (!strcasecmp(s, "localTCF"))
peert38capability |= T38FAX_RATE_MANAGEMENT_LOCAL_TCF;
else if (!strcasecmp(s, "transferredTCF"))
peert38capability |= T38FAX_RATE_MANAGEMENT_TRANSFERED_TCF;
- }
- if ((sscanf(a, "T38FaxUdpEC:%s", s) == 1)) {
+ } else if ((sscanf(a, "T38FaxUdpEC:%s", s) == 1)) {
found = 1;
if (option_debug > 2)
- ast_log(LOG_DEBUG,"UDP EC: %s\n", s);
+ ast_log(LOG_DEBUG, "UDP EC: %s\n", s);
if (!strcasecmp(s, "t38UDPRedundancy")) {
peert38capability |= T38FAX_UDP_EC_REDUNDANCY;
ast_udptl_set_error_correction_scheme(p->udptl, UDPTL_ERROR_CORRECTION_REDUNDANCY);
@@ -4872,7 +4865,7 @@
p->t38.jointcapability |= (peert38capability & p->t38.capability); /* Put the lower of our's and peer's speed */
}
if (debug)
- ast_log(LOG_DEBUG,"Our T38 capability = (%d), peer T38 capability (%d), joint T38 capability (%d)\n",
+ ast_log(LOG_DEBUG, "Our T38 capability = (%d), peer T38 capability (%d), joint T38 capability (%d)\n",
p->t38.capability,
p->t38.peercapability,
p->t38.jointcapability);
@@ -6003,7 +5996,7 @@
if (option_debug > 2)
ast_log(LOG_DEBUG, "-- Done with adding codecs to SDP\n");
- if(!ast_internal_timing_enabled(p->owner))
+ if(!p->owner || !ast_internal_timing_enabled(p->owner))
ast_build_string(&a_audio_next, &a_audio_left, "a=silenceSupp:off - - - -\r\n");
if ((m_audio_left < 2) || (m_video_left < 2) || (a_audio_left == 0) || (a_video_left == 0))
@@ -13087,7 +13080,7 @@
break;
}
} else {
- if (p && !ast_test_flag(&p->flags[0], SIP_NEEDDESTROY)) {
+ if (p && p->autokillid > -1) {
const char *msg;
if (!p->jointcapability)
@@ -15125,6 +15118,10 @@
ast_copy_string(user->md5secret, v->value, sizeof(user->md5secret));
} else if (!strcasecmp(v->name, "callerid")) {
ast_callerid_split(v->value, user->cid_name, sizeof(user->cid_name), user->cid_num, sizeof(user->cid_num));
+ } else if (!strcasecmp(v->name, "fullname")) {
+ ast_copy_string(user->cid_name, v->value, sizeof(user->cid_name));
+ } else if (!strcasecmp(v->name, "cid_number")) {
+ ast_copy_string(user->cid_num, v->value, sizeof(user->cid_num));
} else if (!strcasecmp(v->name, "callgroup")) {
user->callgroup = ast_get_group(v->value);
} else if (!strcasecmp(v->name, "pickupgroup")) {
@@ -15250,12 +15247,13 @@
}
/*! \brief Build peer from configuration (file or realtime static/dynamic) */
-static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int realtime)
+static struct sip_peer *build_peer(const char *name, struct ast_variable *v, struct ast_variable *alt, int realtime)
{
struct sip_peer *peer = NULL;
struct ast_ha *oldha = NULL;
int obproxyfound=0;
int found=0;
+ int firstpass=1;
int format=0; /* Ama flags */
time_t regseconds = 0;
char *varname = NULL, *varval = NULL;
@@ -15275,6 +15273,8 @@
if (peer) {
/* Already in the list, remove it and it will be added back (or FREE'd) */
found++;
+ if (!(peer->objflags & ASTOBJ_FLAG_MARKED))
+ firstpass = 0;
} else {
if (!(peer = ast_calloc(1, sizeof(*peer))))
return NULL;
@@ -15286,11 +15286,12 @@
ASTOBJ_INIT(peer);
}
/* Note that our peer HAS had its reference count incrased */
-
- peer->lastmsgssent = -1;
- oldha = peer->ha;
- peer->ha = NULL;
- set_peer_defaults(peer); /* Set peer defaults */
+ if (firstpass) {
+ peer->lastmsgssent = -1;
+ oldha = peer->ha;
+ peer->ha = NULL;
+ set_peer_defaults(peer); /* Set peer defaults */
+ }
if (!found && name)
ast_copy_string(peer->name, name, sizeof(peer->name));
@@ -15300,7 +15301,7 @@
peer->chanvars = NULL;
/* XXX should unregister ? */
}
- for (; v; v = v->next) {
+ for (; v || ((v = alt) && !(alt=NULL)); v = v->next) {
if (handle_common_options(&peerflags[0], &mask[0], v))
continue;
if (realtime && !strcasecmp(v->name, "regseconds")) {
@@ -15320,6 +15321,10 @@
peer->auth = add_realm_authentication(peer->auth, v->value, v->lineno);
else if (!strcasecmp(v->name, "callerid")) {
ast_callerid_split(v->value, peer->cid_name, sizeof(peer->cid_name), peer->cid_num, sizeof(peer->cid_num));
+ } else if (!strcasecmp(v->name, "fullname")) {
+ ast_copy_string(peer->cid_name, v->value, sizeof(peer->cid_name));
+ } else if (!strcasecmp(v->name, "cid_number")) {
+ ast_copy_string(peer->cid_num, v->value, sizeof(peer->cid_num));
} else if (!strcasecmp(v->name, "context")) {
ast_copy_string(peer->context, v->value, sizeof(peer->context));
} else if (!strcasecmp(v->name, "subscribecontext")) {
@@ -15508,7 +15513,7 @@
*/
static int reload_config(enum channelreloadreason reason)
{
- struct ast_config *cfg;
+ struct ast_config *cfg, *ucfg;
struct ast_variable *v;
struct sip_peer *peer;
struct sip_user *user;
@@ -15870,6 +15875,58 @@
authl = add_realm_authentication(authl, v->value, v->lineno);
}
+ ucfg = ast_config_load("users.conf");
+ if (ucfg) {
+ struct ast_variable *gen;
+ int genhassip, genregistersip;
+ char *hassip, *registersip;
+
+ genhassip = ast_true(ast_variable_retrieve(ucfg, "general", "hassip"));
+ genregistersip = ast_true(ast_variable_retrieve(ucfg, "general", "registersip"));
+ gen = ast_variable_browse(ucfg, "general");
+ cat = ast_category_browse(ucfg, NULL);
+ while (cat) {
+ if (strcasecmp(cat, "general")) {
+ hassip = ast_variable_retrieve(ucfg, cat, "hassip");
+ registersip = ast_variable_retrieve(ucfg, cat, "registersip");
+ if (ast_true(hassip) || (!hassip && genhassip)) {
+ peer = build_peer(cat, gen, ast_variable_browse(ucfg, cat), 0);
+ if (peer) {
+ ASTOBJ_CONTAINER_LINK(&peerl,peer);
+ ASTOBJ_UNREF(peer, sip_destroy_peer);
+ peer_count++;
+ }
+ }
+ if (ast_true(registersip) || (!registersip && genregistersip)) {
+ char tmp[256];
+ char *host = ast_variable_retrieve(ucfg, cat, "host");
+ char *username = ast_variable_retrieve(ucfg, cat, "username");
+ char *secret = ast_variable_retrieve(ucfg, cat, "secret");
+ char *contact = ast_variable_retrieve(ucfg, cat, "contact");
+ if (!host)
+ host = ast_variable_retrieve(ucfg, "general", "host");
+ if (!username)
+ username = ast_variable_retrieve(ucfg, "general", "username");
+ if (!secret)
+ secret = ast_variable_retrieve(ucfg, "general", "secret");
+ if (!contact)
+ contact = "s";
+ if (!ast_strlen_zero(username) && !ast_strlen_zero(host)) {
+ if (!ast_strlen_zero(secret))
+ snprintf(tmp, sizeof(tmp), "%s:%s@%s/%s", username, secret, host, contact);
+ else
+ snprintf(tmp, sizeof(tmp), "%s@%s/%s", username, host, contact);
+ if (sip_register(tmp, 0) == 0)
+ registry_count++;
+ }
+ }
+ }
+ cat = ast_category_browse(ucfg, cat);
+ }
+ ast_config_destroy(ucfg);
+ }
+
+
/* Load peers, users and friends */
cat = NULL;
while ( (cat = ast_category_browse(cfg, cat)) ) {
@@ -15901,7 +15958,7 @@
}
}
if (is_peer) {
- peer = build_peer(cat, ast_variable_browse(cfg, cat), 0);
+ peer = build_peer(cat, ast_variable_browse(cfg, cat), NULL, 0);
if (peer) {
ASTOBJ_CONTAINER_LINK(&peerl,peer);
ASTOBJ_UNREF(peer, sip_destroy_peer);
Modified: team/mogorman/asterisk-jabber/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-jabber/channels/chan_skinny.c?rev=43184&r1=43183&r2=43184&view=diff
==============================================================================
--- team/mogorman/asterisk-jabber/channels/chan_skinny.c (original)
+++ team/mogorman/asterisk-jabber/channels/chan_skinny.c Mon Sep 18 11:29:28 2006
@@ -139,67 +139,67 @@
[... 3149 lines stripped ...]
More information about the asterisk-commits
mailing list