No subject


Thu Jul 12 09:23:04 CDT 2007


........

................
r79109 | qwell | 2007-08-10 16:29:31 -0500 (Fri, 10 Aug 2007) | 4 lines

Use localized softkey labels.

Add some information about localization "codes".

................
r79147 | tilghman | 2007-08-11 00:28:08 -0500 (Sat, 11 Aug 2007) | 10 lines

Merged revisions 79142 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r79142 | tilghman | 2007-08-11 00:23:04 -0500 (Sat, 11 Aug 2007) | 2 lines

Ensure the connection gets marked as used at allocation time (closes issue #10429, report and fix by mnicholson)

........

................
r79175 | file | 2007-08-13 09:22:46 -0500 (Mon, 13 Aug 2007) | 12 lines

Merged revisions 79174 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r79174 | file | 2007-08-13 11:18:04 -0300 (Mon, 13 Aug 2007) | 4 lines

(closes issue #10437)
Reported by: haklin
Don't set the callerid name and number a second time on a newly created channel. ast_channel_alloc itself already sets it and setting it twice would cause a memory leak.

........

................
r79176 | russell | 2007-08-13 09:23:38 -0500 (Mon, 13 Aug 2007) | 1 line

constify the return value of reason2str
................
r79208 | file | 2007-08-13 09:55:17 -0500 (Mon, 13 Aug 2007) | 10 lines

Merged revisions 79207 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r79207 | file | 2007-08-13 11:51:09 -0300 (Mon, 13 Aug 2007) | 2 lines

Add an API call to allow the engine to know that DTMF was received.

........

................
r79222 | russell | 2007-08-13 10:32:05 -0500 (Mon, 13 Aug 2007) | 12 lines

Merged revisions 79214 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r79214 | russell | 2007-08-13 10:28:13 -0500 (Mon, 13 Aug 2007) | 4 lines

Fix a potential deadlock in socket_process.  check_provisioning can eventually
call find_callno.  You can't hold a pvt lock while calling find_callno because
it goes through and locks every single one looking for a match.

........

................
r79238 | mmichelson | 2007-08-13 10:39:48 -0500 (Mon, 13 Aug 2007) | 5 lines

Allow non-realtime queues to have realtime members

(issue #10424, reported and patched by irroot)


................
r79273 | russell | 2007-08-13 14:29:30 -0500 (Mon, 13 Aug 2007) | 17 lines

Merged revisions 79272 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r79272 | russell | 2007-08-13 14:27:39 -0500 (Mon, 13 Aug 2007) | 9 lines

I am fighting deadlocks in chan_iax2.  I have tracked them down to a single
core issue.  You can not call find_callno() while holding a pvt lock as this
function has to lock another (every) other pvt lock.  Doing so can lead to a
classic deadlock.  So, I am tracking down all of the code paths where this
can happen and fixing them.

The fix I committed earlier today was along the same theme.  This patch fixes
some code down the path of authenticate_reply.

........

................
r79275 | russell | 2007-08-13 15:06:19 -0500 (Mon, 13 Aug 2007) | 11 lines

Merged revisions 79274 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r79274 | russell | 2007-08-13 15:02:57 -0500 (Mon, 13 Aug 2007) | 3 lines

Don't call find_peer within update_registry with a pvt lock held.  This can
cause a deadlock as the code will eventually call find_callno.

........

................
r79277 | russell | 2007-08-13 15:20:43 -0500 (Mon, 13 Aug 2007) | 12 lines

Merged revisions 79276 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r79276 | russell | 2007-08-13 15:18:30 -0500 (Mon, 13 Aug 2007) | 4 lines

Release the pvt lock before calling find_peer in register_verify to avoid a
deadlock.  Also, remove some unnecessary locking in auth_fail that was only done
recursively.

........

................
r79306 | russell | 2007-08-13 15:40:47 -0500 (Mon, 13 Aug 2007) | 11 lines

Merged revisions 79301 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r79301 | russell | 2007-08-13 15:37:50 -0500 (Mon, 13 Aug 2007) | 3 lines

Don't call find_peer in registry_authrequest with the pvt lock held to avoid a
deadlock.

........

................
r79333 | tilghman | 2007-08-13 16:44:22 -0500 (Mon, 13 Aug 2007) | 2 lines

Only use the sanitysql if it's not zero-len

................
r79335 | file | 2007-08-13 16:59:15 -0500 (Mon, 13 Aug 2007) | 10 lines

Merged revisions 79334 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r79334 | file | 2007-08-13 18:57:20 -0300 (Mon, 13 Aug 2007) | 2 lines

Instead of accepting a single DTMF character accept a full string.

........

................
r79378 | murf | 2007-08-14 08:46:58 -0500 (Tue, 14 Aug 2007) | 1 line

Don't ask me why, but waitfordigit will immediately return a 1 on my system, unless the outfd is initialized to -1 before calling the nandfds func
................
r79379 | file | 2007-08-14 09:17:43 -0500 (Tue, 14 Aug 2007) | 4 lines

(closes issue #10427)
Reported by: pj
Two of the three places ast_waitfor_nandfds could branch off to did not clear outfd and exception. If the calling function did not clear these there was a chance they could get a false positive on testing to see whether they were set.

................
r79392 | murf | 2007-08-14 09:32:21 -0500 (Tue, 14 Aug 2007) | 9 lines

Merged revisions 79255 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r79255 | murf | 2007-08-13 11:49:54 -0600 (Mon, 13 Aug 2007) | 1 line

This patch fixes bug 10411. I added a new regression test, some regression test cleanups
........

................
r79403 | file | 2007-08-14 10:30:03 -0500 (Tue, 14 Aug 2007) | 12 lines

Merged revisions 79397 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r79397 | file | 2007-08-14 12:27:13 -0300 (Tue, 14 Aug 2007) | 4 lines

(closes issue #10415)
Reported by: atis
Revert fix for #10327 as it causes more issues then it solves.

........

................

Added:
    team/group/ast_storage/pbx/ael/ael-test/ael-vtest21/
      - copied from r79403, trunk/pbx/ael/ael-test/ael-vtest21/
    team/group/ast_storage/pbx/ael/ael-test/ael-vtest21/extensions.ael
      - copied unchanged from r79403, trunk/pbx/ael/ael-test/ael-vtest21/extensions.ael
    team/group/ast_storage/pbx/ael/ael-test/ref.ael-vtest21
      - copied unchanged from r79403, trunk/pbx/ael/ael-test/ref.ael-vtest21
Modified:
    team/group/ast_storage/   (props changed)
    team/group/ast_storage/CHANGES
    team/group/ast_storage/Makefile
    team/group/ast_storage/apps/app_meetme.c
    team/group/ast_storage/apps/app_minivm.c
    team/group/ast_storage/apps/app_queue.c
    team/group/ast_storage/apps/app_speech_utils.c
    team/group/ast_storage/apps/app_voicemail.c
    team/group/ast_storage/channels/chan_gtalk.c
    team/group/ast_storage/channels/chan_h323.c
    team/group/ast_storage/channels/chan_iax2.c
    team/group/ast_storage/channels/chan_jingle.c
    team/group/ast_storage/channels/chan_local.c
    team/group/ast_storage/channels/chan_mgcp.c
    team/group/ast_storage/channels/chan_misdn.c
    team/group/ast_storage/channels/chan_oss.c
    team/group/ast_storage/channels/chan_phone.c
    team/group/ast_storage/channels/chan_sip.c
    team/group/ast_storage/channels/chan_skinny.c
    team/group/ast_storage/channels/chan_zap.c
    team/group/ast_storage/configs/queues.conf.sample
    team/group/ast_storage/funcs/func_devstate.c
    team/group/ast_storage/include/asterisk/channel.h
    team/group/ast_storage/include/asterisk/devicestate.h
    team/group/ast_storage/include/asterisk/lock.h
    team/group/ast_storage/include/asterisk/speech.h
    team/group/ast_storage/main/cdr.c
    team/group/ast_storage/main/channel.c
    team/group/ast_storage/main/devicestate.c
    team/group/ast_storage/main/dial.c
    team/group/ast_storage/main/event.c
    team/group/ast_storage/main/file.c
    team/group/ast_storage/pbx/ael/ael-test/ael-test5/extensions.ael
    team/group/ast_storage/pbx/ael/ael-test/ael-test6/extensions.ael
    team/group/ast_storage/pbx/ael/ael-test/ref.ael-ntest10
    team/group/ast_storage/pbx/ael/ael-test/ref.ael-test1
    team/group/ast_storage/pbx/ael/ael-test/ref.ael-test11
    team/group/ast_storage/pbx/ael/ael-test/ref.ael-test14
    team/group/ast_storage/pbx/ael/ael-test/ref.ael-test19
    team/group/ast_storage/pbx/ael/ael-test/ref.ael-test2
    team/group/ast_storage/pbx/ael/ael-test/ref.ael-test3
    team/group/ast_storage/pbx/ael/ael-test/ref.ael-test4
    team/group/ast_storage/pbx/ael/ael-test/ref.ael-test6
    team/group/ast_storage/pbx/ael/ael-test/ref.ael-vtest13
    team/group/ast_storage/pbx/ael/ael-test/ref.ael-vtest17
    team/group/ast_storage/pbx/pbx_ael.c
    team/group/ast_storage/pbx/pbx_spool.c
    team/group/ast_storage/res/res_features.c
    team/group/ast_storage/res/res_odbc.c
    team/group/ast_storage/res/res_speech.c
    team/group/ast_storage/utils/ael_main.c

Propchange: team/group/ast_storage/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/group/ast_storage/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/group/ast_storage/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Aug 14 12:03:01 2007
@@ -1,1 +1,1 @@
-/trunk:1-78777
+/trunk:1-79431

Modified: team/group/ast_storage/CHANGES
URL: http://svn.digium.com/view/asterisk/team/group/ast_storage/CHANGES?view=diff&rev=79432&r1=79431&r2=79432
==============================================================================
--- team/group/ast_storage/CHANGES (original)
+++ team/group/ast_storage/CHANGES Tue Aug 14 12:03:01 2007
@@ -144,6 +144,7 @@
      position changes frequently.
   * Added additional information to EXITWITHTIMEOUT and EXITWITHKEY events in the
      queue log.
+  * Added ability for non-realtime queues to have realtime members
 
 MeetMe Changes
 --------------

Modified: team/group/ast_storage/Makefile
URL: http://svn.digium.com/view/asterisk/team/group/ast_storage/Makefile?view=diff&rev=79432&r1=79431&r2=79432
==============================================================================
--- team/group/ast_storage/Makefile (original)
+++ team/group/ast_storage/Makefile Tue Aug 14 12:03:01 2007
@@ -281,7 +281,11 @@
 	@echo " + Asterisk has successfully been built, and +"  
 	@echo " + can be installed by running:              +"
 	@echo " +                                           +"
+ifeq ($(MAKE), gmake)
+	@echo " +               $(MAKE) install               +"  
+else
 	@echo " +               $(MAKE) install                +"  
+endif
 	@echo " +-------------------------------------------+"  
 
 _all: cleantest $(SUBDIRS)
@@ -490,14 +494,22 @@
 	@echo " + configuration files (overwriting any      +"
 	@echo " + existing config files), run:              +"  
 	@echo " +                                           +"
+ifeq ($(MAKE), gmake)
+	@echo " +               $(MAKE) samples               +"
+else
 	@echo " +               $(MAKE) samples                +"
+endif
 	@echo " +                                           +"
 	@echo " +-----------------  or ---------------------+"
 	@echo " +                                           +"
 	@echo " + You can go ahead and install the asterisk +"
 	@echo " + program documentation now or later run:   +"
 	@echo " +                                           +"
+ifeq ($(MAKE), gmake)
+	@echo " +              $(MAKE) progdocs               +"
+else
 	@echo " +              $(MAKE) progdocs                +"
+endif
 	@echo " +                                           +"
 	@echo " + **Note** This requires that you have      +"
 	@echo " + doxygen installed on your local system    +"
@@ -669,7 +681,11 @@
 	@echo " + directories, and logs, run the following  +"
 	@echo " + command:                                  +"
 	@echo " +                                           +"
+ifeq ($(MAKE), gmake)
+	@echo " +            $(MAKE) uninstall-all            +"  
+else
 	@echo " +            $(MAKE) uninstall-all             +"  
+endif
 	@echo " +-------------------------------------------+"  
 
 uninstall-all: _uninstall

Modified: team/group/ast_storage/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/group/ast_storage/apps/app_meetme.c?view=diff&rev=79432&r1=79431&r2=79432
==============================================================================
--- team/group/ast_storage/apps/app_meetme.c (original)
+++ team/group/ast_storage/apps/app_meetme.c Tue Aug 14 12:03:01 2007
@@ -1513,7 +1513,7 @@
 
 	/* This device changed state now - if this is the first user */
 	if (conf->users == 1)
-		ast_device_state_changed("meetme:%s", conf->confno);
+		ast_devstate_changed(AST_DEVICE_INUSE, "meetme:%s", conf->confno);
 
 	ast_mutex_unlock(&conf->playlock);
 
@@ -2333,7 +2333,7 @@
 
 		/* Change any states */
 		if (!conf->users)
-			ast_device_state_changed("meetme:%s", conf->confno);
+			ast_devstate_changed(AST_DEVICE_NOT_INUSE, "meetme:%s", conf->confno);
 		
 		/* Return the number of seconds the user was in the conf */
 		snprintf(meetmesecs, sizeof(meetmesecs), "%d", (int) (time(NULL) - user->jointime));
@@ -3305,6 +3305,23 @@
 	return ringing_station;
 }
 
+static enum ast_device_state sla_state_to_devstate(enum sla_trunk_state state)
+{
+	switch (state) {
+	case SLA_TRUNK_STATE_IDLE:
+		return AST_DEVICE_NOT_INUSE;
+	case SLA_TRUNK_STATE_RINGING:
+		return AST_DEVICE_RINGING;
+	case SLA_TRUNK_STATE_UP:
+		return AST_DEVICE_INUSE;
+	case SLA_TRUNK_STATE_ONHOLD:
+	case SLA_TRUNK_STATE_ONHOLD_BYME:
+		return AST_DEVICE_ONHOLD;
+	}
+
+	return AST_DEVICE_UNKNOWN;
+}
+
 static void sla_change_trunk_state(const struct sla_trunk *trunk, enum sla_trunk_state state, 
 	enum sla_which_trunk_refs inactive_only, const struct sla_trunk_ref *exclude)
 {
@@ -3317,7 +3334,8 @@
 				|| trunk_ref == exclude)
 				continue;
 			trunk_ref->state = state;
-			ast_device_state_changed("SLA:%s_%s", station->name, trunk->name);
+			ast_devstate_changed(sla_state_to_devstate(state), 
+				"SLA:%s_%s", station->name, trunk->name);
 			break;
 		}
 	}
@@ -3809,7 +3827,7 @@
 {
 	ast_atomic_fetchadd_int((int *) &event->trunk_ref->trunk->hold_stations, 1);
 	event->trunk_ref->state = SLA_TRUNK_STATE_ONHOLD_BYME;
-	ast_device_state_changed("SLA:%s_%s", 
+	ast_devstate_changed(AST_DEVICE_ONHOLD, "SLA:%s_%s", 
 		event->station->name, event->trunk_ref->trunk->name);
 	sla_change_trunk_state(event->trunk_ref->trunk, SLA_TRUNK_STATE_ONHOLD, 
 		INACTIVE_TRUNK_REFS, event->trunk_ref);
@@ -4319,7 +4337,8 @@
 			sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_UP, ALL_TRUNK_REFS, NULL);
 		else {
 			trunk_ref->state = SLA_TRUNK_STATE_UP;
-			ast_device_state_changed("SLA:%s_%s", station->name, trunk_ref->trunk->name);
+			ast_devstate_changed(AST_DEVICE_INUSE, 
+				"SLA:%s_%s", station->name, trunk_ref->trunk->name);
 		}
 	}
 
@@ -4536,21 +4555,7 @@
 			AST_RWLIST_UNLOCK(&sla_trunks);
 			break;
 		}
-		switch (trunk_ref->state) {
-		case SLA_TRUNK_STATE_IDLE:
-			res = AST_DEVICE_NOT_INUSE;
-			break;
-		case SLA_TRUNK_STATE_RINGING:
-			res = AST_DEVICE_RINGING;
-			break;
-		case SLA_TRUNK_STATE_UP:
-			res = AST_DEVICE_INUSE;
-			break;
-		case SLA_TRUNK_STATE_ONHOLD:
-		case SLA_TRUNK_STATE_ONHOLD_BYME:
-			res = AST_DEVICE_ONHOLD;
-			break;
-		}
+		res = sla_state_to_devstate(trunk_ref->state);
 		AST_RWLIST_UNLOCK(&sla_trunks);
 	}
 	AST_RWLIST_UNLOCK(&sla_stations);

