[asterisk-commits] mmichelson: branch group/issue8824 r169425 - in /team/group/issue8824: ./ app...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jan 19 14:28:10 CST 2009
Author: mmichelson
Date: Mon Jan 19 14:28:10 2009
New Revision: 169425
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=169425
Log:
Resolve conflict and reset automerge
Modified:
team/group/issue8824/ (props changed)
team/group/issue8824/apps/app_userevent.c
team/group/issue8824/channels/chan_skinny.c
team/group/issue8824/main/asterisk.c
team/group/issue8824/main/manager.c
Propchange: team/group/issue8824/
------------------------------------------------------------------------------
automerge = *
Propchange: team/group/issue8824/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Propchange: team/group/issue8824/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jan 19 14:28:10 2009
@@ -1,1 +1,1 @@
-/trunk:1-169336
+/trunk:1-169403
Modified: team/group/issue8824/apps/app_userevent.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/issue8824/apps/app_userevent.c?view=diff&rev=169425&r1=169424&r2=169425
==============================================================================
--- team/group/issue8824/apps/app_userevent.c (original)
+++ team/group/issue8824/apps/app_userevent.c Mon Jan 19 14:28:10 2009
@@ -58,15 +58,22 @@
static int userevent_exec(struct ast_channel *chan, void *data)
{
- char *parse, buf[2048] = "";
- int x, buflen = 0;
+ char *parse;
+ int x;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(eventname);
AST_APP_ARG(extra)[100];
);
+ struct ast_str *body = ast_str_create(16);
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "UserEvent requires an argument (eventname,optional event body)\n");
+ ast_free(body);
+ return -1;
+ }
+
+ if (!body) {
+ ast_log(LOG_WARNING, "Unable to allocate buffer\n");
return -1;
}
@@ -75,13 +82,11 @@
AST_STANDARD_APP_ARGS(args, parse);
for (x = 0; x < args.argc - 1; x++) {
- ast_copy_string(buf + buflen, args.extra[x], sizeof(buf) - buflen - 2);
- buflen += strlen(args.extra[x]);
- ast_copy_string(buf + buflen, "\r\n", 3);
- buflen += 2;
+ ast_str_append(&body, 0, "%s\r\n", args.extra[x]);
}
- manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n%s", args.eventname, buf);
+ manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n%s", args.eventname, ast_str_buffer(body));
+ ast_free(body);
return 0;
}
Modified: team/group/issue8824/channels/chan_skinny.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/issue8824/channels/chan_skinny.c?view=diff&rev=169425&r1=169424&r2=169425
==============================================================================
--- team/group/issue8824/channels/chan_skinny.c (original)
+++ team/group/issue8824/channels/chan_skinny.c Mon Jan 19 14:28:10 2009
@@ -1192,6 +1192,7 @@
AST_LIST_ENTRY(skinny_line) all;
struct skinny_device *device;
struct ast_variable *chanvars; /*!< Channel variables to set for inbound call */
+ int newmsgs;
};
struct skinny_line_options{
@@ -1321,6 +1322,7 @@
static int skinny_senddigit_begin(struct ast_channel *ast, char digit);
static int skinny_senddigit_end(struct ast_channel *ast, char digit, unsigned int duration);
static int handle_time_date_req_message(struct skinny_req *req, struct skinnysession *s);
+static void mwi_event_cb(const struct ast_event *event, void *userdata);
static const struct ast_channel_tech skinny_tech = {
.type = "Skinny",
@@ -1849,8 +1851,11 @@
/* l->capability = d->capability;
l->prefs = d->prefs; */
l->instance = instance;
+ l->newmsgs = ast_app_has_voicemail(l->mailbox, NULL);
set_callforwards(l, NULL, 0);
register_exten(l);
+ /* initialize MWI on line and device */
+ mwi_event_cb(0, l);
ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Skinny/%s@%s", l->name, d->name);
}
--instance;
@@ -2501,14 +2506,6 @@
return 0;
}
-static void mwi_event_cb(const struct ast_event *event, void *userdata)
-{
- /* This module does not handle MWI in an event-based manner. However, it
- * subscribes to MWI for each mailbox that is configured so that the core
- * knows that we care about it. Then, chan_skinny will get the MWI from the
- * event cache instead of checking the mailbox directly. */
-}
-
static void update_connectedline(struct skinny_subchannel *sub, const void *data, size_t datalen)
{
struct ast_channel *c = sub->owner;
@@ -2546,59 +2543,46 @@
}
}
-static int has_voicemail(struct skinny_line *l)
-{
- int new_msgs;
- struct ast_event *event;
- char *mbox, *context;
-
- context = mbox = ast_strdupa(l->mailbox);
- strsep(&context, "@");
- if (ast_strlen_zero(context))
- context = "default";
-
- event = ast_event_get_cached(AST_EVENT_MWI,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mbox,
- AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context,
- AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_EXISTS,
- AST_EVENT_IE_END);
-
- if (event) {
- new_msgs = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS);
- ast_event_destroy(event);
- } else
- new_msgs = ast_app_has_voicemail(l->mailbox, NULL);
-
- return new_msgs;
+static void mwi_event_cb(const struct ast_event *event, void *userdata)
+{
+ struct skinny_line *l = userdata;
+ struct skinny_device *d = l->device;
+ struct skinnysession *s = d->session;
+ struct skinny_line *l2;
+ int new_msgs = 0;
+ int dev_msgs = 0;
+
+ if (s) {
+ if (event) {
+ l->newmsgs = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS);
+ }
+
+ if (l->newmsgs) {
+ transmit_lamp_indication(d, STIMULUS_VOICEMAIL, l->instance, l->mwiblink?SKINNY_LAMP_BLINK:SKINNY_LAMP_ON);
+ } else {
+ transmit_lamp_indication(d, STIMULUS_VOICEMAIL, l->instance, SKINNY_LAMP_OFF);
+ }
+
+ /* find out wether the device lamp should be on or off */
+ AST_LIST_TRAVERSE(&d->lines, l2, list) {
+ if (l2->newmsgs) {
+ dev_msgs++;
+ }
+ }
+
+ if (dev_msgs) {
+ transmit_lamp_indication(d, STIMULUS_VOICEMAIL, 0, d->mwiblink?SKINNY_LAMP_BLINK:SKINNY_LAMP_ON);
+ } else {
+ transmit_lamp_indication(d, STIMULUS_VOICEMAIL, 0, SKINNY_LAMP_OFF);
+ }
+ ast_verb(3, "Skinny mwi_event_cb found %d new messages\n", new_msgs);
+ }
}
static void do_housekeeping(struct skinnysession *s)
{
- int device_lamp = 0;
- struct skinny_device *d = s->device;
- struct skinny_line *l;
-
/* Update time on device */
handle_time_date_req_message(NULL, s);
-
- /* Set MWI on individual lines */
- AST_LIST_TRAVERSE(&d->lines, l, list) {
- if (has_voicemail(l)) {
- if (skinnydebug)
- ast_verb(1, "Checking for voicemail Skinny %s@%s\n", l->name, d->name);
- if (skinnydebug)
- ast_verb(1, "Skinny %s@%s has voicemail!\n", l->name, d->name);
- transmit_lamp_indication(d, STIMULUS_VOICEMAIL, l->instance, l->mwiblink?SKINNY_LAMP_BLINK:SKINNY_LAMP_ON);
- device_lamp++;
- } else {
- transmit_lamp_indication(d, STIMULUS_VOICEMAIL, l->instance, SKINNY_LAMP_OFF);
- }
- }
- /* If at least one line has VM, turn the device level lamp on */
- if (device_lamp)
- transmit_lamp_indication(d, STIMULUS_VOICEMAIL, 0, SKINNY_LAMP_ON);
- else
- transmit_lamp_indication(d, STIMULUS_VOICEMAIL, 0, SKINNY_LAMP_OFF);
}
/* I do not believe skinny can deal with video.
@@ -6645,7 +6629,7 @@
strsep(&cfg_context, "@");
if (ast_strlen_zero(cfg_context))
cfg_context = "default";
- l->mwi_event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb, NULL,
+ l->mwi_event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb, l,
AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, cfg_mailbox,
AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, cfg_context,
AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_EXISTS,
Modified: team/group/issue8824/main/asterisk.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/issue8824/main/asterisk.c?view=diff&rev=169425&r1=169424&r2=169425
==============================================================================
--- team/group/issue8824/main/asterisk.c (original)
+++ team/group/issue8824/main/asterisk.c Mon Jan 19 14:28:10 2009
@@ -549,7 +549,7 @@
#elif defined(HAVE_SYSCTL) && !defined(HAVE_SYSINFO)
static int swapmode(int *used, int *total)
{
- used = total = 0;
+ *used = *total = 0;
return 1;
}
#endif
Modified: team/group/issue8824/main/manager.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/issue8824/main/manager.c?view=diff&rev=169425&r1=169424&r2=169425
==============================================================================
--- team/group/issue8824/main/manager.c (original)
+++ team/group/issue8824/main/manager.c Mon Jan 19 14:28:10 2009
@@ -910,6 +910,8 @@
* initialize the thread local storage key.
*/
AST_THREADSTORAGE(astman_append_buf);
+AST_THREADSTORAGE(userevent_buf);
+
/*! \brief initial allocated size for the astman_append_buf */
#define ASTMAN_APPEND_BUF_INITSIZE 256
@@ -2599,18 +2601,15 @@
static int action_userevent(struct mansession *s, const struct message *m)
{
const char *event = astman_get_header(m, "UserEvent");
- char body[2048] = "";
- int x, bodylen = 0;
+ struct ast_str *body = ast_str_thread_get(&userevent_buf, 16);
+ int x;
for (x = 0; x < m->hdrcount; x++) {
if (strncasecmp("UserEvent:", m->headers[x], strlen("UserEvent:"))) {
- ast_copy_string(body + bodylen, m->headers[x], sizeof(body) - bodylen - 3);
- bodylen += strlen(m->headers[x]);
- ast_copy_string(body + bodylen, "\r\n", 3);
- bodylen += 2;
- }
- }
-
- manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n%s", event, body);
+ ast_str_append(&body, 0, "%s\r\n", m->headers[x]);
+ }
+ }
+
+ manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n%s", event, ast_str_buffer(body));
return 0;
}
More information about the asterisk-commits
mailing list