Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > 8839b0a2474211d1e41984e51e6c40b7 > files > 47

linphone-devel-3.5.2-5.fc18.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>liblinphone: Chat room and messaging</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">liblinphone
   &#160;<span id="projectnumber">3.5.2</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.1.2 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Chat room and messaging</div>  </div>
<div class="ingroups"><a class="el" href="group__tutorials.html">Tutorials:</a></div></div><!--header-->
<div class="contents">
<p>*This program is a <em>very</em> simple usage example of liblinphone, *desmonstrating how to send/receive SIP MESSAGE from a sip uri identity passed from the command line. <br/>
Argument must be like sip:<a href="#" onclick="location.href='mai'+'lto:'+'jeh'+'an'+'@si'+'p.'+'lin'+'ph'+'one'+'.o'+'rg'; return false;">jehan<span style="display: none;">.nosp@m.</span>@sip<span style="display: none;">.nosp@m.</span>.linp<span style="display: none;">.nosp@m.</span>hone<span style="display: none;">.nosp@m.</span>.org</a> . <br/>
 *ex chatroom sip:<a href="#" onclick="location.href='mai'+'lto:'+'jeh'+'an'+'@si'+'p.'+'lin'+'ph'+'one'+'.o'+'rg'; return false;">jehan<span style="display: none;">.nosp@m.</span>@sip<span style="display: none;">.nosp@m.</span>.linp<span style="display: none;">.nosp@m.</span>hone<span style="display: none;">.nosp@m.</span>.org</a> <br/>
 </p>