Modified: team/group/ast_storage/apps/app_minivm.c
URL: http://svn.digium.com/view/asterisk/team/group/ast_storage/apps/app_minivm.c?view=diff&rev=79432&r1=79431&r2=79432
==============================================================================
--- team/group/ast_storage/apps/app_minivm.c (original)
+++ team/group/ast_storage/apps/app_minivm.c Tue Aug 14 12:03:01 2007
@@ -2275,11 +2275,11 @@
 	       int len = strlen("\n");
 	       switch (tmpwrite[1]) {
 	       case 'n':
-		      strncpy(tmpwrite+len, tmpwrite+2, strlen(tmpwrite+2)+1);
+		      memmove(tmpwrite + len, tmpwrite + 2, strlen(tmpwrite + 2) + 1);
 		      strncpy(tmpwrite, "\n", len);
 		      break;
 	       case 't':
-		      strncpy(tmpwrite+len, tmpwrite+2, strlen(tmpwrite+2)+1);
+		      memmove(tmpwrite + len, tmpwrite + 2, strlen(tmpwrite + 2) + 1);
 		      strncpy(tmpwrite, "\t", len);
 		      break;
 	       default:

Modified: team/group/ast_storage/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/group/ast_storage/apps/app_queue.c?view=diff&rev=79432&r1=79431&r2=79432
==============================================================================
--- team/group/ast_storage/apps/app_queue.c (original)
+++ team/group/ast_storage/apps/app_queue.c Tue Aug 14 12:03:01 2007
@@ -410,6 +410,7 @@
 
 static AST_LIST_HEAD_STATIC(queues, call_queue);
 
+static void update_realtime_members(struct call_queue *q);
 static int set_member_paused(const char *queuename, const char *interface, int paused);
 
 static void set_queue_result(struct ast_channel *chan, enum queue_result res)
@@ -1254,6 +1255,8 @@
 			ast_variables_destroy(queue_vars);
 
 		AST_LIST_UNLOCK(&queues);
+	} else {
+		update_realtime_members(q);
 	}
 	return q;
 }

