[asterisk-commits] mmichelson: branch mmichelson/trunk-vm-imap r71951 - in /team/mmichelson/trun...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 26 16:50:08 CDT 2007


Author: mmichelson
Date: Tue Jun 26 16:50:07 2007
New Revision: 71951

URL: http://svn.digium.com/view/asterisk?view=rev&rev=71951
Log:
Resolved conflicts in app_voicemail. Re-setting the automerge property for this branch


Modified:
    team/mmichelson/trunk-vm-imap/   (props changed)
    team/mmichelson/trunk-vm-imap/apps/app_record.c
    team/mmichelson/trunk-vm-imap/apps/app_voicemail.c
    team/mmichelson/trunk-vm-imap/configure
    team/mmichelson/trunk-vm-imap/configure.ac
    team/mmichelson/trunk-vm-imap/doc/imapstorage.tex
    team/mmichelson/trunk-vm-imap/main/cdr.c
    team/mmichelson/trunk-vm-imap/main/rtp.c
    team/mmichelson/trunk-vm-imap/res/res_agi.c
    team/mmichelson/trunk-vm-imap/res/res_jabber.c

Propchange: team/mmichelson/trunk-vm-imap/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/mmichelson/trunk-vm-imap/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/mmichelson/trunk-vm-imap/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Jun 26 16:50:07 2007
@@ -1,1 +1,1 @@
-/trunk:1-71620
+/trunk:1-71950

Modified: team/mmichelson/trunk-vm-imap/apps/app_record.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/trunk-vm-imap/apps/app_record.c?view=diff&rev=71951&r1=71950&r2=71951
==============================================================================
--- team/mmichelson/trunk-vm-imap/apps/app_record.c (original)
+++ team/mmichelson/trunk-vm-imap/apps/app_record.c Tue Jun 26 16:50:07 2007
@@ -81,6 +81,7 @@
 	int count = 0;
 	int percentflag = 0;
 	char *filename, *ext = NULL, *silstr, *maxstr, *options;
+	char *file, *dir;
 	char *vdata, *p;
 	int i = 0;
 	char tmp[256];
@@ -263,8 +264,13 @@
 		}
 		ast_dsp_set_threshold(sildet, 256);
 	} 
-		
-		
+
+	/* Create the directory if it does not exist. */
+	dir = ast_strdupa(tmp);
+	if ((file = strrchr(dir, '/')))
+		*file++ = '\0';
+	ast_mkdir (dir, 0777);
+
 	flags = option_append ? O_CREAT|O_APPEND|O_WRONLY : O_CREAT|O_TRUNC|O_WRONLY;
 	s = ast_writefile( tmp, ext, NULL, flags , 0, AST_FILE_MODE);
 		

Modified: team/mmichelson/trunk-vm-imap/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/trunk-vm-imap/apps/app_voicemail.c?view=diff&rev=71951&r1=71950&r2=71951
==============================================================================
--- team/mmichelson/trunk-vm-imap/apps/app_voicemail.c (original)
+++ team/mmichelson/trunk-vm-imap/apps/app_voicemail.c Tue Jun 26 16:50:07 2007
@@ -82,9 +82,15 @@
 #include <ctype.h>
 #include <signal.h>
 #include <pwd.h>
+#ifdef USE_SYSTEM_IMAP
+#include <imap/c-client.h>
+#include <imap/imap4r1.h>
+#include <imap/linkage.h>
+#else
 #include "c-client.h"
 #include "imap4r1.h"
 #include "linkage.h"
+#endif
 #endif
 
 #include "asterisk/lock.h"
@@ -150,7 +156,6 @@
 static void imap_mailbox_name(char *spec, struct vm_state *vms, int box, int target);
 static int imap_store_file(char *dir, char *mailboxuser, char *mailboxcontext, int msgnum, struct ast_channel *chan, struct ast_vm_user *vmu, char *fmt, int duration, struct vm_state *vms);
 static void update_messages_by_imapuser(const char *user, unsigned long number);
-
 
 static int imap_remove_file (char *dir, int msgnum);
 static int imap_retrieve_file (char *dir, int msgnum, char *mailbox, char *context);
@@ -2684,7 +2689,7 @@
 		return -1;
 	}
 
