]> sjero.net Git - linphone/blobdiff - console/commands.c
support for in call MESSAGEs
[linphone] / console / commands.c
index 82044797e7b2ce14a3098aeb85a0a73dc4cbb0bb..8232a26fda2e5a03e42fe290ff34d5865e352f9f 100644 (file)
@@ -53,6 +53,7 @@ extern char *lpc_strip_blanks(char *input);
 static int lpc_cmd_help(LinphoneCore *, char *);
 static int lpc_cmd_proxy(LinphoneCore *, char *);
 static int lpc_cmd_call(LinphoneCore *, char *);
+static int lpc_cmd_chat(LinphoneCore *, char *);
 static int lpc_cmd_answer(LinphoneCore *, char *);
 static int lpc_cmd_autoanswer(LinphoneCore *, char *);
 static int lpc_cmd_terminate(LinphoneCore *, char *);
@@ -122,6 +123,10 @@ LPC_COMMAND commands[] = {
                "'call <sip-url>' "
                ": initiate a call to the specified destination."
                },
+       { "chat", lpc_cmd_chat, "Chat with a SIP uri",
+               "'chat <sip-url> \"message\"' "
+               ": send a chat message \"message\" to the specified destination."
+               },
        { "terminate", lpc_cmd_terminate, "Terminate the current call",
                NULL },
        { "answer", lpc_cmd_answer, "Answer a call",
@@ -388,6 +393,35 @@ lpc_cmd_call(LinphoneCore *lc, char *args)
        return 1;
 }
 
+static int
+lpc_cmd_chat(LinphoneCore *lc, char *args)
+{
+       char *arg1 = args;
+       char *arg2 = NULL;
+       char *ptr = args;
+
+       if (!args) return 0;
+
+       /* Isolate first and second arg */
+       while(*ptr && !isspace(*ptr)) ++ptr;
+       if ( *ptr )
+       {
+               *ptr='\0';
+               arg2=ptr+1;
+               while(*arg2 && isspace(*arg2)) ++arg2;
+       }
+       else
+       {
+               /* missing one parameter */
+               return 0;
+       }
+       LinphoneChatRoom *cr = linphone_core_create_chat_room(lc,arg1);
+       linphone_chat_room_send_message(cr,arg2);
+       linphone_chat_room_destroy(cr);
+
+       return 1;
+}
+
 const char *linphonec_get_callee(){
        return callee_name;
 }