Modified: team/group/ast_storage/apps/app_speech_utils.c
URL: http://svn.digium.com/view/asterisk/team/group/ast_storage/apps/app_speech_utils.c?view=diff&rev=79432&r1=79431&r2=79432
==============================================================================
--- team/group/ast_storage/apps/app_speech_utils.c (original)
+++ team/group/ast_storage/apps/app_speech_utils.c Tue Aug 14 12:03:01 2007
@@ -701,6 +701,7 @@
 		/* We sort of make a results entry */
 		speech->results = ast_calloc(1, sizeof(*speech->results));
 		if (speech->results != NULL) {
+			ast_speech_dtmf(speech, dtmf);
 			speech->results->score = 1000;
 			speech->results->text = ast_strdup(dtmf);
 			speech->results->grammar = ast_strdup("dtmf");

Modified: team/group/ast_storage/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/group/ast_storage/apps/app_voicemail.c?view=diff&rev=79432&r1=79431&r2=79432
==============================================================================
--- team/group/ast_storage/apps/app_voicemail.c (original)
+++ team/group/ast_storage/apps/app_voicemail.c Tue Aug 14 12:03:01 2007
@@ -1681,8 +1681,6 @@
 	copy(frompath2, topath2);
 	ast_variables_destroy(var);
 }
