* #36737: switch back to svn repo, remove assert in sip_transaction.c
diff --git a/jni/pjproject-android/.svn/pristine/6b/6b2b4619263af2697afafb471e8002d7486a8458.svn-base b/jni/pjproject-android/.svn/pristine/6b/6b2b4619263af2697afafb471e8002d7486a8458.svn-base
new file mode 100644
index 0000000..a1508a5
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/6b/6b2b4619263af2697afafb471e8002d7486a8458.svn-base
@@ -0,0 +1,35 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef __PJ_COMPAT_M_SPARC_H__
+#define __PJ_COMPAT_M_SPARC_H__
+
+/**
+ * @file m_sparc.h
+ * @brief Describes SPARC family processor specifics.
+ */
+
+#define PJ_M_NAME "sparc"
+
+#define PJ_HAS_PENTIUM 0
+#define PJ_IS_LITTLE_ENDIAN 0
+#define PJ_IS_BIG_ENDIAN 1
+
+
+#endif /* __PJ_COMPAT_M_SPARC_H__ */
diff --git a/jni/pjproject-android/.svn/pristine/6b/6b41152df865d4a4af7bcff225db49040761e4cd.svn-base b/jni/pjproject-android/.svn/pristine/6b/6b41152df865d4a4af7bcff225db49040761e4cd.svn-base
new file mode 100644
index 0000000..9ec2ab6
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/6b/6b41152df865d4a4af7bcff225db49040761e4cd.svn-base
@@ -0,0 +1,11 @@
+# $Id$
+#
+from inc_cfg import *
+
+test_param = TestParam(
+ "Callee=mandatory SRTP, caller=mandatory SRTP",
+ [
+ InstanceParam("callee", "--null-audio --use-srtp=2 --srtp-secure=0 --max-calls=1"),
+ InstanceParam("caller", "--null-audio --use-srtp=2 --srtp-secure=0 --max-calls=1")
+ ]
+ )
diff --git a/jni/pjproject-android/.svn/pristine/6b/6b55637535eec5c2a9ae96e91540bfac3c6b93a3.svn-base b/jni/pjproject-android/.svn/pristine/6b/6b55637535eec5c2a9ae96e91540bfac3c6b93a3.svn-base
new file mode 100644
index 0000000..ff54bd4
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/6b/6b55637535eec5c2a9ae96e91540bfac3c6b93a3.svn-base
@@ -0,0 +1,327 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <pj/errno.h>
+#include <pj/log.h>
+#include <pj/string.h>
+#include <pj/compat/string.h>
+#include <pj/compat/stdarg.h>
+#include <pj/assert.h>
+
+/* Prototype for platform specific error message, which will be defined
+ * in separate file.
+ */
+PJ_BEGIN_DECL
+
+ PJ_DECL(int) platform_strerror(pj_os_err_type code,
+ char *buf, pj_size_t bufsize );
+PJ_END_DECL
+
+#ifndef PJLIB_MAX_ERR_MSG_HANDLER
+# define PJLIB_MAX_ERR_MSG_HANDLER 10
+#endif
+
+/* Error message handler. */
+static unsigned err_msg_hnd_cnt;
+static struct err_msg_hnd
+{
+ pj_status_t begin;
+ pj_status_t end;
+ pj_str_t (*strerror)(pj_status_t, char*, pj_size_t);
+
+} err_msg_hnd[PJLIB_MAX_ERR_MSG_HANDLER];
+
+/* PJLIB's own error codes/messages */
+#if defined(PJ_HAS_ERROR_STRING) && PJ_HAS_ERROR_STRING!=0
+
+static const struct
+{
+ int code;
+ const char *msg;
+} err_str[] =
+{
+ PJ_BUILD_ERR(PJ_EUNKNOWN, "Unknown Error" ),
+ PJ_BUILD_ERR(PJ_EPENDING, "Pending operation" ),
+ PJ_BUILD_ERR(PJ_ETOOMANYCONN, "Too many connecting sockets" ),
+ PJ_BUILD_ERR(PJ_EINVAL, "Invalid value or argument" ),
+ PJ_BUILD_ERR(PJ_ENAMETOOLONG, "Name too long" ),
+ PJ_BUILD_ERR(PJ_ENOTFOUND, "Not found" ),
+ PJ_BUILD_ERR(PJ_ENOMEM, "Not enough memory" ),
+ PJ_BUILD_ERR(PJ_EBUG, "BUG DETECTED!" ),
+ PJ_BUILD_ERR(PJ_ETIMEDOUT, "Operation timed out" ),
+ PJ_BUILD_ERR(PJ_ETOOMANY, "Too many objects of the specified type"),
+ PJ_BUILD_ERR(PJ_EBUSY, "Object is busy"),
+ PJ_BUILD_ERR(PJ_ENOTSUP, "Option/operation is not supported"),
+ PJ_BUILD_ERR(PJ_EINVALIDOP, "Invalid operation"),
+ PJ_BUILD_ERR(PJ_ECANCELLED, "Operation cancelled"),
+ PJ_BUILD_ERR(PJ_EEXISTS, "Object already exists" ),
+ PJ_BUILD_ERR(PJ_EEOF, "End of file" ),
+ PJ_BUILD_ERR(PJ_ETOOBIG, "Size is too big"),
+ PJ_BUILD_ERR(PJ_ERESOLVE, "gethostbyname() has returned error"),
+ PJ_BUILD_ERR(PJ_ETOOSMALL, "Size is too short"),
+ PJ_BUILD_ERR(PJ_EIGNORED, "Ignored"),
+ PJ_BUILD_ERR(PJ_EIPV6NOTSUP, "IPv6 is not supported"),
+ PJ_BUILD_ERR(PJ_EAFNOTSUP, "Unsupported address family"),
+ PJ_BUILD_ERR(PJ_EGONE, "Object no longer exists"),
+ PJ_BUILD_ERR(PJ_ESOCKETSTOP, "Socket is in bad state")
+};
+#endif /* PJ_HAS_ERROR_STRING */
+
+
+/*
+ * pjlib_error()
+ *
+ * Retrieve message string for PJLIB's own error code.
+ */
+static int pjlib_error(pj_status_t code, char *buf, pj_size_t size)
+{
+ int len;
+
+#if defined(PJ_HAS_ERROR_STRING) && PJ_HAS_ERROR_STRING!=0
+ unsigned i;
+
+ for (i=0; i<sizeof(err_str)/sizeof(err_str[0]); ++i) {
+ if (err_str[i].code == code) {
+ pj_size_t len = strlen(err_str[i].msg);
+ if (len >= size) len = size-1;
+ pj_memcpy(buf, err_str[i].msg, len);
+ buf[len] = '\0';
+ return (int)len;
+ }
+ }
+#endif
+
+ len = pj_ansi_snprintf( buf, size, "Unknown pjlib error %d", code);
+ if (len < 1 || len >= (int)size)
+ len = size - 1;
+ return len;
+}
+
+#define IN_RANGE(val,start,end) ((val)>=(start) && (val)<(end))
+
+/* Register strerror handle. */
+PJ_DEF(pj_status_t) pj_register_strerror( pj_status_t start,
+ pj_status_t space,
+ pj_error_callback f)
+{
+ unsigned i;
+
+ /* Check arguments. */
+ PJ_ASSERT_RETURN(start && space && f, PJ_EINVAL);
+
+ /* Check if there aren't too many handlers registered. */
+ PJ_ASSERT_RETURN(err_msg_hnd_cnt < PJ_ARRAY_SIZE(err_msg_hnd),
+ PJ_ETOOMANY);
+
+ /* Start error must be greater than PJ_ERRNO_START_USER */
+ PJ_ASSERT_RETURN(start >= PJ_ERRNO_START_USER, PJ_EEXISTS);
+
+ /* Check that no existing handler has covered the specified range. */
+ for (i=0; i<err_msg_hnd_cnt; ++i) {
+ if (IN_RANGE(start, err_msg_hnd[i].begin, err_msg_hnd[i].end) ||
+ IN_RANGE(start+space-1, err_msg_hnd[i].begin, err_msg_hnd[i].end))
+ {
+ if (err_msg_hnd[i].begin == start &&
+ err_msg_hnd[i].end == (start+space) &&
+ err_msg_hnd[i].strerror == f)
+ {
+ /* The same range and handler has already been registered */
+ return PJ_SUCCESS;
+ }
+
+ return PJ_EEXISTS;
+ }
+ }
+
+ /* Register the handler. */
+ err_msg_hnd[err_msg_hnd_cnt].begin = start;
+ err_msg_hnd[err_msg_hnd_cnt].end = start + space;
+ err_msg_hnd[err_msg_hnd_cnt].strerror = f;
+
+ ++err_msg_hnd_cnt;
+
+ return PJ_SUCCESS;
+}
+
+/* Internal PJLIB function called by pj_shutdown() to clear error handlers */
+void pj_errno_clear_handlers(void)
+{
+ err_msg_hnd_cnt = 0;
+ pj_bzero(err_msg_hnd, sizeof(err_msg_hnd));
+}
+
+
+/*
+ * pj_strerror()
+ */
+PJ_DEF(pj_str_t) pj_strerror( pj_status_t statcode,
+ char *buf, pj_size_t bufsize )
+{
+ int len = -1;
+ pj_str_t errstr;
+
+ pj_assert(buf && bufsize);
+
+ if (statcode == PJ_SUCCESS) {
+ len = pj_ansi_snprintf( buf, bufsize, "Success");
+
+ } else if (statcode < PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE) {
+ len = pj_ansi_snprintf( buf, bufsize, "Unknown error %d", statcode);
+
+ } else if (statcode < PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE) {
+ len = pjlib_error(statcode, buf, bufsize);
+
+ } else if (statcode < PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE) {
+ len = platform_strerror(PJ_STATUS_TO_OS(statcode), buf, bufsize);
+
+ } else {
+ unsigned i;
+
+ /* Find user handler to get the error message. */
+ for (i=0; i<err_msg_hnd_cnt; ++i) {
+ if (IN_RANGE(statcode, err_msg_hnd[i].begin, err_msg_hnd[i].end)) {
+ return (*err_msg_hnd[i].strerror)(statcode, buf, bufsize);
+ }
+ }
+
+ /* Handler not found! */
+ len = pj_ansi_snprintf( buf, bufsize, "Unknown error %d", statcode);
+ }
+
+ if (len < 1 || len >= (int)bufsize) {
+ len = bufsize - 1;
+ buf[len] = '\0';
+ }
+
+ errstr.ptr = buf;
+ errstr.slen = len;
+
+ return errstr;
+}
+
+#if PJ_LOG_MAX_LEVEL >= 1
+static void invoke_log(const char *sender, int level, const char *format, ...)
+{
+ va_list arg;
+ va_start(arg, format);
+ pj_log(sender, level, format, arg);
+ va_end(arg);
+}
+
+static void pj_perror_imp(int log_level, const char *sender,
+ pj_status_t status,
+ const char *title_fmt, va_list marker)
+{
+ char titlebuf[PJ_PERROR_TITLE_BUF_SIZE];
+ char errmsg[PJ_ERR_MSG_SIZE];
+ int len;
+
+ /* Build the title */
+ len = pj_ansi_vsnprintf(titlebuf, sizeof(titlebuf), title_fmt, marker);
+ if (len < 0 || len >= (int)sizeof(titlebuf))
+ pj_ansi_strcpy(titlebuf, "Error");
+
+ /* Get the error */
+ pj_strerror(status, errmsg, sizeof(errmsg));
+
+ /* Send to log */
+ invoke_log(sender, log_level, "%s: %s", titlebuf, errmsg);
+}
+
+PJ_DEF(void) pj_perror(int log_level, const char *sender, pj_status_t status,
+ const char *title_fmt, ...)
+{
+ va_list marker;
+ va_start(marker, title_fmt);
+ pj_perror_imp(log_level, sender, status, title_fmt, marker);
+ va_end(marker);
+}
+
+PJ_DEF(void) pj_perror_1(const char *sender, pj_status_t status,
+ const char *title_fmt, ...)
+{
+ va_list marker;
+ va_start(marker, title_fmt);
+ pj_perror_imp(1, sender, status, title_fmt, marker);
+ va_end(marker);
+}
+
+#else /* #if PJ_LOG_MAX_LEVEL >= 1 */
+PJ_DEF(void) pj_perror(int log_level, const char *sender, pj_status_t status,
+ const char *title_fmt, ...)
+{
+}
+#endif /* #if PJ_LOG_MAX_LEVEL >= 1 */
+
+
+#if PJ_LOG_MAX_LEVEL >= 2
+PJ_DEF(void) pj_perror_2(const char *sender, pj_status_t status,
+ const char *title_fmt, ...)
+{
+ va_list marker;
+ va_start(marker, title_fmt);
+ pj_perror_imp(2, sender, status, title_fmt, marker);
+ va_end(marker);
+}
+#endif
+
+#if PJ_LOG_MAX_LEVEL >= 3
+PJ_DEF(void) pj_perror_3(const char *sender, pj_status_t status,
+ const char *title_fmt, ...)
+{
+ va_list marker;
+ va_start(marker, title_fmt);
+ pj_perror_imp(3, sender, status, title_fmt, marker);
+ va_end(marker);
+}
+#endif
+
+#if PJ_LOG_MAX_LEVEL >= 4
+PJ_DEF(void) pj_perror_4(const char *sender, pj_status_t status,
+ const char *title_fmt, ...)
+{
+ va_list marker;
+ va_start(marker, title_fmt);
+ pj_perror_imp(4, sender, status, title_fmt, marker);
+ va_end(marker);
+}
+#endif
+
+#if PJ_LOG_MAX_LEVEL >= 5
+PJ_DEF(void) pj_perror_5(const char *sender, pj_status_t status,
+ const char *title_fmt, ...)
+{
+ va_list marker;
+ va_start(marker, title_fmt);
+ pj_perror_imp(5, sender, status, title_fmt, marker);
+ va_end(marker);
+}
+#endif
+
+#if PJ_LOG_MAX_LEVEL >= 6
+PJ_DEF(void) pj_perror_6(const char *sender, pj_status_t status,
+ const char *title_fmt, ...)
+{
+ va_list marker;
+ va_start(marker, title_fmt);
+ pj_perror_imp(6, sender, status, title_fmt, marker);
+ va_end(marker);
+}
+#endif
+
diff --git a/jni/pjproject-android/.svn/pristine/6b/6b73d8f35cbc60a67b28dec0ac6c8d0b121e5d30.svn-base b/jni/pjproject-android/.svn/pristine/6b/6b73d8f35cbc60a67b28dec0ac6c8d0b121e5d30.svn-base
new file mode 100644
index 0000000..8ab4a76
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/6b/6b73d8f35cbc60a67b28dec0ac6c8d0b121e5d30.svn-base
@@ -0,0 +1,55 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2011 Teluu Inc. (http://www.teluu.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef VIDWIN_H
+#define VIDWIN_H
+
+#include <pjsua.h>
+#include <QWidget>
+#include <QBoxLayout>
+
+class VidWin : public QWidget
+{
+ Q_OBJECT
+
+public:
+ VidWin(const pjmedia_vid_dev_hwnd *hwnd,
+ QWidget* parent = 0,
+ Qt::WindowFlags f = 0);
+ virtual ~VidWin();
+ QSize sizeHint() const { return size_hint; }
+
+ void putIntoLayout(QBoxLayout *layout);
+
+protected:
+ virtual bool event(QEvent *e);
+
+private:
+ pjmedia_vid_dev_hwnd hwnd;
+ void *orig_parent;
+ QSize size_hint;
+
+ void attach();
+ void detach();
+ void set_size();
+ void get_size();
+ void show_sdl(bool visible=true);
+};
+
+#endif
+
diff --git a/jni/pjproject-android/.svn/pristine/6b/6b7e0ba141c8aa703fc0fc785dfd1f975e7d5f1a.svn-base b/jni/pjproject-android/.svn/pristine/6b/6b7e0ba141c8aa703fc0fc785dfd1f975e7d5f1a.svn-base
new file mode 100644
index 0000000..216b8b4
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/6b/6b7e0ba141c8aa703fc0fc785dfd1f975e7d5f1a.svn-base
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Early BYE">
+ <recv request="INVITE" crlf="true">
+ <action>
+ <ereg regexp=".*" search_in="hdr" header="From" assign_to="3"/>
+ <ereg regexp="sip:(.*)>" search_in="hdr" header="Contact" assign_to="4,5"/>
+ <assign assign_to="4" variable="5" />
+ </action>
+ </recv>
+
+ <send>
+ <![CDATA[
+ SIP/2.0 100 Trying
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 180 Ringing
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: sip:sipp@[local_ip]:[local_port]
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <send retrans="500">
+ <![CDATA[
+
+ BYE sip:[$5] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port]
+ From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[call_number]
+ To[$3]
+ Call-ID: [call_id]
+ Cseq: 1 BYE
+ Contact: sip:sipp@[local_ip]:[local_port]
+ Max-Forwards: 70
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv response="200">
+ </recv>
+
+
+ <!-- definition of the response time repartition table (unit is ms) -->
+ <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
+
+ <!-- definition of the call length repartition table (unit is ms) -->
+ <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
+
+</scenario>
+
diff --git a/jni/pjproject-android/.svn/pristine/6b/6b8ee8df8f5849884c4fc70161691d4c5413c84f.svn-base b/jni/pjproject-android/.svn/pristine/6b/6b8ee8df8f5849884c4fc70161691d4c5413c84f.svn-base
new file mode 100644
index 0000000..a9ee8dd
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/6b/6b8ee8df8f5849884c4fc70161691d4c5413c84f.svn-base
@@ -0,0 +1,175 @@
+# $Id$
+#
+# Presence and instant messaging
+#
+# Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+import sys
+import pjsua as pj
+
+LOG_LEVEL = 3
+pending_pres = None
+pending_uri = None
+
+def log_cb(level, str, len):
+ print str,
+
+class MyAccountCallback(pj.AccountCallback):
+ def __init__(self, account=None):
+ pj.AccountCallback.__init__(self, account)
+
+ def on_incoming_subscribe(self, buddy, from_uri, contact_uri, pres):
+ global pending_pres, pending_uri
+ # Allow buddy to subscribe to our presence
+ if buddy:
+ return (200, None)
+ print 'Incoming SUBSCRIBE request from', from_uri
+ print 'Press "A" to accept and add, "R" to reject the request'
+ pending_pres = pres
+ pending_uri = from_uri
+ return (202, None)
+
+
+class MyBuddyCallback(pj.BuddyCallback):
+ def __init__(self, buddy=None):
+ pj.BuddyCallback.__init__(self, buddy)
+
+ def on_state(self):
+ print "Buddy", self.buddy.info().uri, "is",
+ print self.buddy.info().online_text
+
+ def on_pager(self, mime_type, body):
+ print "Instant message from", self.buddy.info().uri,
+ print "(", mime_type, "):"
+ print body
+
+ def on_pager_status(self, body, im_id, code, reason):
+ if code >= 300:
+ print "Message delivery failed for message",
+ print body, "to", self.buddy.info().uri, ":", reason
+
+ def on_typing(self, is_typing):
+ if is_typing:
+ print self.buddy.info().uri, "is typing"
+ else:
+ print self.buddy.info().uri, "stops typing"
+
+
+lib = pj.Lib()
+
+try:
+ # Init library with default config and some customized
+ # logging config.
+ lib.init(log_cfg = pj.LogConfig(level=LOG_LEVEL, callback=log_cb))
+
+ # Create UDP transport which listens to any available port
+ transport = lib.create_transport(pj.TransportType.UDP,
+ pj.TransportConfig(0))
+ print "\nListening on", transport.info().host,
+ print "port", transport.info().port, "\n"
+
+ # Start the library
+ lib.start()
+
+ # Create local account
+ acc = lib.create_account_for_transport(transport, cb=MyAccountCallback())
+ acc.set_basic_status(True)
+
+ my_sip_uri = "sip:" + transport.info().host + \
+ ":" + str(transport.info().port)
+
+ buddy = None
+
+ # Menu loop
+ while True:
+ print "My SIP URI is", my_sip_uri
+ print "Menu: a=add buddy, d=delete buddy, t=toggle", \
+ " online status, i=send IM, q=quit"
+
+ input = sys.stdin.readline().rstrip("\r\n")
+ if input == "a":
+ # Add buddy
+ print "Enter buddy URI: ",
+ input = sys.stdin.readline().rstrip("\r\n")
+ if input == "":
+ continue
+
+ buddy = acc.add_buddy(input, cb=MyBuddyCallback())
+ buddy.subscribe()
+
+ elif input == "t":
+ acc.set_basic_status(not acc.info().online_status)
+
+ elif input == "i":
+ if not buddy:
+ print "Add buddy first"
+ continue
+
+ buddy.send_typing_ind(True)
+
+ print "Type the message: ",
+ input = sys.stdin.readline().rstrip("\r\n")
+ if input == "":
+ buddy.send_typing_ind(False)
+ continue
+
+ buddy.send_pager(input)
+
+ elif input == "d":
+ if buddy:
+ buddy.delete()
+ buddy = None
+ else:
+ print 'No buddy was added'
+
+ elif input == "A":
+ if pending_pres:
+ acc.pres_notify(pending_pres, pj.SubscriptionState.ACTIVE)
+ buddy = acc.add_buddy(pending_uri, cb=MyBuddyCallback())
+ buddy.subscribe()
+ pending_pres = None
+ pending_uri = None
+ else:
+ print "No pending request"
+
+ elif input == "R":
+ if pending_pres:
+ acc.pres_notify(pending_pres, pj.SubscriptionState.TERMINATED,
+ "rejected")
+ pending_pres = None
+ pending_uri = None
+ else:
+ print "No pending request"
+
+ elif input == "q":
+ break
+
+ # Shutdown the library
+ acc.delete()
+ acc = None
+ if pending_pres:
+ acc.pres_notify(pending_pres, pj.SubscriptionState.TERMINATED,
+ "rejected")
+ transport = None
+ lib.destroy()
+ lib = None
+
+except pj.Error, e:
+ print "Exception: " + str(e)
+ lib.destroy()
+ lib = None
+