-	if (!ret && vms_p->updated == 1) {
+	if (!ret && vms_p->updated > 0) {
 		if (newmsgs) {
 			pgm = mail_newsearchpgm();
 			hdr = mail_newsearchheader("X-Asterisk-VM-Extension", (char *)mailboxnc);
@@ -2715,10 +2720,8 @@
 		}
 	}
 
- 	if (vms_p->updated == 1) {  /* changes, so we did the searches above */
+ 	if (vms_p->updated > 1) {  /* changes, so we did the searches above */
  		vms_p->updated = 0;
- 	} else if (vms_p->updated > 1) {  /* decrement delay count */
- 		vms_p->updated--;
  	} else {  /* no changes, so don't search */
  		mail_ping(vms_p->mailstream);
  		/* Keep the old data */
@@ -3138,19 +3141,13 @@
 #ifdef IMAP_STORAGE
 		/* Is ext a mailbox? */
 		/* must open stream for this user to get info! */
-		vms = get_vm_state_by_mailbox(ext,0);
-		if (vms) {
-			ast_debug(3, "Using vm_state, interactive set to %d.\n",vms->interactive);
-			newmsgs = vms->newmessages++;
-			oldmsgs = vms->oldmessages;
-		} else {
-			res = inboxcount(ext_context, &newmsgs, &oldmsgs);
-			if(res < 0) {
-				ast_log(LOG_NOTICE,"Can not leave voicemail, unable to count messages\n");
-				return -1;
-			}
-			vms = get_vm_state_by_mailbox(ext,0);
-		}
+		res = inboxcount(ext_context, &newmsgs, &oldmsgs);
+		if(res < 0) {
+			ast_log(LOG_NOTICE,"Can not leave voicemail, unable to count messages\n");
+			return -1;
+		}
+		if((vms = get_vm_state_by_mailbox(ext,0))) 
+			vms->newmessages++; /*still need to increment new message count*/
 		/* here is a big difference! We add one to it later */
 		msgnum = newmsgs + oldmsgs;
 		ast_debug(3, "Messagecount set to %d\n",msgnum);
@@ -4842,7 +4839,11 @@
 
 	if (delimiter == '\0') {		/* did not probe the server yet */
 		char *cp;
+#ifdef USE_SYSTEM_IMAP
+#include <imap/linkage.c>
+#else
 #include "linkage.c"
+#endif
 		/* Connect to INBOX first to get folders delimiter */
 		imap_mailbox_name(tmp, vms, 0, 0);
 		stream = mail_open(stream, tmp, debug ? OP_DEBUG : NIL);
@@ -5090,6 +5091,7 @@
 	ast_debug (2, "Unable to find greeting\n");
 	return -1;
 }
+
 #else
 static int open_mailbox(struct vm_state *vms, struct ast_vm_user *vmu,int box)
 {
@@ -6824,7 +6826,7 @@
 
 #ifdef IMAP_STORAGE
 	vms.interactive = 1;
-	vms.updated = 2;
+	vms.updated = 1;
 	vmstate_insert(&vms);
 	init_vm_state(&vms);
 #endif
@@ -6874,6 +6876,7 @@
 		if (!vms.newmessages && vms.oldmessages) {
 			/* If we only have old messages start here */
 			res = open_mailbox(&vms, vmu, 1);
+			play_folder = 1;
 			if (res == ERROR_LOCK_PATH)
 				goto out;
 		}
@@ -6937,6 +6940,7 @@
 				res = open_mailbox(&vms, vmu, cmd);
 				if (res == ERROR_LOCK_PATH)
 					goto out;
+				play_folder = cmd;
 				cmd = 0;
 			}
 			if (useadsi)
@@ -7073,10 +7077,20 @@
 				vms.deleted[vms.curmsg] = !vms.deleted[vms.curmsg];
 				if (useadsi)
 					adsi_delete(chan, &vms);
-				if (vms.deleted[vms.curmsg]) 
+				if (vms.deleted[vms.curmsg]) {
+					if (play_folder == 0)
+						vms.newmessages--;
+					else if (play_folder == 1)
+						vms.oldmessages--;
 					cmd = ast_play_and_wait(chan, "vm-deleted");
-				else
+				}
+				else {
+					if (play_folder == 0)
+						vms.newmessages++;
+					else if (play_folder == 1)
+						vms.oldmessages++;
 					cmd = ast_play_and_wait(chan, "vm-undeleted");
+				}
 				if (ast_test_flag((&globalflags), VM_SKIPAFTERCMD)) {
 					if (vms.curmsg < vms.lastmsg) {
 						vms.curmsg++;
@@ -7103,6 +7117,11 @@
 				cmd = ast_play_and_wait(chan, "vm-nomore");
 			break;
 		case '9':
+			if (vms.curmsg < 0 || vms.curmsg > vms.lastmsg) {
+				/* No message selected */
+				cmd = 0;
+				break;
+			}
 			if (useadsi)
 				adsi_folders(chan, 1, "Save to folder...");
 			cmd = get_folder2(chan, "vm-savefolder", 1);
@@ -7808,6 +7827,11 @@
 	
 	AST_LIST_TRAVERSE(&users, vmu, list) {
 		char dirname[256];
+
+#ifdef IMAP_STORAGE
+		int new, old;
+		inboxcount (vmu->mailbox, &new, &old);
+#endif
 		
 		make_dir(dirname, sizeof(dirname), vmu->context, vmu->mailbox, "INBOX");
 		astman_append(s,
@@ -7833,6 +7857,7 @@
 			      "MaxMessageLength: %d\r\n"
 			      "NewMessageCount: %d\r\n"
 #ifdef IMAP_STORAGE
+				  "OldMessageCount: %d\r\n"
 			      "IMAPUser: %s\r\n"
 #endif
 			      "\r\n",
@@ -7840,9 +7865,11 @@
 			      vmu->pager, vmu->serveremail, vmu->mailcmd, vmu->language,
 			      vmu->zonetag, vmu->callback, vmu->dialout, vmu->uniqueid,
 			      vmu->exit, vmu->saydurationm, vmu->attachfmt, vmu->volgain,
-			      vmu->maxmsg, vmu->maxsecs, count_messages(vmu, dirname)
+			      vmu->maxmsg, vmu->maxsecs, 
 #ifdef IMAP_STORAGE
-			      , vmu->imapuser
+				  new, old, vmu->imapuser
+#else
+				  count_messages(vmu, dirname)
 #endif
 			);
 	}		
@@ -9410,10 +9437,10 @@
 	if (ast_strlen_zero(mailbox))
 		return NULL;
 
-	if (!(start = strstr(mailbox, "user=")))
+	if (!(start = strstr(mailbox, "/user=")))
 		return NULL;
 
-	ast_copy_string(buf, start+5, len);
+	ast_copy_string(buf, start+6, len);
 
 	if (!(quote = strchr(buf, '\"'))) {
 		if (!(eol_pnt = strchr(buf, '/')))
@@ -9539,7 +9566,7 @@
 		ast_debug(3, "Duplicate mailbox %s, copying message info...\n", vms->username);
 		altvms->newmessages = vms->newmessages;
 		altvms->oldmessages = vms->oldmessages;
-		altvms->updated = 2;
+		altvms->updated = 1;
 	}
 	
 	ast_debug(3, "Removing vm_state for user:%s, mailbox %s\n", vms->imapuser, vms->username);
@@ -9574,7 +9601,7 @@
 
 	ast_debug(3, "User %s mailbox set for update.\n", user);
        
-	vms->updated = 2; /* Set updated flag since mailbox changed */
+	vms->updated = 1; /* Set updated flag since mailbox changed */
 }
 
 static void init_vm_state(struct vm_state *vms) 

Modified: team/mmichelson/trunk-vm-imap/configure
URL: http://svn.digium.com/view/asterisk/team/mmichelson/trunk-vm-imap/configure?view=diff&rev=71951&r1=71950&r2=71951
==============================================================================
--- team/mmichelson/trunk-vm-imap/configure (original)
+++ team/mmichelson/trunk-vm-imap/configure Tue Jun 26 16:50:07 2007
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 67029 .
+# From configure.ac Revision: 69703 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.61.
 #
@@ -19102,7 +19102,10 @@
 fi
 
 if test "${USE_IMAP_TK}" != "no"; then
-   if test "${IMAP_TK_DIR}" = ""; then
+   if test "${IMAP_TK_DIR}" = "system" ; then
+      { echo "$as_me:$LINENO: Checking for system c-client library..." >&5
+echo "$as_me: Checking for system c-client library..." >&6;}
+   elif test "${IMAP_TK_DIR}" = ""; then
       IMAP_TK_DIR=`pwd`"/../imap-2004g"
       if test  -n "${IMAP_TK_MANDATORY}"; then
 	 { echo "$as_me:$LINENO: The --with-imap option does not search your system for installed" >&5
@@ -19115,22 +19118,34 @@
 echo "$as_me: files at ${IMAP_TK_DIR}, as outlined in the doc/imapstorage.txt file." >&6;}
       fi
    fi
-   { echo "$as_me:$LINENO: checking for UW IMAP Toolkit c-client library" >&5
+   if test "${IMAP_TK_DIR}" != "system" ; then
+      { echo "$as_me:$LINENO: checking for UW IMAP Toolkit c-client library" >&5
 echo $ECHO_N "checking for UW IMAP Toolkit c-client library... $ECHO_C" >&6; }
+   fi
    saved_cppflags="${CPPFLAGS}"
    saved_libs="${LIBS}"
-   if test -f ${IMAP_TK_DIR}/c-client/LDFLAGS ; then
+   if test "${IMAP_TK_DIR}" = "system" ; then
+      imap_ldflags=""
+      imap_libs="-lc-client"
+      imap_include="-DUSE_SYSTEM_IMAP"
+   elif test -f ${IMAP_TK_DIR}/c-client/LDFLAGS ; then
       imap_ldflags=`cat ${IMAP_TK_DIR}/c-client/LDFLAGS`
+      imap_libs="${IMAP_TK_DIR}/c-client/c-client.a"
+      imap_include="-I${IMAP_TK_DIR}/c-client"
    fi
-   CPPFLAGS="${CPPFLAGS} -I${IMAP_TK_DIR}/c-client"
-   LIBS="${LIBS} ${IMAP_TK_DIR}/c-client/c-client.a "`echo ${imap_ldflags}`
+   CPPFLAGS="${CPPFLAGS} ${imap_include}"
+   LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}`
    cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include "c-client.h"
+#ifdef USE_SYSTEM_IMAP
+		#include <imap/c-client.h>
+		#else
+		#include "c-client.h"
+		#endif
 		void mm_searched (MAILSTREAM *stream,unsigned long number)
 		{
 		}
@@ -19223,7 +19238,11 @@
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include "c-client.h"
+#ifdef USE_SYSTEM_IMAP
+	 #include <imap/c-client.h>
+	 #else
+	 #include "c-client.h"
+	 #endif
          void mm_searched (MAILSTREAM *stream,unsigned long number)
          {
          }
@@ -19315,8 +19334,8 @@
    if test "${ac_cv_imap_tk}" = "yes"; then
       { echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6; }
-      IMAP_TK_LIB="${IMAP_TK_DIR}/c-client/c-client.a "`echo ${imap_ldflags}`
-      IMAP_TK_INCLUDE="-I${IMAP_TK_DIR}/c-client"
+      IMAP_TK_LIB="${imap_libs} "`echo ${imap_ldflags}`
+      IMAP_TK_INCLUDE="${imap_include}"
       PBX_IMAP_TK=1
 
 cat >>confdefs.h <<\_ACEOF

Modified: team/mmichelson/trunk-vm-imap/configure.ac
URL: http://svn.digium.com/view/asterisk/team/mmichelson/trunk-vm-imap/configure.ac?view=diff&rev=71951&r1=71950&r2=71951
==============================================================================
--- team/mmichelson/trunk-vm-imap/configure.ac (original)
+++ team/mmichelson/trunk-vm-imap/configure.ac Tue Jun 26 16:50:07 2007
@@ -436,7 +436,9 @@
 fi
 
 if test "${USE_IMAP_TK}" != "no"; then
-   if test "${IMAP_TK_DIR}" = ""; then
+   if test "${IMAP_TK_DIR}" = "system" ; then
+      AC_MSG_NOTICE([Checking for system c-client library...])
+   elif test "${IMAP_TK_DIR}" = ""; then
       IMAP_TK_DIR=`pwd`"/../imap-2004g"
       if test  -n "${IMAP_TK_MANDATORY}"; then
 	 AC_MSG_NOTICE([The --with-imap option does not search your system for installed])
@@ -445,17 +447,29 @@
 	 AC_MSG_NOTICE([files at ${IMAP_TK_DIR}, as outlined in the doc/imapstorage.txt file.])
       fi
    fi
-   AC_MSG_CHECKING(for UW IMAP Toolkit c-client library)
+   if test "${IMAP_TK_DIR}" != "system" ; then
+      AC_MSG_CHECKING(for UW IMAP Toolkit c-client library)
+   fi
    saved_cppflags="${CPPFLAGS}"
    saved_libs="${LIBS}"
-   if test -f ${IMAP_TK_DIR}/c-client/LDFLAGS ; then
+   if test "${IMAP_TK_DIR}" = "system" ; then
+      imap_ldflags=""
+      imap_libs="-lc-client"
+      imap_include="-DUSE_SYSTEM_IMAP"
+   elif test -f ${IMAP_TK_DIR}/c-client/LDFLAGS ; then
       imap_ldflags=`cat ${IMAP_TK_DIR}/c-client/LDFLAGS`
-   fi
-   CPPFLAGS="${CPPFLAGS} -I${IMAP_TK_DIR}/c-client"
-   LIBS="${LIBS} ${IMAP_TK_DIR}/c-client/c-client.a "`echo ${imap_ldflags}`
+      imap_libs="${IMAP_TK_DIR}/c-client/c-client.a"
+      imap_include="-I${IMAP_TK_DIR}/c-client"
+   fi
+   CPPFLAGS="${CPPFLAGS} ${imap_include}"
+   LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}`
    AC_LINK_IFELSE(
 	AC_LANG_PROGRAM(
-		[#include "c-client.h"
+		[#ifdef USE_SYSTEM_IMAP
+		#include <imap/c-client.h>
+		#else
+		#include "c-client.h"
+		#endif
 		void mm_searched (MAILSTREAM *stream,unsigned long number)
 		{
 		}
@@ -511,7 +525,11 @@
    if test "${ac_cv_imap_tk}" = "yes"; then
    AC_LINK_IFELSE(
       AC_LANG_PROGRAM(
-         [#include "c-client.h"
+         [#ifdef USE_SYSTEM_IMAP
+	 #include <imap/c-client.h>
+	 #else
+	 #include "c-client.h"
+	 #endif
          void mm_searched (MAILSTREAM *stream,unsigned long number)
          {
          }
@@ -569,8 +587,8 @@
    LIBS="${saved_libs}"
    if test "${ac_cv_imap_tk}" = "yes"; then
       AC_MSG_RESULT(yes) 
-      IMAP_TK_LIB="${IMAP_TK_DIR}/c-client/c-client.a "`echo ${imap_ldflags}`
-      IMAP_TK_INCLUDE="-I${IMAP_TK_DIR}/c-client"
+      IMAP_TK_LIB="${imap_libs} "`echo ${imap_ldflags}`
+      IMAP_TK_INCLUDE="${imap_include}"
       PBX_IMAP_TK=1
       AC_DEFINE([HAVE_IMAP_TK], 1, [Define if your system has the UW IMAP Toolkit c-client library.])
       if test "${ac_cv_imap_tk2006}" = "yes"; then

Modified: team/mmichelson/trunk-vm-imap/doc/imapstorage.tex
URL: http://svn.digium.com/view/asterisk/team/mmichelson/trunk-vm-imap/doc/imapstorage.tex?view=diff&rev=71951&r1=71950&r2=71951
==============================================================================
--- team/mmichelson/trunk-vm-imap/doc/imapstorage.tex (original)
+++ team/mmichelson/trunk-vm-imap/doc/imapstorage.tex Tue Jun 26 16:50:07 2007
@@ -19,10 +19,11 @@
 
 \subsubsection{University of Washington IMAP C-Client}
 
-You will need a source distribution of University of Washington's IMAP
-c-client (http://www.washington.edu/imap/).  Asterisk supports both the
-2004 and 2006 versions of c-client, however mail\_expunge\_full is enabled
-in the 2006 version.
+If you do not have the University of Washington's IMAP c-client
+installed on your system, you will need to download the c-client
+source distribution (http://www.washington.edu/imap/) and compile it.
+Asterisk supports both the 2004 and 2006 versions of c-client, however
+mail\_expunge\_full is enabled in the 2006 version.
 
 Note that Asterisk only uses the 'client' portion of the UW IMAP toolkit,
 but building it also builds an IMAP server and various other utilities.
@@ -50,19 +51,17 @@
 
 \subsubsection{Compiling Asterisk}
 
-Configure with ./configure --with-imap=/usr/src/imap
-or where ever you built thfe UWashington IMAP Toolkit. When you run
-'make menuselect', choose 'Voicemail Build Options' and the
-IMAP\_STORAGE option should be available for selection.
+To use the system c-client library, configure Asterisk with
+./configure --with-imap=system. If you downloaded the c-client source
+and compiled it according to the above instructions, configure
+Asterisk with with ./configure --with-imap=/usr/src/imap or where ever
+you built the UWashington IMAP Toolkit. When you run 'make
+menuselect', choose 'Voicemail Build Options' and the IMAP\_STORAGE
+option should be available for selection.
 
-Note that the --with-imap option will NOT search your system for an
-installed copy of the IMAP Toolkit c-client library; the Asterisk
-Makefiles and configure script are designed to build against an
-unpacked and compiled source tree of the IMAP Toolkit, not a binary
-distribution.
-
-After selecting it, use the 'x' key to exit menuselect and save
-your changes, and the build/install Asterisk normally.
+After selecting the IMAP\_STORAGE option, use the 'x' key to exit
+menuselect and save your changes, and the build/install Asterisk
+normally.
 
 \subsection{Modify voicemail.conf}
 

Modified: team/mmichelson/trunk-vm-imap/main/cdr.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/trunk-vm-imap/main/cdr.c?view=diff&rev=71951&r1=71950&r2=71951
==============================================================================
--- team/mmichelson/trunk-vm-imap/main/cdr.c (original)
+++ team/mmichelson/trunk-vm-imap/main/cdr.c Tue Jun 26 16:50:07 2007
@@ -526,9 +526,9 @@
 	}
 
 	if (ast_test_flag(from, AST_CDR_FLAG_LOCKED)) {
+		struct ast_cdr *llfrom = NULL;
 		discard_from = 1;
 		if (lto) {
-			struct ast_cdr *llfrom = NULL;
 			/* insert the from stuff after lto */
 			lto->next = from;
 			lfrom = from;
@@ -543,7 +543,6 @@
 		} else {
 			/* save copy of the current *to cdr */
 			struct ast_cdr tcdr;
-			struct ast_cdr *llfrom = NULL;
 			memcpy(&tcdr, to, sizeof(tcdr));
 			/* copy in the locked from cdr */
 			memcpy(to, from, sizeof(*to));

Modified: team/mmichelson/trunk-vm-imap/main/rtp.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/trunk-vm-imap/main/rtp.c?view=diff&rev=71951&r1=71950&r2=71951
==============================================================================
--- team/mmichelson/trunk-vm-imap/main/rtp.c (original)
+++ team/mmichelson/trunk-vm-imap/main/rtp.c Tue Jun 26 16:50:07 2007
@@ -2709,6 +2709,9 @@
 	struct ast_rtp *rtp = data;
 	int res;
 	
+	if (!rtp || !rtp->rtcp)
+		return 0;
+
 	if (rtp->txcount > rtp->rtcp->lastsrtxcount)
 		res = ast_rtcp_write_sr(data);
 	else

Modified: team/mmichelson/trunk-vm-imap/res/res_agi.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/trunk-vm-imap/res/res_agi.c?view=diff&rev=71951&r1=71950&r2=71951
==============================================================================
--- team/mmichelson/trunk-vm-imap/res/res_agi.c (original)
+++ team/mmichelson/trunk-vm-imap/res/res_agi.c Tue Jun 26 16:50:07 2007
@@ -1125,7 +1125,7 @@
 	}
 	fdprintf(agi->fd, "200 result=%d\n", res);
 
-	return res;
+	return res >= 0 ? RESULT_SUCCESS : RESULT_FAILURE;
 }
 
 static int handle_setcallerid(struct ast_channel *chan, AGI *agi, int argc, char **argv)

Modified: team/mmichelson/trunk-vm-imap/res/res_jabber.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/trunk-vm-imap/res/res_jabber.c?view=diff&rev=71951&r1=71950&r2=71951
==============================================================================
--- team/mmichelson/trunk-vm-imap/res/res_jabber.c (original)
+++ team/mmichelson/trunk-vm-imap/res/res_jabber.c Tue Jun 26 16:50:07 2007
@@ -71,6 +71,7 @@
 #endif
 
 /*-- Forward declarations */
+static int aji_start_sasl(iksparser *prs, enum ikssasltype type, char *username, char *pass);
 static int aji_highest_bit(int number);
 static void aji_buddy_destroy(struct aji_buddy *obj);
 static void aji_client_destroy(struct aji_client *obj);
@@ -503,6 +504,50 @@
 }
 
 /*!
+ * \brief A wrapper function for iks_start_sasl
+ * \param prs the XML parser
+ * \param type the SASL authentication type. Supported types are PLAIN and MD5
+ * \param username
+ * \param pass
+ * If SASL authentication type is MD5, we simply call iks_start_sasl().
+ * If type is PLAIN, we compute the authentication string by ourselves, 
+ * because it looks like Google's jabber server does not accept the value 
+ * computed with iks_start_sasl().
+ * \return IKS_OK on success, IKSNET_NOTSUPP on failure.
+ */
+static int aji_start_sasl(iksparser *prs, enum ikssasltype type, char *username, char *pass)
+{
+	iks *x = NULL;
+
+	if (type == IKS_STREAM_SASL_MD5)
+		return iks_start_sasl(prs, type, username, pass);
+
+	x = iks_new("auth"); 
+	if (!x) {
+		ast_log(LOG_ERROR, "Out of memory.\n");
+		return IKS_NET_NOTSUPP;
+	}
+
+	iks_insert_attrib(x, "xmlns", IKS_NS_XMPP_SASL);
+	int len = strlen(username) + strlen(pass) + 3;
+	/* XXX Check return values XXX */
+	char *s = ast_malloc(80 + len);
+	char *base64 = ast_malloc(80 + len * 2);
+	iks_insert_attrib(x, "mechanism", "PLAIN");
+	sprintf(s, "%c%s%c%s", 0, username, 0, pass);
+	ast_base64encode(base64, (const unsigned char *) s, len, len * 2);
+	iks_insert_cdata(x, base64, 0);
+	iks_send(prs, x);
+	iks_delete(x);
+	if (base64)
+		free(base64);
+	if (s)
+		free(s);	
+
+	return IKS_OK;
+}
+
+/*!
  * \brief The action hook parses the inbound packets, constantly running.
  * \param data aji client structure 
  * \param type type of packet 
@@ -514,6 +559,7 @@
 	struct aji_client *client = ASTOBJ_REF((struct aji_client *) data);
 	ikspak *pak = NULL;
 	iks *auth = NULL;
+	int features = 0;
 
 	if(!node) {
 		ast_log(LOG_ERROR, "aji_act_hook was called with out a packet\n"); /* most likely cause type is IKS_NODE_ERROR lost connection */
@@ -554,83 +600,59 @@
 			break;
 
 		case IKS_NODE_NORMAL:
-			{
-				int features = 0;
-				if (!strcmp("stream:features", iks_name(node))) {
-					features = iks_stream_features(node);
-					if (client->usesasl) {
-						if (client->usetls && !iks_is_secure(client->p))
-							break;
-						if (client->authorized) {
-							if (features & IKS_STREAM_BIND) {
-								iks_filter_add_rule (client->f, aji_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_DONE);
-								auth = iks_make_resource_bind(client->jid);
-								if (auth) {
-									iks_insert_attrib(auth, "id", client->mid);
-									ast_aji_increment_mid(client->mid);
-									iks_send(client->p, auth);
-									iks_delete(auth);
-								} else {
-									ast_log(LOG_ERROR, "Out of memory.\n");
-									break;
-								}
-							}
-							if (features & IKS_STREAM_SESSION) {
-								iks_filter_add_rule (client->f, aji_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, "auth", IKS_RULE_DONE);
-								auth = iks_make_session();
-								if (auth) {
-									iks_insert_attrib(auth, "id", "auth");
-									ast_aji_increment_mid(client->mid);
-									iks_send(client->p, auth);
-									iks_delete(auth);
-								} else {
-									ast_log(LOG_ERROR, "Out of memory.\n");
-								}
-							}
-						} else {
-							if (!client->jid->user) {
-								ast_log(LOG_ERROR, "Malformed Jabber ID : %s (domain missing?)\n", client->jid->full);
+			if (!strcmp("stream:features", iks_name(node))) {
+				features = iks_stream_features(node);
+				if (client->usesasl) {
+					if (client->usetls && !iks_is_secure(client->p))
+						break;
+					if (client->authorized) {
+						if (features & IKS_STREAM_BIND) {
+							iks_filter_add_rule (client->f, aji_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_DONE);
+							auth = iks_make_resource_bind(client->jid);
+							if (auth) {
+								iks_insert_attrib(auth, "id", client->mid);
+								ast_aji_increment_mid(client->mid);
+								iks_send(client->p, auth);
+								iks_delete(auth);
+							} else {
+								ast_log(LOG_ERROR, "Out of memory.\n");
 								break;
 							}
-							features = aji_highest_bit(features);
-							if (features == IKS_STREAM_SASL_MD5)
-								iks_start_sasl(client->p, IKS_SASL_DIGEST_MD5, client->jid->user, client->password);
-							else {
-								if (features == IKS_STREAM_SASL_PLAIN) {
-									iks *x = NULL;
-									x = iks_new("auth");
-									if (x) {
-										int len = strlen(client->jid->user) + strlen(client->password) + 3;
-										/* XXX Check return values XXX */
-										char *s = ast_malloc(80 + len);
-										char *base64 = ast_malloc(80 + len * 2);
-
-										iks_insert_attrib(x, "xmlns", IKS_NS_XMPP_SASL);
-										iks_insert_attrib(x, "mechanism", "PLAIN");
-										sprintf(s, "%c%s%c%s", 0, client->jid->user, 0, client->password);
-										ast_base64encode(base64, (const unsigned char *) s, len, len * 2);
-										iks_insert_cdata(x, base64, 0);
-										iks_send(client->p, x);
-										iks_delete(x);
-										if (base64)
-											ast_free(base64);
-										if (s)
-											ast_free(s);
-									} else {
-										ast_log(LOG_ERROR, "Out of memory.\n");
-									}
-								}
+						}
+						if (features & IKS_STREAM_SESSION) {
+							iks_filter_add_rule (client->f, aji_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, "auth", IKS_RULE_DONE);
+							auth = iks_make_session();
+							if (auth) {
+								iks_insert_attrib(auth, "id", "auth");
+								ast_aji_increment_mid(client->mid);
+								iks_send(client->p, auth);
+								iks_delete(auth);
+							} else {
+								ast_log(LOG_ERROR, "Out of memory.\n");
 							}
 						}
+					} else {
+						int ret;
+						if (!client->jid->user) {
+							ast_log(LOG_ERROR, "Malformed Jabber ID : %s (domain missing?)\n", client->jid->full);
+							break;
+						}
+						features = aji_highest_bit(features);
+						ret = aji_start_sasl(client->p, features, client->jid->user, client->password);
+						if (ret != IKS_OK) {
+							ASTOBJ_UNREF(client, aji_client_destroy);
+							return IKS_HOOK;
+						}
+						break;
 					}
-				} else if (!strcmp("failure", iks_name(node))) {
-					ast_log(LOG_ERROR, "JABBER: encryption failure. possible bad password.\n");
-				} else if (!strcmp("success", iks_name(node))) {
-					client->authorized = 1;
-					iks_send_header(client->p, client->jid->server);
 				}
-				break;
+			} else if (!strcmp("failure", iks_name(node))) {
+				ast_log(LOG_ERROR, "JABBER: encryption failure. possible bad password.\n");
+			} else if (!strcmp("success", iks_name(node))) {
+				client->authorized = 1;
+				iks_send_header(client->p, client->jid->server);
 			}
+			break;
 		case IKS_NODE_ERROR: 
 				ast_log(LOG_ERROR, "JABBER: Node Error\n");
 				ASTOBJ_UNREF(client, aji_client_destroy);




More information about the asterisk-commits mailing list