-#endif
-
 /*! \brief
  * A negative return value indicates an error.
  * \note Should always be called with a lock already set on dir.
@@ -1714,8 +1712,8 @@
 	return x - 1;
 }
 
-#endif
-
+#endif /*#ifndef IMAP_STORAGE*/
+#endif /*#else of #ifdef ODBC_STORAGE*/
 #ifndef ODBC_STORAGE
 static int vm_delete(char *file)
 {
@@ -2294,8 +2292,39 @@
 	};
 	return (id >= 0 && id < (sizeof(msgs)/sizeof(msgs[0]))) ? msgs[id] : "Unknown";
 }
+#ifdef IMAP_STORAGE
+static int folder_int(const char *folder)
+{
+	/*assume a NULL folder means INBOX*/
+	if (!folder)
+		return 0;
+	if(!strcasecmp(folder, "INBOX"))
+		return 0;
+	else if (!strcasecmp(folder, "Old"))
+		return 1;
+	else if (!strcasecmp(folder, "Work"))
+		return 2;
+	else if (!strcasecmp(folder, "Family"))
+		return 3;
+	else if (!strcasecmp(folder, "Friends"))
+		return 4;
+	else if (!strcasecmp(folder, "Cust1"))
+		return 5;
+	else if (!strcasecmp(folder, "Cust2"))
+		return 6;
+	else if (!strcasecmp(folder, "Cust3"))
+		return 7;
+	else if (!strcasecmp(folder, "Cust4"))
+		return 8;
+	else if (!strcasecmp(folder, "Cust5"))
+		return 9;
+	else /*assume they meant INBOX if folder is not found otherwise*/
+		return 0;
+}
+#endif
 
 #ifdef ODBC_STORAGE