<div class="fragment"><div class="line"></div>
<div class="line"><span class="comment">/*</span></div>
<div class="line"><span class="comment">linphone</span></div>
<div class="line"><span class="comment">Copyright (C) 2010  Belledonne Communications SARL </span></div>
<div class="line"><span class="comment"></span></div>
<div class="line"><span class="comment">This program is free software; you can redistribute it and/or</span></div>
<div class="line"><span class="comment">modify it under the terms of the GNU General Public License</span></div>
<div class="line"><span class="comment">as published by the Free Software Foundation; either version 2</span></div>
<div class="line"><span class="comment">of the License, or (at your option) any later version.</span></div>
<div class="line"><span class="comment"></span></div>
<div class="line"><span class="comment">This program is distributed in the hope that it will be useful,</span></div>
<div class="line"><span class="comment">but WITHOUT ANY WARRANTY; without even the implied warranty of</span></div>
<div class="line"><span class="comment">MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span></div>
<div class="line"><span class="comment">GNU General Public License for more details.</span></div>
<div class="line"><span class="comment"></span></div>
<div class="line"><span class="comment">You should have received a copy of the GNU General Public License</span></div>
<div class="line"><span class="comment">along with this program; if not, write to the Free Software</span></div>
<div class="line"><span class="comment">Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.</span></div>
<div class="line"><span class="comment">*/</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#ifdef IN_LINPHONE</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#include &quot;linphonecore.h&quot;</span></div>
<div class="line"><span class="preprocessor">#else</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#include &quot;linphone/linphonecore.h&quot;</span></div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"><span class="preprocessor"></span></div>
<div class="line"><span class="preprocessor">#include &lt;signal.h&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="keyword">static</span> bool_t running=TRUE;</div>
<div class="line"></div>
<div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> stop(<span class="keywordtype">int</span> signum){</div>
<div class="line">        running=FALSE;</div>
<div class="line">}</div>
<div class="line"><span class="keywordtype">void</span> text_received(<a class="code" href="group__initializing.html#gaa5cf635b82dd338e7ee2dd3599d05f0a">LinphoneCore</a> *lc, <a class="code" href="group__chatroom.html#ga37902f3fc715b7f6451c241d0efd0299">LinphoneChatRoom</a> *room, <span class="keyword">const</span> <a class="code" href="group__linphone__address.html#gaa017e66840f5ee578168bd469b6c3e91">LinphoneAddress</a> *from, <span class="keyword">const</span> <span class="keywordtype">char</span> *message) {</div>
<div class="line">        printf(<span class="stringliteral">&quot; Message [%s] received from [%s] \n&quot;</span>,message,<a class="code" href="group__linphone__address.html#ga24c1a16f49f8b72f2bab65cc5d8a51af">linphone_address_as_string</a> (from));</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"></div>
<div class="line"><a class="code" href="group__initializing.html#gaa5cf635b82dd338e7ee2dd3599d05f0a">LinphoneCore</a> *lc;</div>
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]){</div>
<div class="line">        <a class="code" href="struct__LinphoneVTable.html">LinphoneCoreVTable</a> vtable={0};</div>
<div class="line"></div>
<div class="line">        <span class="keywordtype">char</span>* dest_friend=NULL;</div>
<div class="line"></div>
<div class="line"></div>
<div class="line">        <span class="comment">/* takes   sip uri  identity from the command line arguments */</span></div>
<div class="line">        <span class="keywordflow">if</span> (argc&gt;1){</div>
<div class="line">                dest_friend=argv[1];</div>
<div class="line">        }</div>
<div class="line"></div>
<div class="line">        signal(SIGINT,stop);</div>
<div class="line"><span class="comment">//#define DEBUG</span></div>
<div class="line"><span class="preprocessor">#ifdef DEBUG</span></div>
<div class="line"><span class="preprocessor"></span>        <a class="code" href="group__misc.html#gad70dc5268366c829238b458547fe5277">linphone_core_enable_logs</a>(NULL); <span class="comment">/*enable liblinphone logs.*/</span></div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"><span class="preprocessor"></span>        <span class="comment">/* </span></div>
<div class="line"><span class="comment">         Fill the LinphoneCoreVTable with application callbacks.</span></div>
<div class="line"><span class="comment">         All are optional. Here we only use the text_received callback</span></div>
<div class="line"><span class="comment">         in order to get notifications about incoming message.</span></div>
<div class="line"><span class="comment">         */</span></div>
<div class="line">        vtable.<a class="code" href="struct__LinphoneVTable.html#aa2d467de0d6fcf1ca5c74b55b14da44e">text_received</a>=text_received;</div>
<div class="line"></div>
<div class="line">        <span class="comment">/*</span></div>
<div class="line"><span class="comment">         Instantiate a LinphoneCore object given the LinphoneCoreVTable</span></div>
<div class="line"><span class="comment">        */</span></div>
<div class="line">        lc=<a class="code" href="group__initializing.html#gac93ed982ae84a5a282a703c8433ca42f">linphone_core_new</a>(&amp;vtable,NULL,NULL,NULL);</div>
<div class="line"></div>
<div class="line"></div>
<div class="line">        <span class="comment">/*Next step is to create a chat root*/</span></div>
<div class="line">        <a class="code" href="group__chatroom.html#ga37902f3fc715b7f6451c241d0efd0299">LinphoneChatRoom</a>* chat_room = <a class="code" href="group__chatroom.html#ga02c675b2181e77397694e801cd606e85">linphone_core_create_chat_room</a>(lc,dest_friend);</div>
<div class="line"></div>
<div class="line">        <a class="code" href="group__chatroom.html#ga5d70a868f932e0793991c8aca1289591">linphone_chat_room_send_message</a>(chat_room,<span class="stringliteral">&quot;Hello world&quot;</span>); <span class="comment">/*sending message*/</span></div>
<div class="line"></div>
<div class="line">        <span class="comment">/* main loop for receiving incoming messages and doing background linphone core work: */</span></div>
<div class="line">        <span class="keywordflow">while</span>(running){</div>
<div class="line">                <a class="code" href="group__initializing.html#ga7bdac8ac386483fc4e0876e4c5d13755">linphone_core_iterate</a>(lc);</div>
<div class="line">                ms_usleep(50000);</div>
<div class="line">        }</div>
<div class="line"></div>
<div class="line">        printf(<span class="stringliteral">&quot;Shutting down...\n&quot;</span>);</div>
<div class="line">        <a class="code" href="group__chatroom.html#gaa2ae6260190b412b2183d5b70b7c7ea9">linphone_chat_room_destroy</a>(chat_room);</div>
<div class="line">        <a class="code" href="group__initializing.html#ga5e3f2f87c8d8262caa1fa90bbd504008">linphone_core_destroy</a>(lc);</div>
<div class="line">        printf(<span class="stringliteral">&quot;Exited\n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span> 0;</div>
<div class="line">}</div>
<div class="line"></div>
</div><!-- fragment --> </div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.1.2
</small></address>
</body>
</html>