<?xml version="1.0" encoding="UTF-8"?> <!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" lang="en_US" xml:lang="en_US"> <head> <title>interfaces: kimproxy.cpp Source File (interfaces)</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="pics-label" content='(pics-1.1 "http://www.icra.org/ratingsv02.html" comment "ICRAonline DE v2.0" l gen true for "http://www.kde.org" r (nz 1 vz 1 lz 1 oz 1 cb 1) "http://www.rsac.org/ratingsv01.html" l gen true for "http://www.kde.org" r (n 0 s 0 v 0 l 0))' /> <meta name="trademark" content="KDE e.V." /> <meta name="description" content="K Desktop Environment Homepage, KDE.org" /> <meta name="MSSmartTagsPreventParsing" content="true" /> <meta name="robots" content="all" /> <link rel="shortcut icon" href="../../favicon.ico" /> <link rel="stylesheet" media="screen" type="text/css" title="APIDOX" href="doxygen.css" /> </head> <body> <div id="nav_header_top" align="right"> <a href="#content" class="doNotDisplay" accesskey="2">Skip to main content ::</a> <a href="../.."><img id="nav_header_logo" alt="Home" align="left" src="../../kde_gear_64.png" border="0" /></a> <span class="doNotDisplay">::</span> <div id="nav_header_title" align="left">KDE API Reference</div> </div> <div id="nav_header_bottom" align="right"> <span class="doNotDisplay">:: <a href="#navigation" accesskey="5">Skip to Link Menu</a><br/></span> <div id="nav_header_bottom_right" style="text-align: left;"> / <a href="../..">API Reference</a> / <a href=".">interfaces</a> </div> </div> <table id="main" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td valign="top" class="menuheader" height="0"></td> <td id="contentcolumn" valign="top" rowspan="2" > <div id="content" style="padding-top: 0px;"><div style="width:100%; margin: 0px; padding: 0px;"> <a name="content"></a> <!-- Generated by Doxygen 1.5.5 --> <h1>kimproxy.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* </span> <a name="l00002"></a>00002 <span class="comment"> kimproxy.cpp</span> <a name="l00003"></a>00003 <span class="comment"> </span> <a name="l00004"></a>00004 <span class="comment"> IM service library for KDE</span> <a name="l00005"></a>00005 <span class="comment"> </span> <a name="l00006"></a>00006 <span class="comment"> Copyright (c) 2004 Will Stephenson <lists@stevello.free-online.co.uk></span> <a name="l00007"></a>00007 <span class="comment"></span> <a name="l00008"></a>00008 <span class="comment"> This library is free software; you can redistribute it and/or</span> <a name="l00009"></a>00009 <span class="comment"> modify it under the terms of the GNU Library General Public</span> <a name="l00010"></a>00010 <span class="comment"> License as published by the Free Software Foundation; either</span> <a name="l00011"></a>00011 <span class="comment"> version 2 of the License, or (at your option) any later version.</span> <a name="l00012"></a>00012 <span class="comment"></span> <a name="l00013"></a>00013 <span class="comment"> This library is distributed in the hope that it will be useful,</span> <a name="l00014"></a>00014 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00015"></a>00015 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span> <a name="l00016"></a>00016 <span class="comment"> Library General Public License for more details.</span> <a name="l00017"></a>00017 <span class="comment"></span> <a name="l00018"></a>00018 <span class="comment"> You should have received a copy of the GNU Library General Public License</span> <a name="l00019"></a>00019 <span class="comment"> along with this library; see the file COPYING.LIB. If not, write to</span> <a name="l00020"></a>00020 <span class="comment"> the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,</span> <a name="l00021"></a>00021 <span class="comment"> Boston, MA 02110-1301, USA.</span> <a name="l00022"></a>00022 <span class="comment">*/</span> <a name="l00023"></a>00023 <a name="l00024"></a>00024 <span class="preprocessor">#include <qglobal.h></span> <a name="l00025"></a>00025 <span class="preprocessor">#include <qpixmapcache.h></span> <a name="l00026"></a>00026 <span class="preprocessor">#include <dcopclient.h></span> <a name="l00027"></a>00027 <span class="preprocessor">#include <kapplication.h></span> <a name="l00028"></a>00028 <span class="preprocessor">#include <kdcopservicestarter.h></span> <a name="l00029"></a>00029 <span class="preprocessor">#include <kdebug.h></span> <a name="l00030"></a>00030 <span class="preprocessor">#include <kmessagebox.h></span> <a name="l00031"></a>00031 <span class="preprocessor">#include <ksimpleconfig.h></span> <a name="l00032"></a>00032 <span class="preprocessor">#include <kiconloader.h></span> <a name="l00033"></a>00033 <span class="preprocessor">#include <kservice.h></span> <a name="l00034"></a>00034 <span class="preprocessor">#include <kservicetype.h></span> <a name="l00035"></a>00035 <a name="l00036"></a>00036 <span class="preprocessor">#include "kimiface_stub.h"</span> <a name="l00037"></a>00037 <a name="l00038"></a>00038 <span class="preprocessor">#include "kimproxy.h"</span> <a name="l00039"></a>00039 <a name="l00040"></a>00040 <span class="keyword">static</span> <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKStaticDeleter.html">KStaticDeleter<KIMProxy></a> _staticDeleter; <a name="l00041"></a>00041 <a name="l00042"></a>00042 <a class="code" href="classKIMProxy.html" title="Provides access to instant messenger programs which implement KDE&#39;s instant messanger...">KIMProxy</a> * KIMProxy::s_instance = 0L; <a name="l00043"></a>00043 <a name="l00044"></a>00044 <span class="keyword">struct </span>AppPresenceCurrent <a name="l00045"></a>00045 { <a name="l00046"></a>00046 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qcstring.html">QCString</a> appId; <a name="l00047"></a>00047 <span class="keywordtype">int</span> presence; <a name="l00048"></a>00048 }; <a name="l00049"></a>00049 <a name="l00050"></a>00050 <span class="keyword">class </span>ContactPresenceListCurrent : <span class="keyword">public</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qvaluelist.html">QValueList</a><AppPresenceCurrent> <a name="l00051"></a>00051 { <a name="l00052"></a>00052 <span class="keyword">public</span>: <a name="l00053"></a>00053 <span class="comment">// return value indicates if the supplied parameter was better than any existing presence</span> <a name="l00054"></a>00054 <span class="keywordtype">bool</span> update( <span class="keyword">const</span> AppPresenceCurrent ); <a name="l00055"></a>00055 AppPresenceCurrent best(); <a name="l00056"></a>00056 }; <a name="l00057"></a>00057 <a name="l00058"></a>00058 <a name="l00059"></a>00059 <span class="keyword">struct </span>KIMProxy::Private <a name="l00060"></a>00060 { <a name="l00061"></a>00061 <a class="codeRef" doxygen="dcop.tag:../../dcop/html/" href="../../dcop/html/classDCOPClient.html">DCOPClient</a> * dc; <a name="l00062"></a>00062 <span class="comment">// list of the strings in use by KIMIface</span> <a name="l00063"></a>00063 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstringlist.html">QStringList</a> presence_strings; <a name="l00064"></a>00064 <span class="comment">// list of the icon names in use by KIMIface</span> <a name="l00065"></a>00065 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstringlist.html">QStringList</a> presence_icons; <a name="l00066"></a>00066 <span class="comment">// map of presences</span> <a name="l00067"></a>00067 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qmap.html">PresenceStringMap</a> presence_map; <a name="l00068"></a>00068 }; <a name="l00069"></a>00069 <a name="l00070"></a>00070 <span class="keywordtype">bool</span> ContactPresenceListCurrent::update( AppPresenceCurrent ap ) <a name="l00071"></a>00071 { <a name="l00072"></a>00072 <span class="keywordflow">if</span> ( isEmpty() ) <a name="l00073"></a>00073 { <a name="l00074"></a>00074 append( ap ); <a name="l00075"></a>00075 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00076"></a>00076 } <a name="l00077"></a>00077 <a name="l00078"></a>00078 <span class="keywordtype">bool</span> bestChanged = <span class="keyword">false</span>; <a name="l00079"></a>00079 AppPresenceCurrent best; <a name="l00080"></a>00080 best.presence = -1; <a name="l00081"></a>00081 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qvaluelist.html#iterator">ContactPresenceListCurrent::iterator</a> it = begin(); <a name="l00082"></a>00082 <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qvaluelist.html#iterator">ContactPresenceListCurrent::iterator</a> itEnd = <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/namespaceKStdAccel.html#8407902cbc74699e1a95168fee54c827">end</a>(); <a name="l00083"></a>00083 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qvaluelist.html#iterator">ContactPresenceListCurrent::iterator</a> existing = itEnd; <a name="l00084"></a>00084 <a name="l00085"></a>00085 <span class="keywordflow">while</span> ( it != itEnd ) <a name="l00086"></a>00086 { <a name="l00087"></a>00087 <span class="keywordflow">if</span> ( (*it).presence > best.presence ) <a name="l00088"></a>00088 best = (*it); <a name="l00089"></a>00089 <span class="keywordflow">if</span> ( (*it).appId == ap.appId ) <a name="l00090"></a>00090 existing = it; <a name="l00091"></a>00091 ++it; <a name="l00092"></a>00092 } <a name="l00093"></a>00093 <a name="l00094"></a>00094 <span class="keywordflow">if</span> ( ap.presence > best.presence || <a name="l00095"></a>00095 best.appId == ap.appId ) <a name="l00096"></a>00096 bestChanged = <span class="keyword">true</span>; <a name="l00097"></a>00097 <a name="l00098"></a>00098 <span class="keywordflow">if</span> ( existing != itEnd ) <a name="l00099"></a>00099 { <a name="l00100"></a>00100 <span class="keyword">remove</span>( existing ); <a name="l00101"></a>00101 append( ap ); <a name="l00102"></a>00102 } <a name="l00103"></a>00103 <span class="keywordflow">return</span> bestChanged; <a name="l00104"></a>00104 } <a name="l00105"></a>00105 <a name="l00106"></a>00106 AppPresenceCurrent ContactPresenceListCurrent::best() <a name="l00107"></a>00107 { <a name="l00108"></a>00108 AppPresenceCurrent best; <a name="l00109"></a>00109 best.presence = -1; <a name="l00110"></a>00110 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qvaluelist.html#iterator">ContactPresenceListCurrent::iterator</a> it = begin(); <a name="l00111"></a>00111 <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qvaluelist.html#iterator">ContactPresenceListCurrent::iterator</a> itEnd = <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/namespaceKStdAccel.html#8407902cbc74699e1a95168fee54c827">end</a>(); <a name="l00112"></a>00112 <span class="keywordflow">while</span> ( it != itEnd ) <a name="l00113"></a>00113 { <a name="l00114"></a>00114 <span class="keywordflow">if</span> ( (*it).presence > best.presence ) <a name="l00115"></a>00115 best = (*it); <a name="l00116"></a>00116 ++it; <a name="l00117"></a>00117 } <a name="l00118"></a>00118 <span class="comment">// if it's still -1 here, we have no presence data, so we return Unknown</span> <a name="l00119"></a>00119 <span class="keywordflow">if</span> ( best.presence == -1 ) <a name="l00120"></a>00120 best.presence = 0; <a name="l00121"></a>00121 <span class="keywordflow">return</span> best; <a name="l00122"></a>00122 } <a name="l00123"></a>00123 <a name="l00124"></a>00124 <span class="comment">// int bestPresence( AppPresence* ap )</span> <a name="l00125"></a>00125 <span class="comment">// {</span> <a name="l00126"></a>00126 <span class="comment">// Q_ASSERT( ap );</span> <a name="l00127"></a>00127 <span class="comment">// AppPresence::const_iterator it;</span> <a name="l00128"></a>00128 <span class="comment">// it = ap->begin();</span> <a name="l00129"></a>00129 <span class="comment">// int best = 0; // unknown</span> <a name="l00130"></a>00130 <span class="comment">// if ( it != ap->end() )</span> <a name="l00131"></a>00131 <span class="comment">// {</span> <a name="l00132"></a>00132 <span class="comment">// best = it.data();</span> <a name="l00133"></a>00133 <span class="comment">// ++it;</span> <a name="l00134"></a>00134 <span class="comment">// for ( ; it != ap->end(); ++it )</span> <a name="l00135"></a>00135 <span class="comment">// {</span> <a name="l00136"></a>00136 <span class="comment">// if ( it.data() > best )</span> <a name="l00137"></a>00137 <span class="comment">// best = it.data(); </span> <a name="l00138"></a>00138 <span class="comment">// }</span> <a name="l00139"></a>00139 <span class="comment">// }</span> <a name="l00140"></a>00140 <span class="comment">// return best;</span> <a name="l00141"></a>00141 <span class="comment">// }</span> <a name="l00142"></a>00142 <span class="comment">// </span> <a name="l00143"></a>00143 <span class="comment">// QCString bestAppId( AppPresence* ap )</span> <a name="l00144"></a>00144 <span class="comment">// {</span> <a name="l00145"></a>00145 <span class="comment">// Q_ASSERT( ap );</span> <a name="l00146"></a>00146 <span class="comment">// AppPresence::const_iterator it;</span> <a name="l00147"></a>00147 <span class="comment">// QCString bestAppId;</span> <a name="l00148"></a>00148 <span class="comment">// it = ap->begin();</span> <a name="l00149"></a>00149 <span class="comment">// if ( it != ap->end() )</span> <a name="l00150"></a>00150 <span class="comment">// {</span> <a name="l00151"></a>00151 <span class="comment">// int best = it.data();</span> <a name="l00152"></a>00152 <span class="comment">// bestAppId = it.key();</span> <a name="l00153"></a>00153 <span class="comment">// ++it;</span> <a name="l00154"></a>00154 <span class="comment">// for ( ; it != ap->end(); ++it )</span> <a name="l00155"></a>00155 <span class="comment">// {</span> <a name="l00156"></a>00156 <span class="comment">// if ( it.data() > best )</span> <a name="l00157"></a>00157 <span class="comment">// {</span> <a name="l00158"></a>00158 <span class="comment">// best = it.data();</span> <a name="l00159"></a>00159 <span class="comment">// bestAppId = it.key();</span> <a name="l00160"></a>00160 <span class="comment">// }</span> <a name="l00161"></a>00161 <span class="comment">// }</span> <a name="l00162"></a>00162 <span class="comment">// }</span> <a name="l00163"></a>00163 <span class="comment">// return bestAppId;</span> <a name="l00164"></a>00164 <span class="comment">// }</span> <a name="l00165"></a>00165 <a name="l00166"></a><a class="code" href="classKIMProxy.html#ba4d2f7cc6437a23dcbf3ac7be65e8b7">00166</a> <a class="code" href="classKIMProxy.html" title="Provides access to instant messenger programs which implement KDE&#39;s instant messanger...">KIMProxy</a> * <a class="code" href="classKIMProxy.html#ba4d2f7cc6437a23dcbf3ac7be65e8b7" title="Obtain an instance of KIMProxy.">KIMProxy::instance</a>( <a class="codeRef" doxygen="dcop.tag:../../dcop/html/" href="../../dcop/html/classDCOPClient.html">DCOPClient</a> * client ) <a name="l00167"></a>00167 { <a name="l00168"></a>00168 <span class="keywordflow">if</span> ( client ) <a name="l00169"></a>00169 { <a name="l00170"></a>00170 <span class="keywordflow">if</span> ( !s_instance ) <a name="l00171"></a>00171 _staticDeleter.<a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKStaticDeleter.html#55e1927b4df3dea163903d06a863dd9a">setObject</a>( s_instance, <span class="keyword">new</span> <a class="code" href="classKIMProxy.html" title="Provides access to instant messenger programs which implement KDE&#39;s instant messanger...">KIMProxy</a>( client ) ); <a name="l00172"></a>00172 <span class="keywordflow">return</span> s_instance; <a name="l00173"></a>00173 } <a name="l00174"></a>00174 <span class="keywordflow">else</span> <a name="l00175"></a>00175 <span class="keywordflow">return</span> 0L; <a name="l00176"></a>00176 } <a name="l00177"></a>00177 <a name="l00178"></a>00178 KIMProxy::KIMProxy( <a class="codeRef" doxygen="dcop.tag:../../dcop/html/" href="../../dcop/html/classDCOPClient.html">DCOPClient</a>* dc ) : <a class="codeRef" doxygen="dcop.tag:../../dcop/html/" href="../../dcop/html/classDCOPObject.html">DCOPObject</a>( <span class="stringliteral">"KIMProxyIface"</span> ), <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qobject.html">QObject</a>(), d( new Private ) <a name="l00179"></a>00179 { <a name="l00180"></a>00180 m_im_client_stubs.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdict.html#setAutoDelete">setAutoDelete</a>( <span class="keyword">true</span> ); <a name="l00181"></a>00181 <a name="l00182"></a>00182 d->dc = dc; <a name="l00183"></a>00183 m_initialized = <span class="keyword">false</span>; <a name="l00184"></a>00184 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qobject.html#connect">connect</a>( d->dc, SIGNAL( applicationRemoved( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qcstring.html">QCString</a>& ) ) , <span class="keyword">this</span>, SLOT( <a class="code" href="classKIMProxy.html#aaae56c3b58c99752f0bde08e97f533f" title="Updates the proxy&#39;s data after an application unregistered with DCOP.">unregisteredFromDCOP</a>( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qcstring.html">QCString</a>& ) ) ); <a name="l00185"></a>00185 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qobject.html#connect">connect</a>( d->dc, SIGNAL( applicationRegistered( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qcstring.html">QCString</a>& ) ) , <span class="keyword">this</span>, SLOT( <a class="code" href="classKIMProxy.html#e05a5b8eca2a84d920e56edee15c8813" title="Updates the proxy&#39;s data after a new application registered with DCOP.">registeredToDCOP</a>( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qcstring.html">QCString</a>& ) ) ); <a name="l00186"></a>00186 d->dc->setNotifications( <span class="keyword">true</span> ); <a name="l00187"></a>00187 <a name="l00188"></a>00188 d->presence_strings.append( <span class="stringliteral">"Unknown"</span> ); <a name="l00189"></a>00189 d->presence_strings.append( <span class="stringliteral">"Offline"</span> ); <a name="l00190"></a>00190 d->presence_strings.append( <span class="stringliteral">"Connecting"</span> ); <a name="l00191"></a>00191 d->presence_strings.append( <span class="stringliteral">"Away"</span> ); <a name="l00192"></a>00192 d->presence_strings.append( <span class="stringliteral">"Online"</span> ); <a name="l00193"></a>00193 <a name="l00194"></a>00194 d->presence_icons.append( <span class="stringliteral">"presence_unknown"</span> ); <a name="l00195"></a>00195 d->presence_icons.append( <span class="stringliteral">"presence_offline"</span> ); <a name="l00196"></a>00196 d->presence_icons.append( <span class="stringliteral">"presence_connecting"</span> ); <a name="l00197"></a>00197 d->presence_icons.append( <span class="stringliteral">"presence_away"</span> ); <a name="l00198"></a>00198 d->presence_icons.append( <span class="stringliteral">"presence_online"</span> ); <a name="l00199"></a>00199 <a name="l00200"></a>00200 <span class="comment">//QCString senderApp = "Kopete";</span> <a name="l00201"></a>00201 <span class="comment">//QCString senderObjectId = "KIMIface";</span> <a name="l00202"></a>00202 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qcstring.html">QCString</a> method = <span class="stringliteral">"contactPresenceChanged( QString, QCString, int )"</span>; <a name="l00203"></a>00203 <span class="comment">//QCString receiverObjectId = "KIMProxyIface";</span> <a name="l00204"></a>00204 <a name="l00205"></a>00205 <span class="comment">// FIXME: make this work when the sender object id is set to KIMIFace</span> <a name="l00206"></a>00206 <span class="keywordflow">if</span> ( !<a class="codeRef" doxygen="dcop.tag:../../dcop/html/" href="../../dcop/html/classDCOPObject.html#3d7cf9a93cfa8a3515c702b1b50db3f6">connectDCOPSignal</a>( 0, 0, method, method, <span class="keyword">false</span> ) ) <a name="l00207"></a>00207 <a class="codeRef" doxygen="kdeui.tag:../../kdeui/html/" href="../../kdeui/html/classKMessageBox.html#b65b0b4aeeae49d061f4b31ed2796105">KMessageBox::information</a>( 0, <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a>( <span class="stringliteral">"Couldn't connect DCOP signal.\nWon't receive any status notifications!"</span> ) ); <a name="l00208"></a>00208 } <a name="l00209"></a>00209 <a name="l00210"></a>00210 KIMProxy::~KIMProxy( ) <a name="l00211"></a>00211 { <a name="l00212"></a>00212 <span class="comment">//d->dc->setNotifications( false );</span> <a name="l00213"></a>00213 } <a name="l00214"></a>00214 <a name="l00215"></a><a class="code" href="classKIMProxy.html#3193fb0f41c75ceeaa33b4489601fe42">00215</a> <span class="keywordtype">bool</span> <a class="code" href="classKIMProxy.html#3193fb0f41c75ceeaa33b4489601fe42" title="Get the proxy ready to connect.">KIMProxy::initialize</a>() <a name="l00216"></a>00216 { <a name="l00217"></a>00217 <span class="keywordflow">if</span> ( !m_initialized ) <a name="l00218"></a>00218 { <a name="l00219"></a>00219 m_initialized = <span class="keyword">true</span>; <span class="comment">// we should only do this once, as registeredToDCOP() will catch any new starts</span> <a name="l00220"></a>00220 <span class="comment">// So there is no error from a failed query when using kdelibs 3.2, which don't have this servicetype</span> <a name="l00221"></a>00221 <span class="keywordflow">if</span> ( KServiceType::serviceType( IM_SERVICE_TYPE ) ) <a name="l00222"></a>00222 { <a name="l00223"></a>00223 <span class="comment">//kdDebug( 790 ) << k_funcinfo << endl;</span> <a name="l00224"></a>00224 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qcstring.html">QCString</a> dcopObjectId = <span class="stringliteral">"KIMIface"</span>; <a name="l00225"></a>00225 <a name="l00226"></a>00226 <span class="comment">// see what apps implementing our service type are out there</span> <a name="l00227"></a>00227 KService::List offers = KServiceType::offers( IM_SERVICE_TYPE ); <a name="l00228"></a>00228 KService::List::iterator offer; <a name="l00229"></a>00229 <span class="keyword">typedef</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qvaluelist.html">QValueList<QCString></a> QCStringList; <a name="l00230"></a>00230 QCStringList registeredApps = d->dc->registeredApplications(); <a name="l00231"></a>00231 QCStringList::iterator app; <a name="l00232"></a>00232 <span class="keyword">const</span> QCStringList::iterator end = registeredApps.end(); <a name="l00233"></a>00233 <span class="comment">// for each registered app</span> <a name="l00234"></a>00234 <span class="keywordflow">for</span> ( app = registeredApps.begin(); app != end; ++app ) <a name="l00235"></a>00235 { <a name="l00236"></a>00236 <span class="comment">//kdDebug( 790 ) << " considering: " << *app << endl;</span> <a name="l00237"></a>00237 <span class="comment">//for each offer</span> <a name="l00238"></a>00238 <span class="keywordflow">for</span> ( offer = offers.begin(); offer != offers.end(); ++offer ) <a name="l00239"></a>00239 { <a name="l00240"></a>00240 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qcstring.html">QCString</a> dcopService = (*offer)->property(<span class="stringliteral">"X-DCOP-ServiceName"</span>).<a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKShortcut.html#0aa8ca8706445e6b76cf53c207ac06ce">toString</a>().<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html#latin1">latin1</a>(); <a name="l00241"></a>00241 <span class="keywordflow">if</span> ( !dcopService.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qcstring.html#isEmpty">isEmpty</a>() ) <a name="l00242"></a>00242 { <a name="l00243"></a>00243 <span class="comment">//kdDebug( 790 ) << " is it: " << dcopService << "?" << endl;</span> <a name="l00244"></a>00244 <span class="comment">// get the application name ( minus any process ID )</span> <a name="l00245"></a>00245 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qcstring.html">QCString</a> instanceName = (*app).left( dcopService.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qcstring.html#length">length</a>() ); <a name="l00246"></a>00246 <span class="comment">// if the application implements the dcop service, add it </span> <a name="l00247"></a>00247 <span class="keywordflow">if</span> ( instanceName == dcopService ) <a name="l00248"></a>00248 { <a name="l00249"></a>00249 m_apps_available = <span class="keyword">true</span>; <a name="l00250"></a>00250 <span class="comment">//kdDebug( 790 ) << " app name: " << (*offer)->name() << ", has instance " << *app << ", dcopService: " << dcopService << endl;</span> <a name="l00251"></a>00251 <span class="keywordflow">if</span> ( !m_im_client_stubs.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdict.html#find">find</a>( dcopService ) ) <a name="l00252"></a>00252 { <a name="l00253"></a>00253 <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/group__kdebug.html#gfbb9aa4a84d6c0563d46550454b9714b">kdDebug</a>( 790 ) << <span class="stringliteral">"App "</span> << *app << <span class="stringliteral">", dcopObjectId "</span> << dcopObjectId << <span class="stringliteral">" found, using it for presence info."</span> << <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/group__kdebug.html#g313d520ed8f8f6b46eeef22cfb3b082a">endl</a>; <a name="l00254"></a>00254 m_im_client_stubs.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdict.html#insert">insert</a>( *app, <span class="keyword">new</span> KIMIface_stub( d->dc, *app, dcopObjectId ) ); <a name="l00255"></a>00255 <a class="code" href="classKIMProxy.html#9231fdbbfd7e4d850b20868a2b122e2c" title="Bootstrap our presence data for a newly registered app.">pollApp</a>( *app ); <a name="l00256"></a>00256 } <a name="l00257"></a>00257 } <a name="l00258"></a>00258 } <a name="l00259"></a>00259 } <a name="l00260"></a>00260 } <a name="l00261"></a>00261 } <a name="l00262"></a>00262 } <a name="l00263"></a>00263 <span class="keywordflow">return</span> !m_im_client_stubs.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdict.html#isEmpty">isEmpty</a>(); <a name="l00264"></a>00264 } <a name="l00265"></a>00265 <a name="l00266"></a><a class="code" href="classKIMProxy.html#e05a5b8eca2a84d920e56edee15c8813">00266</a> <span class="keywordtype">void</span> <a class="code" href="classKIMProxy.html#e05a5b8eca2a84d920e56edee15c8813" title="Updates the proxy&#39;s data after a new application registered with DCOP.">KIMProxy::registeredToDCOP</a>( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qcstring.html">QCString</a>& appId ) <a name="l00267"></a>00267 { <a name="l00268"></a>00268 <span class="comment">//kdDebug( 790 ) << k_funcinfo << " appId '" << appId << "'" << endl;</span> <a name="l00269"></a>00269 <span class="comment">// check that appId implements our service</span> <a name="l00270"></a>00270 <span class="comment">// if the appId ends with a number, i.e. a pid like in foobar-12345,</span> <a name="l00271"></a>00271 <span class="keywordflow">if</span> ( appId.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qcstring.html#isEmpty">isEmpty</a>() ) <a name="l00272"></a>00272 <span class="keywordflow">return</span>; <a name="l00273"></a>00273 <a name="l00274"></a>00274 <span class="keywordtype">bool</span> newApp = <span class="keyword">false</span>; <a name="l00275"></a>00275 <span class="comment">// get an up to date list of offers in case a new app was installed</span> <a name="l00276"></a>00276 <span class="comment">// and check each of the offers that implement the service type we're looking for,</span> <a name="l00277"></a>00277 <span class="comment">// to see if any of them are the app that just registered</span> <a name="l00278"></a>00278 <span class="keyword">const</span> KService::List offers = KServiceType::offers( IM_SERVICE_TYPE ); <a name="l00279"></a>00279 KService::List::const_iterator it; <a name="l00280"></a>00280 <span class="keywordflow">for</span> ( it = offers.begin(); it != offers.end(); ++it ) <a name="l00281"></a>00281 { <a name="l00282"></a>00282 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qcstring.html">QCString</a> dcopObjectId = <span class="stringliteral">"KIMIface"</span>; <a name="l00283"></a>00283 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qcstring.html">QCString</a> dcopService = (*it)->property(<span class="stringliteral">"X-DCOP-ServiceName"</span>).toString().latin1(); <a name="l00284"></a>00284 <span class="keywordflow">if</span> ( appId.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qcstring.html#left">left</a>( dcopService.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qcstring.html#length">length</a>() ) == dcopService ) <a name="l00285"></a>00285 { <a name="l00286"></a>00286 <span class="comment">// if it's not already known, insert it</span> <a name="l00287"></a>00287 <span class="keywordflow">if</span> ( !m_im_client_stubs.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdict.html#find">find</a>( appId ) ) <a name="l00288"></a>00288 { <a name="l00289"></a>00289 newApp = <span class="keyword">true</span>; <a name="l00290"></a>00290 <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/group__kdebug.html#gfbb9aa4a84d6c0563d46550454b9714b">kdDebug</a>( 790 ) << <span class="stringliteral">"App: "</span> << appId << <span class="stringliteral">", dcopService: "</span> << dcopService << <span class="stringliteral">" started, using it for presence info."</span><< <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/group__kdebug.html#g313d520ed8f8f6b46eeef22cfb3b082a">endl</a>; <a name="l00291"></a>00291 m_im_client_stubs.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdict.html#insert">insert</a>( appId, <span class="keyword">new</span> KIMIface_stub( d->dc, appId, dcopObjectId ) ); <a name="l00292"></a>00292 } <a name="l00293"></a>00293 } <a name="l00294"></a>00294 <span class="comment">//else</span> <a name="l00295"></a>00295 <span class="comment">// kdDebug( 790 ) << "App doesn't implement our ServiceType" << endl;</span> <a name="l00296"></a>00296 } <a name="l00297"></a>00297 <span class="comment">//if ( newApp )</span> <a name="l00298"></a>00298 <span class="comment">// emit sigPresenceInfoExpired();</span> <a name="l00299"></a>00299 } <a name="l00300"></a>00300 <a name="l00301"></a><a class="code" href="classKIMProxy.html#aaae56c3b58c99752f0bde08e97f533f">00301</a> <span class="keywordtype">void</span> <a class="code" href="classKIMProxy.html#aaae56c3b58c99752f0bde08e97f533f" title="Updates the proxy&#39;s data after an application unregistered with DCOP.">KIMProxy::unregisteredFromDCOP</a>( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qcstring.html">QCString</a>& appId ) <a name="l00302"></a>00302 { <a name="l00303"></a>00303 <span class="comment">//kdDebug( 790 ) << k_funcinfo << appId << endl;</span> <a name="l00304"></a>00304 <span class="keywordflow">if</span> ( m_im_client_stubs.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdict.html#find">find</a>( appId ) ) <a name="l00305"></a>00305 { <a name="l00306"></a>00306 <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/group__kdebug.html#gfbb9aa4a84d6c0563d46550454b9714b">kdDebug</a>( 790 ) << appId << <span class="stringliteral">" quit, removing its presence info."</span> << <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/group__kdebug.html#g313d520ed8f8f6b46eeef22cfb3b082a">endl</a>; <a name="l00307"></a>00307 <a name="l00308"></a>00308 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qmap.html#Iterator">PresenceStringMap::Iterator</a> it = d->presence_map.begin(); <a name="l00309"></a>00309 <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qmap.html#Iterator">PresenceStringMap::Iterator</a> end = d->presence_map.end(); <a name="l00310"></a>00310 <span class="keywordflow">for</span> ( ; it != end; ++it ) <a name="l00311"></a>00311 { <a name="l00312"></a>00312 ContactPresenceListCurrent list = it.data(); <a name="l00313"></a>00313 ContactPresenceListCurrent::iterator cpIt = list.begin(); <a name="l00314"></a>00314 <span class="keywordflow">while</span>( cpIt != list.end() ) <a name="l00315"></a>00315 { <a name="l00316"></a>00316 ContactPresenceListCurrent::iterator gone = cpIt++; <a name="l00317"></a>00317 <span class="keywordflow">if</span> ( (*gone).appId == appId ) <a name="l00318"></a>00318 { <a name="l00319"></a>00319 list.remove( gone ); <a name="l00320"></a>00320 } <a name="l00321"></a>00321 } <a name="l00322"></a>00322 } <a name="l00323"></a>00323 m_im_client_stubs.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdict.html#remove">remove</a>( appId ); <a name="l00324"></a>00324 emit <a class="code" href="classKIMProxy.html#1dc56f5c66e4dbfa5ff523ec1f21dd83" title="Indicates that presence information obtained earlier on might not be valid any longer...">sigPresenceInfoExpired</a>(); <a name="l00325"></a>00325 } <a name="l00326"></a>00326 } <a name="l00327"></a>00327 <a name="l00328"></a><a class="code" href="classKIMProxy.html#4fd78f3e6a9a306ff83681e04af8dc57">00328</a> <span class="keywordtype">void</span> <a class="code" href="classKIMProxy.html#4fd78f3e6a9a306ff83681e04af8dc57" title="Just exists to let the IDL compiler make the DCOP signal for this.">KIMProxy::contactPresenceChanged</a>( <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> uid, <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qcstring.html">QCString</a> appId, <span class="keywordtype">int</span> presence ) <a name="l00329"></a>00329 { <a name="l00330"></a>00330 <span class="comment">// update the presence map</span> <a name="l00331"></a>00331 <span class="comment">//kdDebug( 790 ) << k_funcinfo << "uid: " << uid << " appId: " << appId << " presence " << presence << endl;</span> <a name="l00332"></a>00332 ContactPresenceListCurrent current; <a name="l00333"></a>00333 current = d->presence_map[ uid ]; <a name="l00334"></a>00334 <span class="comment">//kdDebug( 790 ) << "current best presence from : " << current.best().appId << " is: " << current.best().presence << endl;</span> <a name="l00335"></a>00335 AppPresenceCurrent newPresence; <a name="l00336"></a>00336 newPresence.appId = appId; <a name="l00337"></a>00337 newPresence.presence = presence; <a name="l00338"></a>00338 <a name="l00339"></a>00339 <span class="keywordflow">if</span> ( current.update( newPresence ) ) <a name="l00340"></a>00340 { <a name="l00341"></a>00341 d->presence_map.insert( uid, current ); <a name="l00342"></a>00342 emit <a class="code" href="classKIMProxy.html#ee11bdb993679d6974e7690c73aae442" title="Indicates that the specified IM-contact&#39;s presence changed.">sigContactPresenceChanged</a>( uid ); <a name="l00343"></a>00343 } <a name="l00344"></a>00344 } <a name="l00345"></a>00345 <a name="l00346"></a><a class="code" href="classKIMProxy.html#5ef08be65cd6cd53eccaad945fe2044c">00346</a> <span class="keywordtype">int</span> <a class="code" href="classKIMProxy.html#5ef08be65cd6cd53eccaad945fe2044c" title="Obtain the IM presence as a number for the specified contact.">KIMProxy::presenceNumeric</a>( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a>& uid ) <a name="l00347"></a>00347 { <a name="l00348"></a>00348 AppPresenceCurrent ap; <a name="l00349"></a>00349 ap.presence = 0; <a name="l00350"></a>00350 <span class="keywordflow">if</span> ( <a class="code" href="classKIMProxy.html#3193fb0f41c75ceeaa33b4489601fe42" title="Get the proxy ready to connect.">initialize</a>() ) <a name="l00351"></a>00351 { <a name="l00352"></a>00352 ContactPresenceListCurrent presence = d->presence_map[ uid ]; <a name="l00353"></a>00353 ap = presence.best(); <a name="l00354"></a>00354 } <a name="l00355"></a>00355 <span class="keywordflow">return</span> ap.presence; <a name="l00356"></a>00356 } <a name="l00357"></a>00357 <a name="l00358"></a><a class="code" href="classKIMProxy.html#c67e20a529a22a578362eefe3fde816e">00358</a> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> <a class="code" href="classKIMProxy.html#c67e20a529a22a578362eefe3fde816e" title="Obtain the IM presence as a i18ned string for the specified contact.">KIMProxy::presenceString</a>( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a>& uid ) <a name="l00359"></a>00359 { <a name="l00360"></a>00360 AppPresenceCurrent ap; <a name="l00361"></a>00361 ap.presence = 0; <a name="l00362"></a>00362 <span class="keywordflow">if</span> ( <a class="code" href="classKIMProxy.html#3193fb0f41c75ceeaa33b4489601fe42" title="Get the proxy ready to connect.">initialize</a>() ) <a name="l00363"></a>00363 { <a name="l00364"></a>00364 ContactPresenceListCurrent presence = d->presence_map[ uid ]; <a name="l00365"></a>00365 ap = presence.best(); <a name="l00366"></a>00366 } <a name="l00367"></a>00367 <span class="keywordflow">if</span> ( ap.appId.isEmpty() ) <a name="l00368"></a>00368 <span class="keywordflow">return</span> QString::null; <a name="l00369"></a>00369 <span class="keywordflow">else</span> <a name="l00370"></a>00370 <span class="keywordflow">return</span> d->presence_strings[ ap.presence ]; <a name="l00371"></a>00371 } <a name="l00372"></a>00372 <a name="l00373"></a><a class="code" href="classKIMProxy.html#cac424488ca651eef5b2b2fa51814915">00373</a> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qpixmap.html">QPixmap</a> <a class="code" href="classKIMProxy.html#cac424488ca651eef5b2b2fa51814915" title="Obtain the icon representing the IM presence for the specified contact.">KIMProxy::presenceIcon</a>( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a>& uid ) <a name="l00374"></a>00374 { <a name="l00375"></a>00375 AppPresenceCurrent ap; <a name="l00376"></a>00376 ap.presence = 0; <a name="l00377"></a>00377 <span class="keywordflow">if</span> ( <a class="code" href="classKIMProxy.html#3193fb0f41c75ceeaa33b4489601fe42" title="Get the proxy ready to connect.">initialize</a>() ) <a name="l00378"></a>00378 { <a name="l00379"></a>00379 ContactPresenceListCurrent presence = d->presence_map[ uid ]; <a name="l00380"></a>00380 ap = presence.best(); <a name="l00381"></a>00381 } <a name="l00382"></a>00382 <span class="keywordflow">if</span> ( ap.appId.isEmpty() ) <a name="l00383"></a>00383 { <a name="l00384"></a>00384 <span class="comment">//kdDebug( 790 ) << k_funcinfo << "returning a null QPixmap because we were asked for an icon for a uid we know nothing about" << endl;</span> <a name="l00385"></a>00385 <span class="keywordflow">return</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qpixmap.html">QPixmap</a>(); <a name="l00386"></a>00386 } <a name="l00387"></a>00387 <span class="keywordflow">else</span> <a name="l00388"></a>00388 { <a name="l00389"></a>00389 <span class="comment">//kdDebug( 790 ) << k_funcinfo << "returning this: " << d->presence_icons[ ap.presence ] << endl;</span> <a name="l00390"></a>00390 <span class="keywordflow">return</span> SmallIcon( d->presence_icons[ ap.presence ]); <a name="l00391"></a>00391 } <a name="l00392"></a>00392 } <a name="l00393"></a>00393 <a name="l00394"></a><a class="code" href="classKIMProxy.html#85d6a063ae44a369861e44deb2f07dc7">00394</a> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstringlist.html">QStringList</a> <a class="code" href="classKIMProxy.html#85d6a063ae44a369861e44deb2f07dc7" title="Obtain a list of IM-contacts known to IM-applications.">KIMProxy::allContacts</a>() <a name="l00395"></a>00395 { <a name="l00396"></a>00396 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstringlist.html">QStringList</a> value = d->presence_map.keys(); <a name="l00397"></a>00397 <span class="keywordflow">return</span> value; <a name="l00398"></a>00398 } <a name="l00399"></a>00399 <a name="l00400"></a><a class="code" href="classKIMProxy.html#ffeb58bccb6aa0b8dd79e68068d8a497">00400</a> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstringlist.html">QStringList</a> <a class="code" href="classKIMProxy.html#ffeb58bccb6aa0b8dd79e68068d8a497" title="Obtain a list of IM-contacts that are currently reachable.">KIMProxy::reachableContacts</a>() <a name="l00401"></a>00401 { <a name="l00402"></a>00402 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstringlist.html">QStringList</a> value; <a name="l00403"></a>00403 <a name="l00404"></a>00404 <span class="keywordflow">if</span> ( <a class="code" href="classKIMProxy.html#3193fb0f41c75ceeaa33b4489601fe42" title="Get the proxy ready to connect.">initialize</a>() ) <a name="l00405"></a>00405 { <a name="l00406"></a>00406 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdictiterator.html">QDictIterator<KIMIface_stub></a> it( m_im_client_stubs ); <a name="l00407"></a>00407 <span class="keywordflow">for</span> ( ; it.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdictiterator.html#current">current</a>(); ++it ) <a name="l00408"></a>00408 { <a name="l00409"></a>00409 value += it.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdictiterator.html#current">current</a>()->reachableContacts( ); <a name="l00410"></a>00410 } <a name="l00411"></a>00411 } <a name="l00412"></a>00412 <span class="keywordflow">return</span> value; <a name="l00413"></a>00413 } <a name="l00414"></a>00414 <a name="l00415"></a><a class="code" href="classKIMProxy.html#154656cc1952d2e8a476d1b15eb392bf">00415</a> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstringlist.html">QStringList</a> <a class="code" href="classKIMProxy.html#154656cc1952d2e8a476d1b15eb392bf" title="Obtain a list of IM-contacts that are currently online.">KIMProxy::onlineContacts</a>() <a name="l00416"></a>00416 { <a name="l00417"></a>00417 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstringlist.html">QStringList</a> value; <a name="l00418"></a>00418 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qmap.html#iterator">PresenceStringMap::iterator</a> it = d->presence_map.begin(); <a name="l00419"></a>00419 <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qmap.html#iterator">PresenceStringMap::iterator</a> end= d->presence_map.end(); <a name="l00420"></a>00420 <span class="keywordflow">for</span> ( ; it != end; ++it ) <a name="l00421"></a>00421 <span class="keywordflow">if</span> ( it.data().best().presence > 2 <span class="comment">/*Better than Connecting, ie Away or Online*/</span> ) <a name="l00422"></a>00422 value.append( it.key() ); <a name="l00423"></a>00423 <a name="l00424"></a>00424 <span class="keywordflow">return</span> value; <a name="l00425"></a>00425 } <a name="l00426"></a>00426 <a name="l00427"></a><a class="code" href="classKIMProxy.html#1d02f9f85a7f5af4162f2dec424f1b90">00427</a> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstringlist.html">QStringList</a> <a class="code" href="classKIMProxy.html#1d02f9f85a7f5af4162f2dec424f1b90" title="Obtain a list of IM-contacts who may receive file transfers.">KIMProxy::fileTransferContacts</a>() <a name="l00428"></a>00428 { <a name="l00429"></a>00429 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstringlist.html">QStringList</a> value; <a name="l00430"></a>00430 <a name="l00431"></a>00431 <span class="keywordflow">if</span> ( <a class="code" href="classKIMProxy.html#3193fb0f41c75ceeaa33b4489601fe42" title="Get the proxy ready to connect.">initialize</a>() ) <a name="l00432"></a>00432 { <a name="l00433"></a>00433 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdictiterator.html">QDictIterator<KIMIface_stub></a> it( m_im_client_stubs ); <a name="l00434"></a>00434 <span class="keywordflow">for</span> ( ; it.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdictiterator.html#current">current</a>(); ++it ) <a name="l00435"></a>00435 { <a name="l00436"></a>00436 value += it.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdictiterator.html#current">current</a>()->fileTransferContacts( ); <a name="l00437"></a>00437 } <a name="l00438"></a>00438 } <a name="l00439"></a>00439 <span class="keywordflow">return</span> value; <a name="l00440"></a>00440 } <a name="l00441"></a>00441 <a name="l00442"></a><a class="code" href="classKIMProxy.html#4e31705108604c7314635768e80828bb">00442</a> <span class="keywordtype">bool</span> <a class="code" href="classKIMProxy.html#4e31705108604c7314635768e80828bb" title="Confirm if a given contact is known to the proxy.">KIMProxy::isPresent</a>( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a>& uid ) <a name="l00443"></a>00443 { <a name="l00444"></a>00444 <span class="keywordflow">return</span> ( !d->presence_map[ uid ].isEmpty() ); <a name="l00445"></a>00445 } <a name="l00446"></a>00446 <a name="l00447"></a><a class="code" href="classKIMProxy.html#5fee1c79aeff7f94a38cc0456a3a9fab">00447</a> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> <a class="code" href="classKIMProxy.html#5fee1c79aeff7f94a38cc0456a3a9fab" title="Obtain the proxy&#39;s idea of the contact&#39;s display name.">KIMProxy::displayName</a>( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a>& uid ) <a name="l00448"></a>00448 { <a name="l00449"></a>00449 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qobject.html#name">name</a>; <a name="l00450"></a>00450 <span class="keywordflow">if</span> ( <a class="code" href="classKIMProxy.html#3193fb0f41c75ceeaa33b4489601fe42" title="Get the proxy ready to connect.">initialize</a>() ) <a name="l00451"></a>00451 { <a name="l00452"></a>00452 <span class="keywordflow">if</span> ( KIMIface_stub* s = <a class="code" href="classKIMProxy.html#5d6d1b8e5f553f16379adc6fb25880de" title="Get the app stub best able to reach this uid.">stubForUid</a>( uid ) ) <a name="l00453"></a>00453 name = s->displayName( uid ); <a name="l00454"></a>00454 } <a name="l00455"></a>00455 <span class="comment">//kdDebug( 790 ) << k_funcinfo << name << endl;</span> <a name="l00456"></a>00456 <span class="keywordflow">return</span> name; <a name="l00457"></a>00457 } <a name="l00458"></a>00458 <a name="l00459"></a><a class="code" href="classKIMProxy.html#ac9d6ec424eb7a21305b114ac877e891">00459</a> <span class="keywordtype">bool</span> <a class="code" href="classKIMProxy.html#ac9d6ec424eb7a21305b114ac877e891" title="Indicate if a given contact can receive files.">KIMProxy::canReceiveFiles</a>( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> & uid ) <a name="l00460"></a>00460 { <a name="l00461"></a>00461 <span class="keywordflow">if</span> ( <a class="code" href="classKIMProxy.html#3193fb0f41c75ceeaa33b4489601fe42" title="Get the proxy ready to connect.">initialize</a>() ) <a name="l00462"></a>00462 { <a name="l00463"></a>00463 <span class="keywordflow">if</span> ( KIMIface_stub* s = <a class="code" href="classKIMProxy.html#5d6d1b8e5f553f16379adc6fb25880de" title="Get the app stub best able to reach this uid.">stubForUid</a>( uid ) ) <a name="l00464"></a>00464 <span class="keywordflow">return</span> s->canReceiveFiles( uid ); <a name="l00465"></a>00465 } <a name="l00466"></a>00466 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00467"></a>00467 } <a name="l00468"></a>00468 <a name="l00469"></a><a class="code" href="classKIMProxy.html#267dc5507df926ed18c7b4ed373121be">00469</a> <span class="keywordtype">bool</span> <a class="code" href="classKIMProxy.html#267dc5507df926ed18c7b4ed373121be" title="Indicate if a given contact will be able to respond.">KIMProxy::canRespond</a>( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> & uid ) <a name="l00470"></a>00470 { <a name="l00471"></a>00471 <span class="keywordflow">if</span> ( <a class="code" href="classKIMProxy.html#3193fb0f41c75ceeaa33b4489601fe42" title="Get the proxy ready to connect.">initialize</a>() ) <a name="l00472"></a>00472 { <a name="l00473"></a>00473 <span class="keywordflow">if</span> ( KIMIface_stub* s = <a class="code" href="classKIMProxy.html#5d6d1b8e5f553f16379adc6fb25880de" title="Get the app stub best able to reach this uid.">stubForUid</a>( uid ) ) <a name="l00474"></a>00474 <span class="keywordflow">return</span> s->canRespond( uid ); <a name="l00475"></a>00475 } <a name="l00476"></a>00476 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00477"></a>00477 } <a name="l00478"></a>00478 <a name="l00479"></a><a class="code" href="classKIMProxy.html#0d1f1e663d5bf30d688b8e0a0d8982cc">00479</a> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> <a class="code" href="classKIMProxy.html#0d1f1e663d5bf30d688b8e0a0d8982cc" title="Obtain the given contact&#39;s current context (home, work, or any).">KIMProxy::context</a>( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> & uid ) <a name="l00480"></a>00480 { <a name="l00481"></a>00481 <span class="keywordflow">if</span> ( <a class="code" href="classKIMProxy.html#3193fb0f41c75ceeaa33b4489601fe42" title="Get the proxy ready to connect.">initialize</a>() ) <a name="l00482"></a>00482 { <a name="l00483"></a>00483 <span class="keywordflow">if</span> ( KIMIface_stub* s = <a class="code" href="classKIMProxy.html#5d6d1b8e5f553f16379adc6fb25880de" title="Get the app stub best able to reach this uid.">stubForUid</a>( uid ) ) <a name="l00484"></a>00484 <span class="keywordflow">return</span> s->context( uid ); <a name="l00485"></a>00485 } <a name="l00486"></a>00486 <span class="keywordflow">return</span> QString::null; <a name="l00487"></a>00487 } <a name="l00488"></a>00488 <a name="l00489"></a><a class="code" href="classKIMProxy.html#8fc8d0e966fb79156fc6d6cf1bf6b59a">00489</a> <span class="keywordtype">void</span> <a class="code" href="classKIMProxy.html#8fc8d0e966fb79156fc6d6cf1bf6b59a" title="Start a chat session with the specified contact.">KIMProxy::chatWithContact</a>( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a>& uid ) <a name="l00490"></a>00490 { <a name="l00491"></a>00491 <span class="keywordflow">if</span> ( <a class="code" href="classKIMProxy.html#3193fb0f41c75ceeaa33b4489601fe42" title="Get the proxy ready to connect.">initialize</a>() ) <a name="l00492"></a>00492 { <a name="l00493"></a>00493 <span class="keywordflow">if</span> ( KIMIface_stub* s = <a class="code" href="classKIMProxy.html#5d6d1b8e5f553f16379adc6fb25880de" title="Get the app stub best able to reach this uid.">stubForUid</a>( uid ) ) <a name="l00494"></a>00494 { <a name="l00495"></a>00495 kapp->updateRemoteUserTimestamp( s->app() ); <a name="l00496"></a>00496 s->chatWithContact( uid ); <a name="l00497"></a>00497 } <a name="l00498"></a>00498 } <a name="l00499"></a>00499 <span class="keywordflow">return</span>; <a name="l00500"></a>00500 } <a name="l00501"></a>00501 <a name="l00502"></a><a class="code" href="classKIMProxy.html#51d917c2cf1f619a1be25cc1cf08df74">00502</a> <span class="keywordtype">void</span> <a class="code" href="classKIMProxy.html#51d917c2cf1f619a1be25cc1cf08df74" title="Send a single message to the specified contact.">KIMProxy::messageContact</a>( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a>& uid, <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a>& message ) <a name="l00503"></a>00503 { <a name="l00504"></a>00504 <span class="keywordflow">if</span> ( <a class="code" href="classKIMProxy.html#3193fb0f41c75ceeaa33b4489601fe42" title="Get the proxy ready to connect.">initialize</a>() ) <a name="l00505"></a>00505 { <a name="l00506"></a>00506 <span class="keywordflow">if</span> ( KIMIface_stub* s = <a class="code" href="classKIMProxy.html#5d6d1b8e5f553f16379adc6fb25880de" title="Get the app stub best able to reach this uid.">stubForUid</a>( uid ) ) <a name="l00507"></a>00507 { <a name="l00508"></a>00508 kapp->updateRemoteUserTimestamp( s->app() ); <a name="l00509"></a>00509 s->messageContact( uid, message ); <a name="l00510"></a>00510 } <a name="l00511"></a>00511 } <a name="l00512"></a>00512 <span class="keywordflow">return</span>; <a name="l00513"></a>00513 } <a name="l00514"></a>00514 <a name="l00515"></a><a class="code" href="classKIMProxy.html#681583dd4d014924d0e3e7e303170ba4">00515</a> <span class="keywordtype">void</span> <a class="code" href="classKIMProxy.html#681583dd4d014924d0e3e7e303170ba4" title="Send a file to the contact.">KIMProxy::sendFile</a>(<span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> &uid, <span class="keyword">const</span> <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKURL.html">KURL</a> &sourceURL, <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> &altFileName, uint fileSize ) <a name="l00516"></a>00516 { <a name="l00517"></a>00517 <span class="keywordflow">if</span> ( <a class="code" href="classKIMProxy.html#3193fb0f41c75ceeaa33b4489601fe42" title="Get the proxy ready to connect.">initialize</a>() ) <a name="l00518"></a>00518 { <a name="l00519"></a>00519 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdictiterator.html">QDictIterator<KIMIface_stub></a> it( m_im_client_stubs ); <a name="l00520"></a>00520 <span class="keywordflow">for</span> ( ; it.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdictiterator.html#current">current</a>(); ++it ) <a name="l00521"></a>00521 { <a name="l00522"></a>00522 <span class="keywordflow">if</span> ( it.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdictiterator.html#current">current</a>()->canReceiveFiles( uid ) ) <a name="l00523"></a>00523 { <a name="l00524"></a>00524 kapp->updateRemoteUserTimestamp( it.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdictiterator.html#current">current</a>()->app() ); <a name="l00525"></a>00525 it.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdictiterator.html#current">current</a>()->sendFile( uid, sourceURL, altFileName, fileSize ); <a name="l00526"></a>00526 <span class="keywordflow">break</span>; <a name="l00527"></a>00527 } <a name="l00528"></a>00528 } <a name="l00529"></a>00529 } <a name="l00530"></a>00530 <span class="keywordflow">return</span>; <a name="l00531"></a>00531 } <a name="l00532"></a>00532 <a name="l00533"></a><a class="code" href="classKIMProxy.html#7d71362a9ba1b162672e2a6c80f319bf">00533</a> <span class="keywordtype">bool</span> <a class="code" href="classKIMProxy.html#7d71362a9ba1b162672e2a6c80f319bf" title="Add a new contact given its protocol specific identifier.">KIMProxy::addContact</a>( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> &contactId, <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> &protocol ) <a name="l00534"></a>00534 { <a name="l00535"></a>00535 <span class="keywordflow">if</span> ( <a class="code" href="classKIMProxy.html#3193fb0f41c75ceeaa33b4489601fe42" title="Get the proxy ready to connect.">initialize</a>() ) <a name="l00536"></a>00536 { <a name="l00537"></a>00537 <span class="keywordflow">if</span> ( KIMIface_stub* s = <a class="code" href="classKIMProxy.html#3f777da662e7d0e257e18c32922d93ce" title="Get the app stub for this protocol.">stubForProtocol</a>( protocol ) ) <a name="l00538"></a>00538 <span class="keywordflow">return</span> s->addContact( contactId, protocol ); <a name="l00539"></a>00539 } <a name="l00540"></a>00540 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00541"></a>00541 } <a name="l00542"></a>00542 <a name="l00543"></a><a class="code" href="classKIMProxy.html#0ee83ebea98f0af3db83c96c3d3ece53">00543</a> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> <a class="code" href="classKIMProxy.html#0ee83ebea98f0af3db83c96c3d3ece53" title="Obtain the KABC UID corresponding to the given IM address.">KIMProxy::locate</a>( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> & contactId, <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> & protocol ) <a name="l00544"></a>00544 { <a name="l00545"></a>00545 <span class="keywordflow">if</span> ( <a class="code" href="classKIMProxy.html#3193fb0f41c75ceeaa33b4489601fe42" title="Get the proxy ready to connect.">initialize</a>() ) <a name="l00546"></a>00546 { <a name="l00547"></a>00547 <span class="keywordflow">if</span> ( KIMIface_stub* s = <a class="code" href="classKIMProxy.html#3f777da662e7d0e257e18c32922d93ce" title="Get the app stub for this protocol.">stubForProtocol</a>( protocol ) ) <a name="l00548"></a>00548 <span class="keywordflow">return</span> s->locate( contactId, protocol ); <a name="l00549"></a>00549 } <a name="l00550"></a>00550 <span class="keywordflow">return</span> QString::null; <a name="l00551"></a>00551 } <a name="l00552"></a>00552 <a name="l00553"></a><a class="code" href="classKIMProxy.html#79de4cc33ee155d9989680372e9045f3">00553</a> <span class="keywordtype">bool</span> <a class="code" href="classKIMProxy.html#79de4cc33ee155d9989680372e9045f3" title="Checks if there are any compatible instant messaging applications available.">KIMProxy::imAppsAvailable</a>() <a name="l00554"></a>00554 { <a name="l00555"></a>00555 <span class="keywordflow">return</span> ( !m_im_client_stubs.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdict.html#isEmpty">isEmpty</a>() ); <a name="l00556"></a>00556 } <a name="l00557"></a>00557 <a name="l00558"></a><a class="code" href="classKIMProxy.html#6afbe30b196de30d57366a8fc9c01ee2">00558</a> <span class="keywordtype">bool</span> <a class="code" href="classKIMProxy.html#6afbe30b196de30d57366a8fc9c01ee2" title="Start the user&#39;s preferred IM application.">KIMProxy::startPreferredApp</a>() <a name="l00559"></a>00559 { <a name="l00560"></a>00560 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> preferences = <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a>(<span class="stringliteral">"[X-DCOP-ServiceName] = '%1'"</span>).arg( <a class="code" href="classKIMProxy.html#35e909ffad0720620e6c8f305366b7c7" title="Get the name of the user&#39;s IM application of choice.">preferredApp</a>() ); <a name="l00561"></a>00561 <span class="comment">// start/find an instance of DCOP/InstantMessenger</span> <a name="l00562"></a>00562 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> error; <a name="l00563"></a>00563 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qcstring.html">QCString</a> dcopService; <a name="l00564"></a>00564 <span class="comment">// Get a preferred IM client.</span> <a name="l00565"></a>00565 <span class="comment">// The app will notify itself to us using registeredToDCOP, so we don't need to record a stub for it here</span> <a name="l00566"></a>00566 <span class="comment">// FIXME: error in preferences, see debug output</span> <a name="l00567"></a>00567 preferences = QString::null; <a name="l00568"></a>00568 <span class="keywordtype">int</span> result = KDCOPServiceStarter::self()->findServiceFor( IM_SERVICE_TYPE, QString::null, preferences, &error, &dcopService ); <a name="l00569"></a>00569 <a name="l00570"></a>00570 <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/group__kdebug.html#gfbb9aa4a84d6c0563d46550454b9714b">kdDebug</a>( 790 ) << <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/group__kdebug.html#g634e2de2b699b31ea3a79f984e836d64">k_funcinfo</a> << <span class="stringliteral">"error was: "</span> << error << <span class="stringliteral">", dcopService: "</span> << dcopService << <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/group__kdebug.html#g313d520ed8f8f6b46eeef22cfb3b082a">endl</a>; <a name="l00571"></a>00571 <a name="l00572"></a>00572 <span class="keywordflow">return</span> ( result == 0 ); <a name="l00573"></a>00573 } <a name="l00574"></a>00574 <a name="l00575"></a>00575 <a name="l00576"></a><a class="code" href="classKIMProxy.html#9c0ea64187311ef936d41fd5c3381b2a">00576</a> <span class="keywordtype">void</span> <a class="code" href="classKIMProxy.html#9c0ea64187311ef936d41fd5c3381b2a" title="Bootstrap our presence data by polling all known apps.">KIMProxy::pollAll</a>( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> &uid ) <a name="l00577"></a>00577 { <a name="l00578"></a>00578 <span class="comment">/* // We only need to call this function if we don't have any data at all</span> <a name="l00579"></a>00579 <span class="comment"> // otherwise, the data will be kept fresh by received presence change</span> <a name="l00580"></a>00580 <span class="comment"> // DCOP signals</span> <a name="l00581"></a>00581 <span class="comment"> if ( !d->presence_map.contains( uid ) )</span> <a name="l00582"></a>00582 <span class="comment"> {</span> <a name="l00583"></a>00583 <span class="comment"> AppPresence *presence = new AppPresence();</span> <a name="l00584"></a>00584 <span class="comment"> // record current presence from known clients</span> <a name="l00585"></a>00585 <span class="comment"> QDictIterator<KIMIface_stub> it( m_im_client_stubs );</span> <a name="l00586"></a>00586 <span class="comment"> for ( ; it.current(); ++it )</span> <a name="l00587"></a>00587 <span class="comment"> {</span> <a name="l00588"></a>00588 <span class="comment"> presence->insert( it.currentKey().ascii(), it.current()->presenceStatus( uid ) ); // m_im_client_stubs has qstring keys...</span> <a name="l00589"></a>00589 <span class="comment"> }</span> <a name="l00590"></a>00590 <span class="comment"> d->presence_map.insert( uid, presence );</span> <a name="l00591"></a>00591 <span class="comment"> }*/</span> <a name="l00592"></a>00592 } <a name="l00593"></a>00593 <a name="l00594"></a><a class="code" href="classKIMProxy.html#9231fdbbfd7e4d850b20868a2b122e2c">00594</a> <span class="keywordtype">void</span> <a class="code" href="classKIMProxy.html#9231fdbbfd7e4d850b20868a2b122e2c" title="Bootstrap our presence data for a newly registered app.">KIMProxy::pollApp</a>( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qcstring.html">QCString</a> & appId ) <a name="l00595"></a>00595 { <a name="l00596"></a>00596 <span class="comment">//kdDebug( 790 ) << k_funcinfo << endl;</span> <a name="l00597"></a>00597 KIMIface_stub * appStub = m_im_client_stubs[ appId ]; <a name="l00598"></a>00598 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstringlist.html">QStringList</a> contacts = m_im_client_stubs[ appId ]->allContacts(); <a name="l00599"></a>00599 QStringList::iterator it = contacts.begin(); <a name="l00600"></a>00600 QStringList::iterator end = contacts.end(); <a name="l00601"></a>00601 <span class="keywordflow">for</span> ( ; it != end; ++it ) <a name="l00602"></a>00602 { <a name="l00603"></a>00603 ContactPresenceListCurrent current = d->presence_map[ *it ]; <a name="l00604"></a>00604 AppPresenceCurrent ap; <a name="l00605"></a>00605 ap.appId = appId; <a name="l00606"></a>00606 ap.presence = appStub->presenceStatus( *it ); <a name="l00607"></a>00607 current.append( ap ); <a name="l00608"></a>00608 <a name="l00609"></a>00609 d->presence_map.insert( *it, current ); <a name="l00610"></a>00610 <span class="keywordflow">if</span> ( current.update( ap ) ) <a name="l00611"></a>00611 emit <a class="code" href="classKIMProxy.html#ee11bdb993679d6974e7690c73aae442" title="Indicates that the specified IM-contact&#39;s presence changed.">sigContactPresenceChanged</a>( *it ); <a name="l00612"></a>00612 <span class="comment">//kdDebug( 790 ) << " uid: " << *it << " presence: " << ap.presence << endl;</span> <a name="l00613"></a>00613 } <a name="l00614"></a>00614 } <a name="l00615"></a>00615 <a name="l00616"></a><a class="code" href="classKIMProxy.html#5d6d1b8e5f553f16379adc6fb25880de">00616</a> KIMIface_stub * <a class="code" href="classKIMProxy.html#5d6d1b8e5f553f16379adc6fb25880de" title="Get the app stub best able to reach this uid.">KIMProxy::stubForUid</a>( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> &uid ) <a name="l00617"></a>00617 { <a name="l00618"></a>00618 <span class="comment">// get best appPresence</span> <a name="l00619"></a>00619 AppPresenceCurrent ap = d->presence_map[ uid ].best(); <a name="l00620"></a>00620 <span class="comment">// look up the presence string from that app</span> <a name="l00621"></a>00621 <span class="keywordflow">return</span> m_im_client_stubs.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdict.html#find">find</a>( ap.appId ); <a name="l00622"></a>00622 } <a name="l00623"></a>00623 <a name="l00624"></a><a class="code" href="classKIMProxy.html#3f777da662e7d0e257e18c32922d93ce">00624</a> KIMIface_stub * <a class="code" href="classKIMProxy.html#3f777da662e7d0e257e18c32922d93ce" title="Get the app stub for this protocol.">KIMProxy::stubForProtocol</a>( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> &protocol) <a name="l00625"></a>00625 { <a name="l00626"></a>00626 KIMIface_stub * app; <a name="l00627"></a>00627 <span class="comment">// see if the preferred client supports this protocol</span> <a name="l00628"></a>00628 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> preferred = <a class="code" href="classKIMProxy.html#35e909ffad0720620e6c8f305366b7c7" title="Get the name of the user&#39;s IM application of choice.">preferredApp</a>(); <a name="l00629"></a>00629 <span class="keywordflow">if</span> ( ( app = m_im_client_stubs.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdict.html#find">find</a>( preferred ) ) ) <a name="l00630"></a>00630 { <a name="l00631"></a>00631 <span class="keywordflow">if</span> ( app->protocols().grep( protocol ).count() > 0 ) <a name="l00632"></a>00632 <span class="keywordflow">return</span> app; <a name="l00633"></a>00633 } <a name="l00634"></a>00634 <span class="comment">// preferred doesn't do this protocol, try the first of the others that says it does</span> <a name="l00635"></a>00635 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdictiterator.html">QDictIterator<KIMIface_stub></a> it( m_im_client_stubs ); <a name="l00636"></a>00636 <span class="keywordflow">for</span> ( ; it.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdictiterator.html#current">current</a>(); ++it ) <a name="l00637"></a>00637 { <a name="l00638"></a>00638 <span class="keywordflow">if</span> ( it.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdictiterator.html#current">current</a>()->protocols().grep( protocol ).count() > 0 ) <a name="l00639"></a>00639 <span class="keywordflow">return</span> it.<a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qdictiterator.html#current">current</a>(); <a name="l00640"></a>00640 } <a name="l00641"></a>00641 <span class="keywordflow">return</span> 0L; <a name="l00642"></a>00642 } <a name="l00643"></a>00643 <a name="l00644"></a><a class="code" href="classKIMProxy.html#35e909ffad0720620e6c8f305366b7c7">00644</a> <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> <a class="code" href="classKIMProxy.html#35e909ffad0720620e6c8f305366b7c7" title="Get the name of the user&#39;s IM application of choice.">KIMProxy::preferredApp</a>() <a name="l00645"></a>00645 { <a name="l00646"></a>00646 <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKConfig.html">KConfig</a> *store = <span class="keyword">new</span> <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKSimpleConfig.html">KSimpleConfig</a>( IM_CLIENT_PREFERENCES_FILE ); <a name="l00647"></a>00647 store-><a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKConfigBase.html#1754e470553c9f9ac2556a9d63ce61c9">setGroup</a>( IM_CLIENT_PREFERENCES_SECTION ); <a name="l00648"></a>00648 <a class="codeRef" doxygen="qt.tag:/usr/lib/qt3/doc/html/" href="/usr/lib/qt3/doc/html/qstring.html">QString</a> <a class="code" href="classKIMProxy.html#35e909ffad0720620e6c8f305366b7c7" title="Get the name of the user&#39;s IM application of choice.">preferredApp</a> = store-><a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKConfigBase.html#955d1210aeb86d7ec5265557333ab338">readEntry</a>( IM_CLIENT_PREFERENCES_ENTRY ); <a name="l00649"></a>00649 <span class="comment">//kdDebug( 790 ) << k_funcinfo << "found preferred app: " << preferredApp << endl;</span> <a name="l00650"></a>00650 <span class="keywordflow">return</span> preferredApp; <a name="l00651"></a>00651 } <a name="l00652"></a>00652 <a name="l00653"></a>00653 <span class="preprocessor">#include "kimproxy.moc"</span> </pre></div></div> </div></div> </td> </tr> <tr> <td valign="top" id="leftmenu" width="25%"> <a name="navigation"></a> <div class="menu_box"><h2>interfaces</h2> <div class="nav_list"> <ul><li><a href="index.html">Main Page</a></li><li><a href="namespaces.html">Namespace List</a></li><li><a href="hierarchy.html">Class Hierarchy</a></li><li><a href="classes.html">Alphabetical List</a></li><li><a href="annotated.html">Class List</a></li><li><a href="files.html">File List</a></li><li><a href="namespacemembers.html">Namespace Members</a></li><li><a href="functions.html">Class Members</a></li></ul> <!-- <h2>Class Picker</h2> <div style="text-align: center;"> <form name="guideform"> <select name="guidelinks" style="width:100%;" onChange="window.location=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value"> <option value="annotated.html">-- Choose --</option> <option value="classExtTerminalInterface.html">extterminalinterface</option>, <option value="classKFileAudioPreview.html">kfileaudiopreview</option>, <option value="classKHE_1_1BytesEditInterface.html">khe::byteseditinterface</option>, <option value="classKHE_1_1CharColumnInterface.html">khe::charcolumninterface</option>, <option value="classKHE_1_1ClipboardInterface.html">khe::clipboardinterface</option>, <option value="classKHE_1_1ValueColumnInterface.html">khe::valuecolumninterface</option>, <option value="classKHE_1_1ZoomInterface.html">khe::zoominterface</option>, <option value="classKIMIface.html">kimiface</option>, <option value="classKIMProxy.html">kimproxy</option>, <option value="classKMediaPlayer_1_1Player.html">kmediaplayer::player</option>, <option value="classKMediaPlayer_1_1View.html">kmediaplayer::view</option>, <option value="classKRegExpEditorInterface.html">kregexpeditorinterface</option>, <option value="classKScriptClientInterface.html">kscriptclientinterface</option>, <option value="classKScriptInterface.html">kscriptinterface</option>, <option value="classKScriptManager.html">kscriptmanager</option>, <option value="classKSpeech.html">kspeech</option>, <option value="classKSpeechSink.html">kspeechsink</option>, <option value="classKTextEditor_1_1BlockSelectionDCOPInterface.html">ktexteditor::blockselectiondcopinterface</option>, <option value="classKTextEditor_1_1BlockSelectionInterface.html">ktexteditor::blockselectioninterface</option>, <option value="classKTextEditor_1_1ClipboardDCOPInterface.html">ktexteditor::clipboarddcopinterface</option>, <option value="classKTextEditor_1_1ClipboardInterface.html">ktexteditor::clipboardinterface</option>, <option value="classKTextEditor_1_1CodeCompletionInterface.html">ktexteditor::codecompletioninterface</option>, <option value="classKTextEditor_1_1CompletionEntry.html">ktexteditor::completionentry</option>, <option value="classKTextEditor_1_1ConfigInterface.html">ktexteditor::configinterface</option>, <option value="classKTextEditor_1_1ConfigInterfaceExtension.html">ktexteditor::configinterfaceextension</option>, <option value="classKTextEditor_1_1Cursor.html">ktexteditor::cursor</option>, <option value="classKTextEditor_1_1CursorInterface.html">ktexteditor::cursorinterface</option>, <option value="classKTextEditor_1_1Document.html">ktexteditor::document</option>, <option value="classKTextEditor_1_1DocumentInfoDCOPInterface.html">ktexteditor::documentinfodcopinterface</option>, <option value="classKTextEditor_1_1DocumentInfoInterface.html">ktexteditor::documentinfointerface</option>, <option value="classKTextEditor_1_1DynWordWrapInterface.html">ktexteditor::dynwordwrapinterface</option>, <option value="classKTextEditor_1_1EditDCOPInterface.html">ktexteditor::editdcopinterface</option>, <option value="classKTextEditor_1_1EditInterface.html">ktexteditor::editinterface</option>, <option value="classKTextEditor_1_1EditInterfaceExt.html">ktexteditor::editinterfaceext</option>, <option value="classKTextEditor_1_1Editor.html">ktexteditor::editor</option>, <option value="classKTextEditor_1_1EncodingDCOPInterface.html">ktexteditor::encodingdcopinterface</option>, <option value="classKTextEditor_1_1EncodingInterface.html">ktexteditor::encodinginterface</option>, <option value="classKTextEditor_1_1HighlightingInterface.html">ktexteditor::highlightinginterface</option>, <option value="classKTextEditor_1_1MarkInterface.html">ktexteditor::markinterface</option>, <option value="classKTextEditor_1_1MarkInterfaceExtension.html">ktexteditor::markinterfaceextension</option>, <option value="classKTextEditor_1_1Plugin.html">ktexteditor::plugin</option>, <option value="classKTextEditor_1_1PluginViewInterface.html">ktexteditor::pluginviewinterface</option>, <option value="classKTextEditor_1_1PopupMenuInterface.html">ktexteditor::popupmenuinterface</option>, <option value="classKTextEditor_1_1PrintDCOPInterface.html">ktexteditor::printdcopinterface</option>, <option value="classKTextEditor_1_1PrintInterface.html">ktexteditor::printinterface</option>, <option value="classKTextEditor_1_1SearchDCOPInterface.html">ktexteditor::searchdcopinterface</option>, <option value="classKTextEditor_1_1SearchInterface.html">ktexteditor::searchinterface</option>, <option value="classKTextEditor_1_1SelectionDCOPInterface.html">ktexteditor::selectiondcopinterface</option>, <option value="classKTextEditor_1_1SelectionExtDCOPInterface.html">ktexteditor::selectionextdcopinterface</option>, <option value="classKTextEditor_1_1SelectionInterface.html">ktexteditor::selectioninterface</option>, <option value="classKTextEditor_1_1SelectionInterfaceExt.html">ktexteditor::selectioninterfaceext</option>, <option value="classKTextEditor_1_1SessionConfigInterface.html">ktexteditor::sessionconfiginterface</option>, <option value="classKTextEditor_1_1TemplateInterface.html">ktexteditor::templateinterface</option>, <option value="classKTextEditor_1_1TextHintInterface.html">ktexteditor::texthintinterface</option>, <option value="classKTextEditor_1_1UndoDCOPInterface.html">ktexteditor::undodcopinterface</option>, <option value="classKTextEditor_1_1UndoInterface.html">ktexteditor::undointerface</option>, <option value="classKTextEditor_1_1VariableInterface.html">ktexteditor::variableinterface</option>, <option value="classKTextEditor_1_1View.html">ktexteditor::view</option>, <option value="classKTextEditor_1_1ViewCursorDCOPInterface.html">ktexteditor::viewcursordcopinterface</option>, <option value="classKTextEditor_1_1ViewCursorInterface.html">ktexteditor::viewcursorinterface</option>, <option value="classKTextEditor_1_1ViewStatusMsgDCOPInterface.html">ktexteditor::viewstatusmsgdcopinterface</option>, <option value="classKTextEditor_1_1ViewStatusMsgInterface.html">ktexteditor::viewstatusmsginterface</option>, <option value="classKTextEditor_1_1WordWrapInterface.html">ktexteditor::wordwrapinterface</option>, <option value="classScriptLoader.html">scriptloader</option>, <option value="classTerminalInterface.html">terminalinterface</option>, </select> </form> </div> --> </div></div> <div class="menu_box"><h2>API Dox</h2> <div class="nav_list"> <ul> <li><a href="../../arts/html/index.html">arts</a></li><li><a href="../../dcop/html/index.html">dcop</a></li><li><a href="../../dnssd/html/index.html">dnssd</a></li><li><a href="../../interfaces/html/index.html">interfaces</a></li><li> <a href="../../interfaces/kimproxy/interface/html/index.html">interface</a></li><li> <a href="../../interfaces/kimproxy/library/html/index.html">library</a></li><li> <a href="../../interfaces/kspeech/html/index.html">kspeech</a></li><li> <a href="../../interfaces/ktexteditor/html/index.html">ktexteditor</a></li><li><a href="../../kabc/html/index.html">kabc</a></li><li><a href="../../kate/html/index.html">kate</a></li><li><a href="../../kcmshell/html/index.html">kcmshell</a></li><li><a href="../../kdecore/html/index.html">kdecore</a></li><li><a href="../../kded/html/index.html">kded</a></li><li><a href="../../kdefx/html/index.html">kdefx</a></li><li><a href="../../kdeprint/html/index.html">kdeprint</a></li><li><a href="../../kdesu/html/index.html">kdesu</a></li><li><a href="../../kdeui/html/index.html">kdeui</a></li><li><a href="../../kdoctools/html/index.html">kdoctools</a></li><li><a href="../../khtml/html/index.html">khtml</a></li><li><a href="../../kimgio/html/index.html">kimgio</a></li><li><a href="../../kinit/html/index.html">kinit</a></li><li><a href="../../kio/html/index.html">kio</a></li><li> <a href="../../kio/bookmarks/html/index.html">bookmarks</a></li><li> <a href="../../kio/httpfilter/html/index.html">httpfilter</a></li><li> <a href="../../kio/kfile/html/index.html">kfile</a></li><li> <a href="../../kio/kio/html/index.html">kio</a></li><li> <a href="../../kio/kioexec/html/index.html">kioexec</a></li><li> <a href="../../kio/kpasswdserver/html/index.html">kpasswdserver</a></li><li> <a href="../../kio/kssl/html/index.html">kssl</a></li><li><a href="../../kioslave/html/index.html">kioslave</a></li><li> <a href="../../kioslave/http/html/index.html">http</a></li><li><a href="../../kjs/html/index.html">kjs</a></li><li><a href="../../kmdi/html/index.html">kmdi</a></li><li> <a href="../../kmdi/kmdi/html/index.html">kmdi</a></li><li><a href="../../knewstuff/html/index.html">knewstuff</a></li><li><a href="../../kparts/html/index.html">kparts</a></li><li><a href="../../kresources/html/index.html">kresources</a></li><li><a href="../../kspell2/html/index.html">kspell2</a></li><li><a href="../../kunittest/html/index.html">kunittest</a></li><li><a href="../../kutils/html/index.html">kutils</a></li><li><a href="../../kwallet/html/index.html">kwallet</a></li><li><a href="../../libkmid/html/index.html">libkmid</a></li><li><a href="../../libkscreensaver/html/index.html">libkscreensaver</a></li> </ul></div></div> </td> </tr> </table> <span class="doNotDisplay"> <a href="http://www.kde.org/" accesskey="8">KDE Home</a> | <a href="http://accessibility.kde.org/" accesskey="9">KDE Accessibility Home</a> | <a href="http://www.kde.org/media/accesskeys.php" accesskey="0">Description of Access Keys</a> </span> <div style="height: 8px"></div> <div id="footer"> <div id="footer_left"> Maintained by <a href="mailto:groot@kde.org">Adriaan de Groot</a> and <a href="mailto:winter@kde.org">Allen Winter</a>. <br/> KDE and K Desktop Environment are trademarks of <a href="http://www.kde.org/areas/kde-ev/" title="Homepage of the KDE non-profit Organization">KDE e.V.</a> | <a href="http://www.kde.org/contact/impressum.php">Legal</a> </div> <div id="footer_right"><img src="/media/images/footer_right.png" style="margin: 0px" alt="" /></div> </div> <!-- WARNING: DO NOT SEND MAIL TO THE FOLLOWING EMAIL ADDRESS! YOU WILL BE BLOCKED INSTANTLY AND PERMANENTLY! <a href="mailto:aaaatrap-425acc3b5374943f@kde.org">Block me</a> WARNING END --> </body> </html>