+/*! XXX \todo Fix this function to support multiple mailboxes in the intput string */
 static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs)
 {
 	int x = -1;
@@ -2520,66 +2549,24 @@
 
 }
 
-static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs)
+static int messagecount(const char *context, const char *mailbox, const char *folder)
 {
 	SEARCHPGM *pgm;
 	SEARCHHEADER *hdr;
  
- 	struct ast_vm_user *vmu;
- 	struct vm_state *vms_p;
- 	char tmp[256] = "";
- 	char *mb, *cur;
- 	char *mailboxnc; 
- 	char *context;
- 	int ret = 0;
-
- 	if (newmsgs)
- 		*newmsgs = 0;
-
- 	if (oldmsgs)
- 		*oldmsgs = 0;
- 
-	 ast_debug(3,"Mailbox is set to %s\n",mailbox);
-
- 	/* If no mailbox, return immediately */
- 	if (ast_strlen_zero(mailbox)) 
- 		return 0;
-
- 	if (strchr(mailbox, ',')) {
- 		int tmpnew, tmpold;
-		ast_copy_string(tmp, mailbox, sizeof(tmp));
- 		mb = tmp;
- 		ret = 0;
- 		while((cur = strsep(&mb, ", "))) {
- 			if (!ast_strlen_zero(cur)) {
- 				if (inboxcount(cur, newmsgs ? &tmpnew : NULL, oldmsgs ? &tmpold : NULL))
- 					return -1;
- 				else {
- 					if (newmsgs)
- 						*newmsgs += tmpnew; 
- 					if (oldmsgs)
- 						*oldmsgs += tmpold;
- 				}
- 			}
- 		}
- 		return 0;
- 	}
-
-	ast_copy_string(tmp, mailbox, sizeof(tmp));
-
-	if ((context = strchr(tmp, '@'))) {
- 		*context = '\0';
- 		mailboxnc = tmp;
- 		context++;
- 	} else {
- 		context = "default";
- 		mailboxnc = (char *)mailbox;
- 	}
- 
- 	/* We have to get the user before we can open the stream! */
- 	/*ast_debug(1,"Before find_user, context is %s and mailbox is %s\n",context,mailbox); */
-	if (!(vmu = find_user(NULL, context, mailboxnc))) {
-		ast_log(LOG_ERROR, "Couldn't find mailbox %s in context %s\n", mailboxnc, context);
+	struct ast_vm_user *vmu;
+	struct vm_state *vms_p;
+	int ret = 0;
+	int fold = folder_int(folder);
+	
+	if (ast_strlen_zero(mailbox))
+		return 0;
+
+	/* We have to get the user before we can open the stream! */
+	/* ast_log (LOG_DEBUG,"Before find_user, context is %s and mailbox is %s\n",context,mailbox); */
+	vmu = find_user(NULL, context, mailbox);
+	if (!vmu) {
+		ast_log (LOG_ERROR,"Couldn't find mailbox %s in context %s\n",mailbox,context);
 		return -1;
 	}
 	
@@ -2590,110 +2577,184 @@
 		return -1;
  	}
 
- 	/* check if someone is accessing this box right now... */
-	if ((vms_p = get_vm_state_by_imapuser(vmu->imapuser, 1)) || (vms_p = get_vm_state_by_mailbox(mailboxnc, 1))) {
-		ast_debug(3,"Returning before search - user is logged in\n");
- 		*newmsgs = vms_p->newmessages;
- 		*oldmsgs = vms_p->oldmessages;
-		free_user(vmu);
- 		return 0;
- 	}
-
- 	/* add one if not there... */
-	if (!(vms_p = get_vm_state_by_imapuser(vmu->imapuser, 0)) && !(vms_p = get_vm_state_by_mailbox(mailboxnc, 0))) {
+	/* check if someone is accessing this box right now... */
+	vms_p = get_vm_state_by_imapuser(vmu->imapuser,1);
+	if (!vms_p) {
+		vms_p = get_vm_state_by_mailbox(mailbox,1);
+	}
+	if (vms_p) {
+		ast_debug(3, "Returning before search - user is logged in\n");
+		if(fold == 0) {/*INBOX*/
+			free_user(vmu);
+			return vms_p->newmessages;
+		}
+		if(fold == 1) {/*Old messages*/
+			free_user(vmu);
+		 	return vms_p->oldmessages;
+		}
+	}
+
+	/* add one if not there... */
+	vms_p = get_vm_state_by_imapuser(vmu->imapuser,0);
+	if (!vms_p) {
+		vms_p = get_vm_state_by_mailbox(mailbox,0);
+	}
+
+	if (!vms_p) {
 		ast_debug(3,"Adding new vmstate for %s\n",vmu->imapuser);
 		if (!(vms_p = ast_calloc(1, sizeof(*vms_p)))) {
 			free_user(vmu);
 			return -1;
 		}
- 		ast_copy_string(vms_p->imapuser,vmu->imapuser, sizeof(vms_p->imapuser));
- 		ast_copy_string(vms_p->username, mailboxnc, sizeof(vms_p->username)); /* save for access from interactive entry point */
- 		vms_p->mailstream = NIL; /* save for access from interactive entry point */
-		ast_debug(3,"Copied %s to %s\n",vmu->imapuser,vms_p->imapuser);
+		ast_copy_string(vms_p->imapuser,vmu->imapuser, sizeof(vms_p->imapuser));
+		ast_copy_string(vms_p->username, mailbox, sizeof(vms_p->username)); /* save for access from interactive entry point */
+		vms_p->mailstream = NIL; /* save for access from interactive entry point */
+		ast_debug(3, "Copied %s to %s\n",vmu->imapuser,vms_p->imapuser);
 		vms_p->updated = 1;
 		/* set mailbox to INBOX! */
-		ast_copy_string(vms_p->curbox, mbox(NEW_FOLDER), sizeof(vms_p->curbox));
- 		init_vm_state(vms_p);
- 		vmstate_insert(vms_p);
- 	}
-
-	/* If no mailstream exists yet and even after attempting to initialize it fails, bail out */
-	ret = init_mailstream(vms_p, NEW_FOLDER);
+		ast_copy_string(vms_p->curbox, mbox(fold), sizeof(vms_p->curbox));
+		init_vm_state(vms_p);
+		vmstate_insert(vms_p);
+	}
+	ret = init_mailstream(vms_p, fold);
 	if (!vms_p->mailstream) {
 		ast_log (LOG_ERROR,"Houston we have a problem - IMAP mailstream is NULL\n");
 		free_user(vmu);
 		return -1;
 	}
-
-	if (!ret && vms_p->updated > 0) {
-		if (newmsgs) {
-			pgm = mail_newsearchpgm();
-			hdr = mail_newsearchheader("X-Asterisk-VM-Extension", (char *)mailboxnc);
-			pgm->header = hdr;
+	if (ret == 0) {
+		pgm = mail_newsearchpgm ();
+		hdr = mail_newsearchheader ("X-Asterisk-VM-Extension", (char *)mailbox);
+		pgm->header = hdr;
+		if (fold != 1) {
 			pgm->unseen = 1;
 			pgm->seen = 0;
-			pgm->undeleted = 1;
-			pgm->deleted = 0;
-			vms_p->vmArrayIndex = 0;
-			mail_search_full(vms_p->mailstream, NULL, pgm, NIL);
-			*newmsgs = vms_p->vmArrayIndex;
-			vms_p->newmessages = vms_p->vmArrayIndex;
-			mail_free_searchpgm(&pgm);
-		}
-		if (oldmsgs) {
-			pgm = mail_newsearchpgm ();
-			hdr = mail_newsearchheader ("X-Asterisk-VM-Extension", (char *)mailboxnc);
-			pgm->header = hdr;
+		}
+		/* In the special case where fold is 1 (old messages) we have to do things a bit
+		 * differently. Old messages are stored in the INBOX but are marked as "seen"
+		 */
+		else {
 			pgm->unseen = 0;
 			pgm->seen = 1;
-			pgm->undeleted = 1;
-			pgm->deleted = 0;
-			vms_p->vmArrayIndex = 0;
-			mail_search_full(vms_p->mailstream, NULL, pgm, NIL);
-			*oldmsgs = vms_p->vmArrayIndex;
+		}
+		pgm->undeleted = 1;
+		pgm->deleted = 0;
+
+		vms_p->vmArrayIndex = 0;
+		mail_search_full (vms_p->mailstream, NULL, pgm, NIL);
+		if(fold == 0)
+			vms_p->newmessages = vms_p->vmArrayIndex;
+		if(fold == 1)
 			vms_p->oldmessages = vms_p->vmArrayIndex;
-			mail_free_searchpgm(&pgm);
-		}
-	}
-
- 	if (vms_p->updated > 1) {  /* changes, so we did the searches above */
- 		vms_p->updated = 0;
- 	} else {  /* no changes, so don't search */
- 		mail_ping(vms_p->mailstream);
- 		/* Keep the old data */
- 		*newmsgs = vms_p->newmessages;
- 		*oldmsgs = vms_p->oldmessages;
- 	}
-
+		/*Freeing the searchpgm also frees the searchhdr*/
+		mail_free_searchpgm(&pgm);
+		free_user(vmu);
+		vms_p->updated = 0;
+		return vms_p->vmArrayIndex;
+	} else {  
+		mail_ping(vms_p->mailstream);
+	}
 	free_user(vmu);
- 	return 0;
- }
-
-/*! XXX \todo Fix this function to support multiple mailboxes separated
- * by commas */
+	return 0;
+}
+static int inboxcount(const char *mailbox_context, int *newmsgs, int *oldmsgs)
+{
+	char tmp[PATH_MAX] = "";
+	char *mailboxnc; 	
+	char *context;
+	char *mb;
+	char *cur;
+	if (newmsgs)
+		*newmsgs = 0;
+	if (oldmsgs)
+		*oldmsgs = 0;
+
+	ast_debug(3,"Mailbox is set to %s\n",mailbox_context);
+	/* If no mailbox, return immediately */
+	if (ast_strlen_zero(mailbox_context))
+		return 0;
+	
+	ast_copy_string(tmp, mailbox_context, sizeof(tmp));
+	context = strchr(tmp, '@');
+	if (strchr(mailbox_context, ',')) {
+		int tmpnew, tmpold;
+		ast_copy_string(tmp, mailbox_context, sizeof(tmp));
+		mb = tmp;
+		while((cur = strsep(&mb, ", "))) {
+			if (!ast_strlen_zero(cur)) {
+				if (inboxcount(cur, newmsgs ? &tmpnew : NULL, oldmsgs ? &tmpold : NULL))
+					return -1;
+				else {
+					if (newmsgs)
+						*newmsgs += tmpnew; 
+					if (oldmsgs)
+						*oldmsgs += tmpold;
+				}
+			}
+		}
+		return 0;
+	}
+	if (context) {
+		*context = '\0';
+		mailboxnc = tmp;
+		context++;
+	} else {
+		context = "default";
+		mailboxnc = (char *)mailbox_context;
+	}
+	if (newmsgs) {
+		if((*newmsgs = messagecount(context, mailboxnc, "INBOX")) < 0)
+			return -1;
+	}
+	if (oldmsgs) {
+		if((*oldmsgs = messagecount(context, mailboxnc, "Old")) < 0)
+			return -1;
+	}
+	return 0;
+}
+	
+
 static int has_voicemail(const char *mailbox, const char *folder)
 {
-	int newmsgs, oldmsgs;
-	
-	if(inboxcount(mailbox, &newmsgs, &oldmsgs))
+	char tmp[256], *tmp2, *mbox, *context;
+	ast_copy_string(tmp, mailbox, sizeof(tmp));
+	tmp2 = tmp;
+	if(strchr(tmp2, ',')) {
+		while((mbox = strsep(&tmp2, ","))) {
+			if(!ast_strlen_zero(mbox)) {
+				if (has_voicemail(mbox, folder))
+					return 1;
+			}
+		}
+	}
+	if ((context= strchr(tmp, '@')))
+		*context++ = '\0';
+	else
+		context = "default";
+	return messagecount(context, tmp, folder) ? 1 : 0;
+}
+
+static int copy_message(struct ast_channel *chan, struct ast_vm_user *vmu, int imbox, int msgnum, long duration, struct ast_vm_user *recip, char *fmt, char *dir)
+{
+	char dest[256];
+	struct vm_state *sendvms = NULL, *destvms = NULL;
+	char messagestring[10]; /*I guess this could be a problem if someone has more than 999999999 messages...*/
+	if(!(sendvms = get_vm_state_by_imapuser(vmu->imapuser, 2)))
+	{
+		ast_log(LOG_ERROR, "Couldn't get vm_state for originator's mailbox!!\n");
+		return -1;
+	}
+	if(!(destvms = get_vm_state_by_imapuser(recip->imapuser, 2)))
+	{
+		ast_log(LOG_ERROR, "Couldn't get vm_state for destination mailbox!\n");
+		return -1;
+	}
+	imap_mailbox_name(dest, destvms, imbox, 1);
+	snprintf(messagestring, sizeof(messagestring), "%ld", sendvms->msgArray[msgnum]);
+	if((mail_copy(sendvms->mailstream, messagestring, dest) == T))
 		return 0;
-	else
-		return folder? oldmsgs: newmsgs;
-}
-
-static int messagecount(const char *context, const char *mailbox, const char *folder)
-{
-	int newmsgs, oldmsgs;
- 	char tmp[256] = "";
-	
- 	if (ast_strlen_zero(mailbox))
- 		return 0;
-	sprintf(tmp,"%s@%s", mailbox, ast_strlen_zero(context)? "default": context);
-
-	if(inboxcount(tmp, &newmsgs, &oldmsgs))
-		return 0;
-	else
-		return folder? oldmsgs: newmsgs;
+	ast_log(LOG_WARNING, "Unable to copy message from mailbox %s to mailbox %s\n", vmu->mailbox, recip->mailbox);
+	return -1;
 }
 
 #endif
@@ -3242,7 +3303,6 @@
 						snprintf(tmpdur, sizeof(tmpdur), "%d", duration);
 						ast_update_realtime("voicemail_data", "id", tmpid, "filename", fn, "duration", tmpdur, NULL);
 					}
-#ifndef IMAP_STORAGE
 					/* We must store the file first, before copying the message, because
 					 * ODBC storage does the entire copy with SQL.
 					 */
@@ -3266,7 +3326,6 @@
 							free_user(recip);
 						}
 					}
-#endif
 					/* Notification and disposal needs to happen after the copy, though. */
 					if (ast_fileexists(fn, NULL, NULL)) {
 						notify_new_message(chan, vmu, msgnum, duration, fmt, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL));

Modified: team/group/ast_storage/channels/chan_gtalk.c
URL: http://svn.digium.com/view/asterisk/team/group/ast_storage/channels/chan_gtalk.c?view=diff&rev=79432&r1=79431&r2=79432
==============================================================================
--- team/group/ast_storage/channels/chan_gtalk.c (original)
+++ team/group/ast_storage/channels/chan_gtalk.c Tue Aug 14 12:03:01 2007
@@ -979,9 +979,7 @@
 		cid = data;
 	}
 	cid = strsep(&cid, "@");
-	tmp->cid.cid_num = ast_strdup(cid);
 	tmp->cid.cid_ani = ast_strdup(cid);
-	tmp->cid.cid_name = ast_strdup(i->them);
 	if (!ast_strlen_zero(i->exten) && strcmp(i->exten, "s"))
 		tmp->cid.cid_dnid = ast_strdup(i->exten);
 	tmp->priority = 1;

Modified: team/group/ast_storage/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/group/ast_storage/channels/chan_h323.c?view=diff&rev=79432&r1=79431&r2=79432
==============================================================================
--- team/group/ast_storage/channels/chan_h323.c (original)

[... 7576 lines stripped ...]



More information about the asterisk-commits mailing list