Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 98d6b53e11e983e268c3e19f14e091a0 > files > 3685

kdepim-devel-doc-3.5.9-9mdv2008.1.x86_64.rpm

<?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>kpilot/lib: kpilotdevicelink.cc Source File (kpilot/lib)</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" />



<style type="text/css">
<!--
hr { display: none; }
#content h2 { margin-left: 0px; }
table.mdTable { background-color: #f8f8f8; border: .2em solid #d7d7d7; }
td.mdRow { padding: 8px 20px; }
td.md { font-weight: bold; }
td.mdname1 { font-weight: bold; color: #602020; }
td.mdname { font-weight: bold; color: #602020;  }

-->
</style>

</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>
  <img id="nav_header_logo_right" alt="" align="right" src="../../../pimlogo.png" border="0" />

  <div id="nav_header_title" align="left">KDE PIM 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_left" style="text-align: left;">
/ <a href="../../../">API Reference</a>
 / <a href="../../html/index.html">kpilot</a> / <a href=".">lib</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;">
    <h2><a name="content"></a>kpilot/lib</h2>


<!-- Generated by Doxygen 1.5.5 -->
<h1>kpilotdevicelink.cc</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* KPilot</span>
<a name="l00002"></a>00002 <span class="comment"> **</span>
<a name="l00003"></a>00003 <span class="comment"> ** Copyright (C) 1998-2001 by Dan Pilone</span>
<a name="l00004"></a>00004 <span class="comment"> ** Copyright (C) 2003-2004 Reinhold Kainhofer &lt;reinhold@kainhofer.com&gt;</span>
<a name="l00005"></a>00005 <span class="comment"> ** Copyright (C) 2006-2007 Adriaan de Groot &lt;groot@kde.org&gt;</span>
<a name="l00006"></a>00006 <span class="comment"> ** Copyright (C) 2007 Jason 'vanRijn' Kasper &lt;vR@movingparts.net&gt;</span>
<a name="l00007"></a>00007 <span class="comment"> **</span>
<a name="l00008"></a>00008 <span class="comment"> */</span>
<a name="l00009"></a>00009 
<a name="l00010"></a>00010 <span class="comment">/*</span>
<a name="l00011"></a>00011 <span class="comment"> ** This program is free software; you can redistribute it and/or modify</span>
<a name="l00012"></a>00012 <span class="comment"> ** it under the terms of the GNU Lesser General Public License as published by</span>
<a name="l00013"></a>00013 <span class="comment"> ** the Free Software Foundation; either version 2.1 of the License, or</span>
<a name="l00014"></a>00014 <span class="comment"> ** (at your option) any later version.</span>
<a name="l00015"></a>00015 <span class="comment"> **</span>
<a name="l00016"></a>00016 <span class="comment"> ** This program is distributed in the hope that it will be useful,</span>
<a name="l00017"></a>00017 <span class="comment"> ** but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00018"></a>00018 <span class="comment"> ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00019"></a>00019 <span class="comment"> ** GNU Lesser General Public License for more details.</span>
<a name="l00020"></a>00020 <span class="comment"> **</span>
<a name="l00021"></a>00021 <span class="comment"> ** You should have received a copy of the GNU Lesser General Public License</span>
<a name="l00022"></a>00022 <span class="comment"> ** along with this program in a file called COPYING; if not, write to</span>
<a name="l00023"></a>00023 <span class="comment"> ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,</span>
<a name="l00024"></a>00024 <span class="comment"> ** MA 02110-1301, USA.</span>
<a name="l00025"></a>00025 <span class="comment"> */</span>
<a name="l00026"></a>00026 
<a name="l00027"></a>00027 <span class="comment">/*</span>
<a name="l00028"></a>00028 <span class="comment"> ** Bug reports and questions can be sent to kde-pim@kde.org</span>
<a name="l00029"></a>00029 <span class="comment"> */</span>
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 <span class="preprocessor">#include "options.h"</span>
<a name="l00032"></a>00032 
<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;sys/stat.h&gt;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;sys/types.h&gt;</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include &lt;unistd.h&gt;</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;fcntl.h&gt;</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include &lt;errno.h&gt;</span>
<a name="l00039"></a>00039 
<a name="l00040"></a>00040 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00041"></a>00041 
<a name="l00042"></a>00042 <span class="preprocessor">#include &lt;pi-source.h&gt;</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include &lt;pi-socket.h&gt;</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include &lt;pi-dlp.h&gt;</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include &lt;pi-file.h&gt;</span>
<a name="l00046"></a>00046 <span class="preprocessor">#include &lt;pi-buffer.h&gt;</span>
<a name="l00047"></a>00047 
<a name="l00048"></a>00048 <span class="preprocessor">#include &lt;qdir.h&gt;</span>
<a name="l00049"></a>00049 <span class="preprocessor">#include &lt;qtimer.h&gt;</span>
<a name="l00050"></a>00050 <span class="preprocessor">#include &lt;qdatetime.h&gt;</span>
<a name="l00051"></a>00051 <span class="preprocessor">#include &lt;qthread.h&gt;</span>
<a name="l00052"></a>00052 <span class="preprocessor">#include &lt;qsocketnotifier.h&gt;</span>
<a name="l00053"></a>00053 
<a name="l00054"></a>00054 <span class="preprocessor">#include &lt;kconfig.h&gt;</span>
<a name="l00055"></a>00055 <span class="preprocessor">#include &lt;kmessagebox.h&gt;</span>
<a name="l00056"></a>00056 <span class="preprocessor">#include &lt;kstandarddirs.h&gt;</span>
<a name="l00057"></a>00057 <span class="preprocessor">#include &lt;kurl.h&gt;</span>
<a name="l00058"></a>00058 <span class="preprocessor">#include &lt;kio/netaccess.h&gt;</span>
<a name="l00059"></a>00059 
<a name="l00060"></a>00060 <span class="preprocessor">#include "pilotUser.h"</span>
<a name="l00061"></a>00061 <span class="preprocessor">#include "pilotSysInfo.h"</span>
<a name="l00062"></a>00062 <span class="preprocessor">#include "pilotCard.h"</span>
<a name="l00063"></a>00063 <span class="preprocessor">#include "<a class="code" href="pilotSerialDatabase_8h.html" title="Database class for a database on the pilot connected via the serial port (ie: hot-sync...">pilotSerialDatabase.h</a>"</span>
<a name="l00064"></a>00064 <span class="preprocessor">#include "<a class="code" href="pilotLocalDatabase_8h.html" title="Defines the PilotLocalDatabase class, for databases stored on disk (as opposed to...">pilotLocalDatabase.h</a>"</span>
<a name="l00065"></a>00065 
<a name="l00066"></a>00066 <span class="preprocessor">#include "<a class="code" href="kpilotlink_8h.html" title="Encapsulates all the communication with the handheld.">kpilotlink.h</a>"</span>
<a name="l00067"></a>00067 <span class="preprocessor">#include "kpilotdevicelinkPrivate.moc"</span>
<a name="l00068"></a>00068 <span class="preprocessor">#include "kpilotdevicelink.moc"</span>
<a name="l00069"></a>00069 
<a name="l00070"></a>00070 
<a name="l00071"></a>00071 DeviceMap *DeviceMap::mThis = 0L;
<a name="l00072"></a>00072 
<a name="l00073"></a>00073 
<a name="l00074"></a>00074 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> startOpenTimer(<a class="code" href="classDeviceCommThread.html" title="Class that handles all device communications.">DeviceCommThread</a> *dev, QTimer *&amp;t)
<a name="l00075"></a>00075 {
<a name="l00076"></a>00076     <span class="keywordflow">if</span> ( !t)
<a name="l00077"></a>00077     {
<a name="l00078"></a>00078         t = <span class="keyword">new</span> QTimer(dev);
<a name="l00079"></a>00079         QObject::connect(t, SIGNAL(timeout()), dev, SLOT(openDevice()));
<a name="l00080"></a>00080     }
<a name="l00081"></a>00081     <span class="comment">// just a single-shot timer.  we'll know when to start it again...</span>
<a name="l00082"></a>00082     t-&gt;start(1000, <span class="keyword">true</span>);
<a name="l00083"></a>00083 }
<a name="l00084"></a>00084 
<a name="l00085"></a>00085 DeviceCommThread::DeviceCommThread(<a class="code" href="classKPilotDeviceLink.html" title="Definition of the device link class for physical handheld devices, which communicate...">KPilotDeviceLink</a> *d) :
<a name="l00086"></a>00086     QThread(),
<a name="l00087"></a>00087     fDone(true),
<a name="l00088"></a>00088     fHandle(d),
<a name="l00089"></a>00089     fOpenTimer(0L),
<a name="l00090"></a>00090     fSocketNotifier(0L),
<a name="l00091"></a>00091     fSocketNotifierActive(false),
<a name="l00092"></a>00092     fWorkaroundUSBTimer(0L),
<a name="l00093"></a>00093     fPilotSocket(-1),
<a name="l00094"></a>00094     fTempSocket(-1),
<a name="l00095"></a>00095     fAcceptedCount(0)
<a name="l00096"></a>00096 {
<a name="l00097"></a>00097     FUNCTIONSETUP;
<a name="l00098"></a>00098 }
<a name="l00099"></a>00099 
<a name="l00100"></a>00100 
<a name="l00101"></a>00101 DeviceCommThread::~DeviceCommThread()
<a name="l00102"></a>00102 {
<a name="l00103"></a>00103     FUNCTIONSETUPL(2);
<a name="l00104"></a>00104     close();
<a name="l00105"></a>00105     KPILOT_DELETE(fWorkaroundUSBTimer);
<a name="l00106"></a>00106 }
<a name="l00107"></a>00107 
<a name="l00108"></a>00108 <span class="keywordtype">void</span> DeviceCommThread::close()
<a name="l00109"></a>00109 {
<a name="l00110"></a>00110     FUNCTIONSETUPL(2);
<a name="l00111"></a>00111 
<a name="l00112"></a>00112     KPILOT_DELETE(fWorkaroundUSBTimer);
<a name="l00113"></a>00113     KPILOT_DELETE(fOpenTimer);
<a name="l00114"></a>00114     KPILOT_DELETE(fSocketNotifier);
<a name="l00115"></a>00115     fSocketNotifierActive=<span class="keyword">false</span>;
<a name="l00116"></a>00116 
<a name="l00117"></a>00117     <span class="keywordflow">if</span> (fTempSocket != -1)
<a name="l00118"></a>00118     {
<a name="l00119"></a>00119         DEBUGKPILOT &lt;&lt; fname
<a name="l00120"></a>00120         &lt;&lt; <span class="stringliteral">": device comm thread closing socket: ["</span>
<a name="l00121"></a>00121         &lt;&lt; fTempSocket &lt;&lt; <span class="stringliteral">"]"</span> &lt;&lt; endl;
<a name="l00122"></a>00122 
<a name="l00123"></a>00123         pi_close(fTempSocket);
<a name="l00124"></a>00124     }
<a name="l00125"></a>00125 
<a name="l00126"></a>00126     <span class="keywordflow">if</span> (fPilotSocket != -1)
<a name="l00127"></a>00127     {
<a name="l00128"></a>00128         DEBUGKPILOT &lt;&lt; fname
<a name="l00129"></a>00129         &lt;&lt; <span class="stringliteral">": device comm thread closing socket: ["</span>
<a name="l00130"></a>00130         &lt;&lt; fPilotSocket &lt;&lt; <span class="stringliteral">"]"</span> &lt;&lt; endl;
<a name="l00131"></a>00131 
<a name="l00132"></a>00132         pi_close(fPilotSocket);
<a name="l00133"></a>00133     }
<a name="l00134"></a>00134 
<a name="l00135"></a>00135     fTempSocket = (-1);
<a name="l00136"></a>00136     fPilotSocket = (-1);
<a name="l00137"></a>00137 
<a name="l00138"></a>00138     DeviceMap::self()-&gt;unbindDevice(link()-&gt;fRealPilotPath);
<a name="l00139"></a>00139 }
<a name="l00140"></a>00140 
<a name="l00141"></a>00141 <span class="keywordtype">void</span> DeviceCommThread::reset()
<a name="l00142"></a>00142 {
<a name="l00143"></a>00143     FUNCTIONSETUP;
<a name="l00144"></a>00144 
<a name="l00145"></a>00145     <span class="keywordflow">if</span> (link()-&gt;fMessages-&gt;shouldPrint(Messages::OpenFailMessage))
<a name="l00146"></a>00146     {
<a name="l00147"></a>00147         QApplication::postEvent(link(), <span class="keyword">new</span> DeviceCommEvent(EventLogMessage,
<a name="l00148"></a>00148                 i18n(<span class="stringliteral">"Could not open device: %1 (will retry)"</span>)
<a name="l00149"></a>00149                 .arg(link()-&gt;pilotPath() )));
<a name="l00150"></a>00150     }
<a name="l00151"></a>00151 
<a name="l00152"></a>00152     link()-&gt;<a class="code" href="classKPilotDeviceLink.html#46a721fb2058b123642536262b038a8d">fMessages</a>-&gt;reset();
<a name="l00153"></a>00153     close();
<a name="l00154"></a>00154 
<a name="l00155"></a>00155     <span class="comment">// Timer already deleted by close() call.</span>
<a name="l00156"></a>00156     startOpenTimer(<span class="keyword">this</span>,fOpenTimer);
<a name="l00157"></a>00157 
<a name="l00158"></a>00158     link()-&gt;<a class="code" href="classKPilotDeviceLink.html#ac681b833d3e3fa7f677ad331d0502f1">fLinkStatus</a> = WaitingForDevice;
<a name="l00159"></a>00159 }
<a name="l00160"></a>00160 
<a name="l00170"></a><a class="code" href="classDeviceCommThread.html#6ae9e24a146c1f51c691f685b3ecb108">00170</a> <span class="keywordtype">void</span> <a class="code" href="classDeviceCommThread.html#6ae9e24a146c1f51c691f685b3ecb108" title="Attempt to open the device.">DeviceCommThread::openDevice</a>()
<a name="l00171"></a>00171 {
<a name="l00172"></a>00172     FUNCTIONSETUPL(2);
<a name="l00173"></a>00173 
<a name="l00174"></a>00174     <span class="keywordtype">bool</span> deviceOpened = <span class="keyword">false</span>;
<a name="l00175"></a>00175 
<a name="l00176"></a>00176     <span class="comment">// This transition (from Waiting to Found) can only be</span>
<a name="l00177"></a>00177     <span class="comment">// taken once.</span>
<a name="l00178"></a>00178     <span class="comment">//</span>
<a name="l00179"></a>00179     <span class="keywordflow">if</span> (link()-&gt;fLinkStatus == WaitingForDevice)
<a name="l00180"></a>00180     {
<a name="l00181"></a>00181         link()-&gt;<a class="code" href="classKPilotDeviceLink.html#ac681b833d3e3fa7f677ad331d0502f1">fLinkStatus</a> = FoundDevice;
<a name="l00182"></a>00182     }
<a name="l00183"></a>00183 
<a name="l00184"></a>00184     <span class="keywordflow">if</span> (link()-&gt;fMessages-&gt;shouldPrint(Messages::OpenMessage))
<a name="l00185"></a>00185     {
<a name="l00186"></a>00186         QApplication::postEvent(link(), <span class="keyword">new</span> DeviceCommEvent(EventLogMessage,
<a name="l00187"></a>00187                 i18n(<span class="stringliteral">"Trying to open device %1..."</span>)
<a name="l00188"></a>00188                 .arg(link()-&gt;fPilotPath)));
<a name="l00189"></a>00189     }
<a name="l00190"></a>00190 
<a name="l00191"></a>00191     <span class="comment">// if we're not supposed to be done, try to open the main pilot</span>
<a name="l00192"></a>00192     <span class="comment">// path...</span>
<a name="l00193"></a>00193     <span class="keywordflow">if</span> (!fDone &amp;&amp; link()-&gt;fPilotPath.length() &gt; 0)
<a name="l00194"></a>00194     {
<a name="l00195"></a>00195         DEBUGKPILOT &lt;&lt; fname &lt;&lt; <span class="stringliteral">": Opening main pilot path: ["</span>
<a name="l00196"></a>00196             &lt;&lt; link()-&gt;<a class="code" href="classKPilotLink.html#49e621f9a9aaea2e96bae802fa3b9cea" title="Path of the device special file that will be used.">fPilotPath</a> &lt;&lt; <span class="stringliteral">"]."</span> &lt;&lt; endl;
<a name="l00197"></a>00197         deviceOpened = <a class="code" href="classDeviceCommThread.html#a1ae57caa1b8bc175275e5c6f9318539" title="Does the low-level opening of the device and handles the pilot-link library initialisation...">open</a>(link()-&gt;fPilotPath);
<a name="l00198"></a>00198     }
<a name="l00199"></a>00199 
<a name="l00200"></a>00200     <span class="comment">// only try the temp device if our earlier attempt didn't work and the temp</span>
<a name="l00201"></a>00201     <span class="comment">// device is different than the main device, and it's a non-empty</span>
<a name="l00202"></a>00202     <span class="comment">// string</span>
<a name="l00203"></a>00203     <span class="keywordtype">bool</span> tryTemp = !deviceOpened &amp;&amp; (link()-&gt;<a class="code" href="classKPilotDeviceLink.html#5db6950afb44f89f4373ade2ab08013c">fTempDevice</a>.length() &gt; 0) &amp;&amp; (link()-&gt;<a class="code" href="classKPilotLink.html#49e621f9a9aaea2e96bae802fa3b9cea" title="Path of the device special file that will be used.">fPilotPath</a> != link()-&gt;<a class="code" href="classKPilotDeviceLink.html#5db6950afb44f89f4373ade2ab08013c">fTempDevice</a>);
<a name="l00204"></a>00204 
<a name="l00205"></a>00205     <span class="comment">// if we're not supposed to be done, and we should try the temp</span>
<a name="l00206"></a>00206     <span class="comment">// device, try the temp device...</span>
<a name="l00207"></a>00207     <span class="keywordflow">if</span> (!fDone &amp;&amp; tryTemp)
<a name="l00208"></a>00208     {
<a name="l00209"></a>00209         DEBUGKPILOT &lt;&lt; fname &lt;&lt; <span class="stringliteral">": Couldn't open main pilot path. "</span>
<a name="l00210"></a>00210             &lt;&lt; <span class="stringliteral">"Now trying temp device: ["</span>
<a name="l00211"></a>00211             &lt;&lt; link()-&gt;<a class="code" href="classKPilotDeviceLink.html#5db6950afb44f89f4373ade2ab08013c">fTempDevice</a> &lt;&lt; <span class="stringliteral">"]."</span> &lt;&lt; endl;
<a name="l00212"></a>00212         deviceOpened = <a class="code" href="classDeviceCommThread.html#a1ae57caa1b8bc175275e5c6f9318539" title="Does the low-level opening of the device and handles the pilot-link library initialisation...">open</a>(link()-&gt;fTempDevice);
<a name="l00213"></a>00213     }
<a name="l00214"></a>00214 
<a name="l00215"></a>00215     <span class="comment">// if we couldn't connect, try to connect again...</span>
<a name="l00216"></a>00216     <span class="keywordflow">if</span> (!fDone &amp;&amp; !deviceOpened)
<a name="l00217"></a>00217     {
<a name="l00218"></a>00218         startOpenTimer(<span class="keyword">this</span>, fOpenTimer);
<a name="l00219"></a>00219     }
<a name="l00220"></a>00220 }
<a name="l00221"></a>00221 
<a name="l00222"></a><a class="code" href="classDeviceCommThread.html#a1ae57caa1b8bc175275e5c6f9318539">00222</a> <span class="keywordtype">bool</span> <a class="code" href="classDeviceCommThread.html#a1ae57caa1b8bc175275e5c6f9318539" title="Does the low-level opening of the device and handles the pilot-link library initialisation...">DeviceCommThread::open</a>(<span class="keyword">const</span> QString &amp;device)
<a name="l00223"></a>00223 {
<a name="l00224"></a>00224     FUNCTIONSETUPL(2);
<a name="l00225"></a>00225 
<a name="l00226"></a>00226     <span class="keywordtype">int</span> ret;
<a name="l00227"></a>00227     <span class="keywordtype">int</span> e = 0;
<a name="l00228"></a>00228     QString msg;
<a name="l00229"></a>00229 
<a name="l00230"></a>00230     <span class="keywordflow">if</span> (fTempSocket != -1)
<a name="l00231"></a>00231     {
<a name="l00232"></a>00232         pi_close(fTempSocket);
<a name="l00233"></a>00233     }
<a name="l00234"></a>00234     fTempSocket = (-1);
<a name="l00235"></a>00235 
<a name="l00236"></a>00236     link()-&gt;<a class="code" href="classKPilotDeviceLink.html#8fbbebbfa3cd2e0f405e20c425e1cf56" title="Path with resolved symlinks, to prevent double binding to the same device.">fRealPilotPath</a>
<a name="l00237"></a>00237             = KStandardDirs::realFilePath(device.isEmpty() ? link()-&gt;<a class="code" href="classKPilotLink.html#49e621f9a9aaea2e96bae802fa3b9cea" title="Path of the device special file that will be used.">fPilotPath</a> : device);
<a name="l00238"></a>00238 
<a name="l00239"></a>00239     <span class="keywordflow">if</span> ( !DeviceMap::self()-&gt;canBind(link()-&gt;fRealPilotPath) )
<a name="l00240"></a>00240     {
<a name="l00241"></a>00241         msg = i18n(<span class="stringliteral">"Already listening on that device"</span>);
<a name="l00242"></a>00242 
<a name="l00243"></a>00243         WARNINGKPILOT &lt;&lt; <span class="stringliteral">"Pilot Path: ["</span>
<a name="l00244"></a>00244             &lt;&lt; link()-&gt;<a class="code" href="classKPilotDeviceLink.html#8fbbebbfa3cd2e0f405e20c425e1cf56" title="Path with resolved symlinks, to prevent double binding to the same device.">fRealPilotPath</a> &lt;&lt; <span class="stringliteral">"] already connected."</span> &lt;&lt; endl;
<a name="l00245"></a>00245         WARNINGKPILOT &lt;&lt; msg &lt;&lt; endl;
<a name="l00246"></a>00246 
<a name="l00247"></a>00247         link()-&gt;<a class="code" href="classKPilotDeviceLink.html#ac681b833d3e3fa7f677ad331d0502f1">fLinkStatus</a> = PilotLinkError;
<a name="l00248"></a>00248 
<a name="l00249"></a>00249         QApplication::postEvent(link(), <span class="keyword">new</span> DeviceCommEvent(EventLogError, msg));
<a name="l00250"></a>00250 
<a name="l00251"></a>00251         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00252"></a>00252     }
<a name="l00253"></a>00253 
<a name="l00254"></a>00254     DEBUGKPILOT &lt;&lt; fname &lt;&lt; <span class="stringliteral">": Trying to create socket."</span> &lt;&lt; endl;
<a name="l00255"></a>00255 
<a name="l00256"></a>00256     fTempSocket = pi_socket(PI_AF_PILOT, PI_SOCK_STREAM, PI_PF_DLP);
<a name="l00257"></a>00257 
<a name="l00258"></a>00258     <span class="keywordflow">if</span> (fTempSocket &lt; 0)
<a name="l00259"></a>00259     {
<a name="l00260"></a>00260         e = errno;
<a name="l00261"></a>00261         msg = i18n(<span class="stringliteral">"Cannot create socket for communicating "</span>
<a name="l00262"></a>00262                 <span class="stringliteral">"with the Pilot (%1)"</span>).arg(errorMessage(e));
<a name="l00263"></a>00263         DEBUGKPILOT &lt;&lt; msg &lt;&lt; endl;
<a name="l00264"></a>00264         DEBUGKPILOT &lt;&lt; <span class="stringliteral">"("</span> &lt;&lt; strerror(e) &lt;&lt; <span class="stringliteral">")"</span> &lt;&lt; endl;
<a name="l00265"></a>00265 
<a name="l00266"></a>00266         link()-&gt;<a class="code" href="classKPilotDeviceLink.html#ac681b833d3e3fa7f677ad331d0502f1">fLinkStatus</a> = PilotLinkError;
<a name="l00267"></a>00267 
<a name="l00268"></a>00268         QApplication::postEvent(link(), <span class="keyword">new</span> DeviceCommEvent(EventLogError, msg));
<a name="l00269"></a>00269 
<a name="l00270"></a>00270         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00271"></a>00271     }
<a name="l00272"></a>00272 
<a name="l00273"></a>00273     DEBUGKPILOT &lt;&lt; fname &lt;&lt; <span class="stringliteral">": Got socket: ["</span> &lt;&lt; fTempSocket &lt;&lt; <span class="stringliteral">"]"</span> &lt;&lt; endl;
<a name="l00274"></a>00274 
<a name="l00275"></a>00275     link()-&gt;<a class="code" href="classKPilotDeviceLink.html#ac681b833d3e3fa7f677ad331d0502f1">fLinkStatus</a> = CreatedSocket;
<a name="l00276"></a>00276 
<a name="l00277"></a>00277     DEBUGKPILOT &lt;&lt; fname &lt;&lt; <span class="stringliteral">": Binding to path: ["</span>
<a name="l00278"></a>00278         &lt;&lt; link()-&gt;<a class="code" href="classKPilotDeviceLink.html#8fbbebbfa3cd2e0f405e20c425e1cf56" title="Path with resolved symlinks, to prevent double binding to the same device.">fRealPilotPath</a> &lt;&lt; <span class="stringliteral">"]"</span> &lt;&lt; endl;
<a name="l00279"></a>00279 
<a name="l00280"></a>00280     ret = pi_bind(fTempSocket, QFile::encodeName(link()-&gt;fRealPilotPath));
<a name="l00281"></a>00281 
<a name="l00282"></a>00282     <span class="keywordflow">if</span> (ret &lt; 0)
<a name="l00283"></a>00283     {
<a name="l00284"></a>00284         DEBUGKPILOT &lt;&lt; fname
<a name="l00285"></a>00285             &lt;&lt; <span class="stringliteral">": pi_bind error: ["</span>
<a name="l00286"></a>00286             &lt;&lt; strerror(errno) &lt;&lt; <span class="stringliteral">"]"</span> &lt;&lt; endl;
<a name="l00287"></a>00287 
<a name="l00288"></a>00288         e = errno;
<a name="l00289"></a>00289         msg = i18n(<span class="stringliteral">"Cannot open Pilot port \"%1\". "</span>).arg(link()-&gt;fRealPilotPath);
<a name="l00290"></a>00290 
<a name="l00291"></a>00291         DEBUGKPILOT &lt;&lt; msg &lt;&lt; endl;
<a name="l00292"></a>00292         DEBUGKPILOT &lt;&lt; <span class="stringliteral">"("</span> &lt;&lt; strerror(e) &lt;&lt; <span class="stringliteral">")"</span> &lt;&lt; endl;
<a name="l00293"></a>00293 
<a name="l00294"></a>00294         link()-&gt;<a class="code" href="classKPilotDeviceLink.html#ac681b833d3e3fa7f677ad331d0502f1">fLinkStatus</a> = PilotLinkError;
<a name="l00295"></a>00295 
<a name="l00296"></a>00296         <span class="keywordflow">if</span> (link()-&gt;fMessages-&gt;shouldPrint(Messages::OpenFailMessage))
<a name="l00297"></a>00297         {
<a name="l00298"></a>00298             QApplication::postEvent(link(), <span class="keyword">new</span> DeviceCommEvent(EventLogError, msg));
<a name="l00299"></a>00299         }
<a name="l00300"></a>00300 
<a name="l00301"></a>00301         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00302"></a>00302     }
<a name="l00303"></a>00303 
<a name="l00304"></a>00304     link()-&gt;<a class="code" href="classKPilotDeviceLink.html#ac681b833d3e3fa7f677ad331d0502f1">fLinkStatus</a> = DeviceOpen;
<a name="l00305"></a>00305     DeviceMap::self()-&gt;bindDevice(link()-&gt;fRealPilotPath);
<a name="l00306"></a>00306 
<a name="l00307"></a>00307     fSocketNotifier = <span class="keyword">new</span> QSocketNotifier(fTempSocket,
<a name="l00308"></a>00308             QSocketNotifier::Read, <span class="keyword">this</span>);
<a name="l00309"></a>00309     QObject::connect(fSocketNotifier, SIGNAL(activated(<span class="keywordtype">int</span>)),
<a name="l00310"></a>00310             <span class="keyword">this</span>, SLOT(<a class="code" href="classDeviceCommThread.html#edd1966c42f5a936ac610ad742491f63" title="Called when the device is opened *and* activity occurs on the device.">acceptDevice</a>()));
<a name="l00311"></a>00311     fSocketNotifierActive=<span class="keyword">true</span>;
<a name="l00312"></a>00312 
<a name="l00319"></a>00319     <span class="keywordtype">int</span> timeout=20000;
<a name="l00320"></a>00320     <span class="keywordflow">if</span> (link()-&gt;fWorkaroundUSB)
<a name="l00321"></a>00321     {
<a name="l00322"></a>00322         timeout=5000;
<a name="l00323"></a>00323     }
<a name="l00324"></a>00324 
<a name="l00325"></a>00325     fWorkaroundUSBTimer = <span class="keyword">new</span> QTimer(<span class="keyword">this</span>);
<a name="l00326"></a>00326     connect(fWorkaroundUSBTimer, SIGNAL(timeout()), <span class="keyword">this</span>, SLOT(<a class="code" href="classDeviceCommThread.html#1c11ffbf720e699496f7284684932c5b" title="This slot fires whenever we&amp;#39;ve been trying to establish a hotsync with the device...">workaroundUSB</a>()));
<a name="l00327"></a>00327     fWorkaroundUSBTimer-&gt;start(timeout, <span class="keyword">true</span>);
<a name="l00328"></a>00328 
<a name="l00329"></a>00329     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00330"></a>00330 }
<a name="l00331"></a>00331 
<a name="l00339"></a><a class="code" href="classDeviceCommThread.html#edd1966c42f5a936ac610ad742491f63">00339</a> <span class="keywordtype">void</span> <a class="code" href="classDeviceCommThread.html#edd1966c42f5a936ac610ad742491f63" title="Called when the device is opened *and* activity occurs on the device.">DeviceCommThread::acceptDevice</a>()
<a name="l00340"></a>00340 {
<a name="l00341"></a>00341     FUNCTIONSETUP;
<a name="l00342"></a>00342 
<a name="l00343"></a>00343     <span class="keywordtype">int</span> ret;
<a name="l00344"></a>00344 
<a name="l00350"></a>00350     <span class="keywordflow">if</span> (!fSocketNotifierActive)
<a name="l00351"></a>00351     {
<a name="l00352"></a>00352         <span class="keywordflow">if</span> (!fAcceptedCount)
<a name="l00353"></a>00353         {
<a name="l00354"></a>00354         kdWarning() &lt;&lt; k_funcinfo &lt;&lt; <span class="stringliteral">": Accidentally in acceptDevice()"</span>
<a name="l00355"></a>00355             &lt;&lt; endl;
<a name="l00356"></a>00356         }
<a name="l00357"></a>00357         fAcceptedCount++;
<a name="l00358"></a>00358         <span class="keywordflow">if</span> (fAcceptedCount&gt;10)
<a name="l00359"></a>00359         {
<a name="l00360"></a>00360             <span class="comment">// Damn the torpedoes</span>
<a name="l00361"></a>00361             KPILOT_DELETE(fSocketNotifier);
<a name="l00362"></a>00362         }
<a name="l00363"></a>00363         <span class="keywordflow">return</span>;
<a name="l00364"></a>00364     }
<a name="l00365"></a>00365 
<a name="l00366"></a>00366     <span class="keywordflow">if</span> (fSocketNotifier)
<a name="l00367"></a>00367     {
<a name="l00368"></a>00368         <span class="comment">// fSocketNotifier-&gt;setEnabled(false);</span>
<a name="l00369"></a>00369         fSocketNotifierActive=<span class="keyword">false</span>;
<a name="l00370"></a>00370         KPILOT_DELETE(fSocketNotifier);
<a name="l00371"></a>00371     }
<a name="l00372"></a>00372 
<a name="l00373"></a>00373     DEBUGKPILOT &lt;&lt; fname &lt;&lt; <span class="stringliteral">": Found connection on device: ["</span>
<a name="l00374"></a>00374         &lt;&lt; link()-&gt;<a class="code" href="classKPilotLink.html#17da9e490e5929d6b5ada57b9488b85b" title="Information on what kind of device we&amp;#39;re dealing with.">pilotPath</a>().latin1() &lt;&lt; <span class="stringliteral">"]."</span> &lt;&lt;endl;
<a name="l00375"></a>00375 
<a name="l00376"></a>00376     DEBUGKPILOT &lt;&lt; fname
<a name="l00377"></a>00377         &lt;&lt; <span class="stringliteral">": Current status: ["</span>
<a name="l00378"></a>00378         &lt;&lt; link()-&gt;<a class="code" href="classKPilotDeviceLink.html#99cffe9febf5b12705f1df88a66be351" title="Get a human-readable string for the given status l.">statusString</a>()
<a name="l00379"></a>00379         &lt;&lt; <span class="stringliteral">"] and socket: ["</span> &lt;&lt; fTempSocket &lt;&lt; <span class="stringliteral">"]"</span> &lt;&lt; endl;
<a name="l00380"></a>00380 
<a name="l00381"></a>00381     ret = pi_listen(fTempSocket, 1);
<a name="l00382"></a>00382     <span class="keywordflow">if</span> (ret &lt; 0)
<a name="l00383"></a>00383     {
<a name="l00384"></a>00384         <span class="keywordtype">char</span> *s = strerror(errno);
<a name="l00385"></a>00385 
<a name="l00386"></a>00386         WARNINGKPILOT &lt;&lt; <span class="stringliteral">"pi_listen returned: ["</span> &lt;&lt; s &lt;&lt; <span class="stringliteral">"]"</span> &lt;&lt; endl;
<a name="l00387"></a>00387 
<a name="l00388"></a>00388         <span class="comment">// Presumably, strerror() returns things in</span>
<a name="l00389"></a>00389         <span class="comment">// local8Bit and not latin1.</span>
<a name="l00390"></a>00390         QApplication::postEvent(link(), <span class="keyword">new</span> DeviceCommEvent(EventLogError,
<a name="l00391"></a>00391                 i18n(<span class="stringliteral">"Cannot listen on Pilot socket (%1)"</span>).
<a name="l00392"></a>00392                 arg(QString::fromLocal8Bit(s))));
<a name="l00393"></a>00393         reset();
<a name="l00394"></a>00394         <span class="keywordflow">return</span>;
<a name="l00395"></a>00395     }
<a name="l00396"></a>00396 
<a name="l00397"></a>00397     QApplication::postEvent(link(), <span class="keyword">new</span> DeviceCommEvent(EventLogProgress, QString::null, 10));
<a name="l00398"></a>00398 
<a name="l00399"></a>00399     DEBUGKPILOT &lt;&lt; fname &lt;&lt;
<a name="l00400"></a>00400         <span class="stringliteral">": Listening to pilot. Now trying accept..."</span> &lt;&lt; endl;
<a name="l00401"></a>00401 
<a name="l00402"></a>00402     <span class="keywordtype">int</span> timeout = 20;
<a name="l00403"></a>00403     fPilotSocket = pi_accept_to(fTempSocket, 0, 0, timeout);
<a name="l00404"></a>00404 
<a name="l00405"></a>00405     <span class="keywordflow">if</span> (fPilotSocket &lt; 0)
<a name="l00406"></a>00406     {
<a name="l00407"></a>00407         <span class="keywordtype">char</span> *s = strerror(errno);
<a name="l00408"></a>00408 
<a name="l00409"></a>00409         WARNINGKPILOT &lt;&lt; <span class="stringliteral">"pi_accept returned: ["</span> &lt;&lt; s &lt;&lt; <span class="stringliteral">"]"</span> &lt;&lt; endl;
<a name="l00410"></a>00410 
<a name="l00411"></a>00411         QApplication::postEvent(link(), <span class="keyword">new</span> DeviceCommEvent(EventLogError, i18n(<span class="stringliteral">"Cannot accept Pilot (%1)"</span>)
<a name="l00412"></a>00412                 .arg(QString::fromLocal8Bit(s))));
<a name="l00413"></a>00413 
<a name="l00414"></a>00414         link()-&gt;<a class="code" href="classKPilotDeviceLink.html#ac681b833d3e3fa7f677ad331d0502f1">fLinkStatus</a> = PilotLinkError;
<a name="l00415"></a>00415         reset();
<a name="l00416"></a>00416         <span class="keywordflow">return</span>;
<a name="l00417"></a>00417     }
<a name="l00418"></a>00418 
<a name="l00419"></a>00419     DEBUGKPILOT &lt;&lt; fname &lt;&lt; <span class="stringliteral">": Link accept done."</span> &lt;&lt; endl;
<a name="l00420"></a>00420 
<a name="l00421"></a>00421     <span class="keywordflow">if</span> ((link()-&gt;fLinkStatus != DeviceOpen) || (fPilotSocket == -1))
<a name="l00422"></a>00422     {
<a name="l00423"></a>00423         link()-&gt;<a class="code" href="classKPilotDeviceLink.html#ac681b833d3e3fa7f677ad331d0502f1">fLinkStatus</a> = PilotLinkError;
<a name="l00424"></a>00424         WARNINGKPILOT &lt;&lt; <span class="stringliteral">"Already connected or unable to connect!"</span> &lt;&lt; endl;
<a name="l00425"></a>00425 
<a name="l00426"></a>00426         QApplication::postEvent(link(), <span class="keyword">new</span> DeviceCommEvent(EventLogError, i18n(<span class="stringliteral">"Cannot accept Pilot (%1)"</span>)
<a name="l00427"></a>00427                 .arg(i18n(<span class="stringliteral">"already connected"</span>))));
<a name="l00428"></a>00428 
<a name="l00429"></a>00429         reset();
<a name="l00430"></a>00430         <span class="keywordflow">return</span>;
<a name="l00431"></a>00431     }
<a name="l00432"></a>00432 
<a name="l00433"></a>00433     QApplication::postEvent(link(), <span class="keyword">new</span> DeviceCommEvent(EventLogProgress, QString::null, 30));
<a name="l00434"></a>00434 
<a name="l00435"></a>00435     DEBUGKPILOT &lt;&lt; fname &lt;&lt; <span class="stringliteral">": doing dlp_ReadSysInfo..."</span> &lt;&lt; endl;
<a name="l00436"></a>00436 
<a name="l00437"></a>00437     <span class="keyword">struct </span>SysInfo sys_info;
<a name="l00438"></a>00438     <span class="keywordflow">if</span> (dlp_ReadSysInfo(fPilotSocket, &amp;sys_info) &lt; 0)
<a name="l00439"></a>00439     {
<a name="l00440"></a>00440         QApplication::postEvent(link(), <span class="keyword">new</span> DeviceCommEvent(EventLogError,
<a name="l00441"></a>00441                 i18n(<span class="stringliteral">"Unable to read system information from Pilot"</span>)));
<a name="l00442"></a>00442 
<a name="l00443"></a>00443         link()-&gt;<a class="code" href="classKPilotDeviceLink.html#ac681b833d3e3fa7f677ad331d0502f1">fLinkStatus</a>=PilotLinkError;
<a name="l00444"></a>00444         reset();
<a name="l00445"></a>00445         <span class="keywordflow">return</span>;
<a name="l00446"></a>00446     }
<a name="l00447"></a>00447     <span class="keywordflow">else</span>
<a name="l00448"></a>00448     {
<a name="l00449"></a>00449         DEBUGKPILOT &lt;&lt; fname &lt;&lt; <span class="stringliteral">": dlp_ReadSysInfo successful..."</span> &lt;&lt; endl;
<a name="l00450"></a>00450 
<a name="l00451"></a>00451         KPILOT_DELETE(link()-&gt;fPilotSysInfo);
<a name="l00452"></a>00452         link()-&gt;<a class="code" href="classKPilotLink.html#6cc39da0ab26bde7a7c88193028bb500" title="System information about the device.">fPilotSysInfo</a> = <span class="keyword">new</span> KPilotSysInfo(&amp;sys_info);
<a name="l00453"></a>00453         DEBUGKPILOT &lt;&lt; fname
<a name="l00454"></a>00454             &lt;&lt; <span class="stringliteral">": RomVersion: ["</span> &lt;&lt; link()-&gt;<a class="code" href="classKPilotLink.html#6cc39da0ab26bde7a7c88193028bb500" title="System information about the device.">fPilotSysInfo</a>-&gt;getRomVersion()
<a name="l00455"></a>00455             &lt;&lt; <span class="stringliteral">"] Locale: ["</span> &lt;&lt; link()-&gt;<a class="code" href="classKPilotLink.html#6cc39da0ab26bde7a7c88193028bb500" title="System information about the device.">fPilotSysInfo</a>-&gt;getLocale()
<a name="l00456"></a>00456             &lt;&lt; <span class="stringliteral">"] Product: ["</span> &lt;&lt; link()-&gt;<a class="code" href="classKPilotLink.html#6cc39da0ab26bde7a7c88193028bb500" title="System information about the device.">fPilotSysInfo</a>-&gt;getProductID()
<a name="l00457"></a>00457             &lt;&lt; <span class="stringliteral">"]"</span> &lt;&lt; endl;
<a name="l00458"></a>00458     }
<a name="l00459"></a>00459 
<a name="l00460"></a>00460     <span class="comment">// If we've made it this far, make sure our USB workaround timer doesn't fire!</span>
<a name="l00461"></a>00461     fWorkaroundUSBTimer-&gt;stop();
<a name="l00462"></a>00462     KPILOT_DELETE(fWorkaroundUSBTimer);
<a name="l00463"></a>00463 
<a name="l00464"></a>00464     QApplication::postEvent(link(), <span class="keyword">new</span> DeviceCommEvent(EventLogProgress, QString::null, 60));
<a name="l00465"></a>00465 
<a name="l00466"></a>00466     KPILOT_DELETE(link()-&gt;fPilotUser);
<a name="l00467"></a>00467     link()-&gt;<a class="code" href="classKPilotLink.html#1e899f38254dd6afc3067726d1a08aa9" title="User information structure.">fPilotUser</a> = <span class="keyword">new</span> KPilotUser;
<a name="l00468"></a>00468 
<a name="l00469"></a>00469     DEBUGKPILOT &lt;&lt; fname &lt;&lt; <span class="stringliteral">": doing dlp_ReadUserInfo..."</span> &lt;&lt; endl;
<a name="l00470"></a>00470 
<a name="l00471"></a>00471     <span class="comment">/* Ask the pilot who it is.  And see if it's who we think it is. */</span>
<a name="l00472"></a>00472     dlp_ReadUserInfo(fPilotSocket, link()-&gt;fPilotUser-&gt;data());
<a name="l00473"></a>00473 
<a name="l00474"></a>00474     QString n = link()-&gt;<a class="code" href="classKPilotLink.html#5aa7b902245c4533efa16eebb6454eaf" title="Retrieve the user information from the device.">getPilotUser</a>().name();
<a name="l00475"></a>00475     DEBUGKPILOT &lt;&lt; fname
<a name="l00476"></a>00476         &lt;&lt; <span class="stringliteral">": Read user name: ["</span> &lt;&lt; n &lt;&lt; <span class="stringliteral">"]"</span> &lt;&lt; endl;
<a name="l00477"></a>00477 
<a name="l00478"></a>00478     QApplication::postEvent(link(), <span class="keyword">new</span> DeviceCommEvent(EventLogProgress, i18n(<span class="stringliteral">"Checking last PC..."</span>), 90));
<a name="l00479"></a>00479 
<a name="l00480"></a>00480     <span class="comment">/* Tell user (via Pilot) that we are starting things up */</span>
<a name="l00481"></a>00481     <span class="keywordflow">if</span> ((ret=dlp_OpenConduit(fPilotSocket)) &lt; 0)
<a name="l00482"></a>00482     {
<a name="l00483"></a>00483         DEBUGKPILOT &lt;&lt; fname
<a name="l00484"></a>00484             &lt;&lt; <span class="stringliteral">": dlp_OpenConduit returned: ["</span> &lt;&lt; ret &lt;&lt; <span class="stringliteral">"]"</span> &lt;&lt; endl;
<a name="l00485"></a>00485 
<a name="l00486"></a>00486         QApplication::postEvent(link(), <span class="keyword">new</span> DeviceCommEvent(EventLogError,
<a name="l00487"></a>00487                 i18n(<span class="stringliteral">"Could not read user information from the Pilot. "</span>
<a name="l00488"></a>00488                         <span class="stringliteral">"Perhaps you have a password set on the device?"</span>)));
<a name="l00489"></a>00489 
<a name="l00490"></a>00490     }
<a name="l00491"></a>00491     link()-&gt;<a class="code" href="classKPilotDeviceLink.html#ac681b833d3e3fa7f677ad331d0502f1">fLinkStatus</a> = AcceptedDevice;
<a name="l00492"></a>00492 
<a name="l00493"></a>00493     QApplication::postEvent(link(), <span class="keyword">new</span> DeviceCommEvent(EventLogProgress, QString::null, 100));
<a name="l00494"></a>00494 
<a name="l00495"></a>00495     DeviceCommEvent * ev = <span class="keyword">new</span> DeviceCommEvent(EventDeviceReady);
<a name="l00496"></a>00496     ev-&gt;setCurrentSocket(fPilotSocket);
<a name="l00497"></a>00497     QApplication::postEvent(link(), ev);
<a name="l00498"></a>00498 
<a name="l00499"></a>00499 }
<a name="l00500"></a>00500 
<a name="l00501"></a><a class="code" href="classDeviceCommThread.html#1c11ffbf720e699496f7284684932c5b">00501</a> <span class="keywordtype">void</span> <a class="code" href="classDeviceCommThread.html#1c11ffbf720e699496f7284684932c5b" title="This slot fires whenever we&amp;#39;ve been trying to establish a hotsync with the device...">DeviceCommThread::workaroundUSB</a>()
<a name="l00502"></a>00502 {
<a name="l00503"></a>00503     FUNCTIONSETUP;
<a name="l00504"></a>00504 
<a name="l00505"></a>00505     reset();
<a name="l00506"></a>00506 }
<a name="l00507"></a>00507 
<a name="l00508"></a>00508 <span class="keywordtype">void</span> DeviceCommThread::run()
<a name="l00509"></a>00509 {
<a name="l00510"></a>00510     FUNCTIONSETUP;
<a name="l00511"></a>00511     fDone = <span class="keyword">false</span>;
<a name="l00512"></a>00512 
<a name="l00513"></a>00513     startOpenTimer(<span class="keyword">this</span>, fOpenTimer);
<a name="l00514"></a>00514 
<a name="l00515"></a>00515     <span class="keywordtype">int</span> sleepBetweenPoll = 2;
<a name="l00516"></a>00516     <span class="comment">// keep the thread alive until we're supposed to be done</span>
<a name="l00517"></a>00517     <span class="keywordflow">while</span> (!fDone)
<a name="l00518"></a>00518     {
<a name="l00519"></a>00519         QThread::sleep(sleepBetweenPoll);
<a name="l00520"></a>00520     }
<a name="l00521"></a>00521 
<a name="l00522"></a>00522     close();
<a name="l00523"></a>00523     <span class="comment">// now sleep one last bit to make sure the pthread inside</span>
<a name="l00524"></a>00524     <span class="comment">// pilot-link (potentially, if it's libusb) is done before we exit</span>
<a name="l00525"></a>00525     QThread::sleep(1);
<a name="l00526"></a>00526 
<a name="l00527"></a>00527     DEBUGKPILOT &lt;&lt; fname &lt;&lt; <span class="stringliteral">": comm thread now done..."</span> &lt;&lt; endl;
<a name="l00528"></a>00528 }
<a name="l00529"></a>00529 
<a name="l00530"></a><a class="code" href="classKPilotDeviceLink.html#e807a3db3836da2fdf539d63aef2078c">00530</a> <a class="code" href="classKPilotDeviceLink.html#e807a3db3836da2fdf539d63aef2078c" title="Constructor.">KPilotDeviceLink::KPilotDeviceLink</a>(QObject * parent, <span class="keyword">const</span> <span class="keywordtype">char</span> *name,
<a name="l00531"></a>00531         <span class="keyword">const</span> QString &amp;tempDevice) :
<a name="l00532"></a>00532     <a class="code" href="classKPilotLink.html" title="KPilotLink handles some aspects of communication with a Handheld.">KPilotLink</a>(parent, name), fLinkStatus(Init), fWorkaroundUSB(false),
<a name="l00533"></a>00533             fPilotSocket(-1), fTempDevice(tempDevice), fMessages(new Messages(this)), fDeviceCommThread(0L)
<a name="l00534"></a>00534 {
<a name="l00535"></a>00535     FUNCTIONSETUP;
<a name="l00536"></a>00536 
<a name="l00537"></a>00537     DEBUGKPILOT &lt;&lt; fname
<a name="l00538"></a>00538         &lt;&lt; <span class="stringliteral">": Pilot-link version: ["</span> &lt;&lt; PILOT_LINK_NUMBER
<a name="l00539"></a>00539         &lt;&lt; <span class="stringliteral">"]"</span> &lt;&lt; endl;
<a name="l00540"></a>00540 }
<a name="l00541"></a>00541 
<a name="l00542"></a><a class="code" href="classKPilotDeviceLink.html#af4e2a2346c8290c04aaff62fe70c0d8">00542</a> <a class="code" href="classKPilotDeviceLink.html#af4e2a2346c8290c04aaff62fe70c0d8" title="Destructor.">KPilotDeviceLink::~KPilotDeviceLink</a>()
<a name="l00543"></a>00543 {
<a name="l00544"></a>00544     FUNCTIONSETUP;
<a name="l00545"></a>00545     <a class="code" href="classKPilotDeviceLink.html#b7e0347f592550521f4c967975e66d1c" title="Release all resources, including the master pilot socket, timers, etc.">close</a>();
<a name="l00546"></a>00546     KPILOT_DELETE(<a class="code" href="classKPilotLink.html#6cc39da0ab26bde7a7c88193028bb500" title="System information about the device.">fPilotSysInfo</a>);
<a name="l00547"></a>00547     KPILOT_DELETE(<a class="code" href="classKPilotLink.html#1e899f38254dd6afc3067726d1a08aa9" title="User information structure.">fPilotUser</a>);
<a name="l00548"></a>00548     KPILOT_DELETE(fMessages);
<a name="l00549"></a>00549 }
<a name="l00550"></a>00550 
<a name="l00551"></a><a class="code" href="classKPilotDeviceLink.html#63a66d4f73bce3cc1ac185233258d3e9">00551</a> <span class="comment">/* virtual */</span><span class="keywordtype">bool</span> <a class="code" href="classKPilotDeviceLink.html#63a66d4f73bce3cc1ac185233258d3e9" title="True if HotSync has been started but not finished yet (ie.">KPilotDeviceLink::isConnected</a>()<span class="keyword"> const</span>
<a name="l00552"></a>00552 <span class="keyword"></span>{
<a name="l00553"></a>00553     <span class="keywordflow">return</span> fLinkStatus == AcceptedDevice;
<a name="l00554"></a>00554 }
<a name="l00555"></a>00555 
<a name="l00556"></a><a class="code" href="classKPilotDeviceLink.html#01525c65efacfee53bff912c13db8bb7">00556</a> <span class="comment">/* virtual */</span><span class="keywordtype">bool</span> <a class="code" href="classKPilotDeviceLink.html#01525c65efacfee53bff912c13db8bb7" title="Allows our class to receive custom events that our threads will be giving to us,...">KPilotDeviceLink::event</a>(QEvent *e)
<a name="l00557"></a>00557 {
<a name="l00558"></a>00558     FUNCTIONSETUP;
<a name="l00559"></a>00559 
<a name="l00560"></a>00560     <span class="keywordtype">bool</span> handled = <span class="keyword">false</span>;
<a name="l00561"></a>00561 
<a name="l00562"></a>00562     <span class="keywordflow">if</span> ((<span class="keywordtype">int</span>)e-&gt;type() == EventDeviceReady)
<a name="l00563"></a>00563     {
<a name="l00564"></a>00564         DeviceCommEvent* t = <span class="keyword">static_cast&lt;</span>DeviceCommEvent*<span class="keyword">&gt;</span>(e);
<a name="l00565"></a>00565         <a class="code" href="classKPilotDeviceLink.html#16e64a051920f58eda67086e9d8d308e" title="Pilot-link library handles for the device once it&amp;#39;s opened.">fPilotSocket</a> = t-&gt;currentSocket();
<a name="l00566"></a>00566         emit <a class="code" href="classKPilotLink.html#484126de2ce41436c19c782bb0b5c075" title="Emitted once the user information has been read and the HotSync is really ready to...">deviceReady</a>( <span class="keyword">this</span>);
<a name="l00567"></a>00567         handled = <span class="keyword">true</span>;
<a name="l00568"></a>00568     }
<a name="l00569"></a>00569     <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((<span class="keywordtype">int</span>)e-&gt;type() == EventLogMessage)
<a name="l00570"></a>00570     {
<a name="l00571"></a>00571         DeviceCommEvent* t = <span class="keyword">static_cast&lt;</span>DeviceCommEvent*<span class="keyword">&gt;</span>(e);
<a name="l00572"></a>00572         emit <a class="code" href="classKPilotLink.html#3cd9fad622ffa521829d34532a95c30c" title="Signal that a message has been written to the sync log.">logMessage</a>(t-&gt;message());
<a name="l00573"></a>00573         handled = <span class="keyword">true</span>;
<a name="l00574"></a>00574     }
<a name="l00575"></a>00575     <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((<span class="keywordtype">int</span>)e-&gt;type() == EventLogError)
<a name="l00576"></a>00576     {
<a name="l00577"></a>00577         DeviceCommEvent* t = <span class="keyword">static_cast&lt;</span>DeviceCommEvent*<span class="keyword">&gt;</span>(e);
<a name="l00578"></a>00578         emit <a class="code" href="classKPilotLink.html#3900f1762d5e4ea34eb6e1a55d996495" title="Signal that an error has occurred, for logging.">logError</a>(t-&gt;message());
<a name="l00579"></a>00579         handled = <span class="keyword">true</span>;
<a name="l00580"></a>00580     }
<a name="l00581"></a>00581     <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((<span class="keywordtype">int</span>)e-&gt;type() == EventLogProgress)
<a name="l00582"></a>00582     {
<a name="l00583"></a>00583         DeviceCommEvent* t = <span class="keyword">static_cast&lt;</span>DeviceCommEvent*<span class="keyword">&gt;</span>(e);
<a name="l00584"></a>00584         emit <a class="code" href="classKPilotLink.html#1aac46c985996eedbbfbe7c72dd26e8f" title="Signal that progress has been made, for logging purposes.">logProgress</a>(t-&gt;message(), t-&gt;progress());
<a name="l00585"></a>00585         handled = <span class="keyword">true</span>;
<a name="l00586"></a>00586     }
<a name="l00587"></a>00587     <span class="keywordflow">else</span>
<a name="l00588"></a>00588     {
<a name="l00589"></a>00589         handled = <a class="code" href="classKPilotLink.html#515938ea6d53c08f543db05913eaca86" title="Allows our class to receive custom events that our threads will be giving to us,...">KPilotLink::event</a>(e);
<a name="l00590"></a>00590     }
<a name="l00591"></a>00591 
<a name="l00592"></a>00592     <span class="keywordflow">return</span> handled;
<a name="l00593"></a>00593 }
<a name="l00594"></a>00594 
<a name="l00595"></a>00595 <span class="keywordtype">void</span> KPilotDeviceLink::stopCommThread()
<a name="l00596"></a>00596 {
<a name="l00597"></a>00597     FUNCTIONSETUP;
<a name="l00598"></a>00598     <span class="keywordflow">if</span> (fDeviceCommThread)
<a name="l00599"></a>00599     {
<a name="l00600"></a>00600         fDeviceCommThread-&gt;<a class="code" href="classDeviceCommThread.html#46b6eb848b8945c16df814f4ea13ca1d">setDone</a>(<span class="keyword">true</span>);
<a name="l00601"></a>00601 
<a name="l00602"></a>00602         <span class="comment">// try to wait for our thread to finish, but don't</span>
<a name="l00603"></a>00603         <span class="comment">// block the main thread forever</span>
<a name="l00604"></a>00604         <span class="keywordflow">if</span> (fDeviceCommThread-&gt;running())
<a name="l00605"></a>00605         {
<a name="l00606"></a>00606             DEBUGKPILOT &lt;&lt; fname
<a name="l00607"></a>00607                 &lt;&lt; <span class="stringliteral">": comm thread still running. "</span>
<a name="l00608"></a>00608                 &lt;&lt; <span class="stringliteral">"waiting for it to complete."</span> &lt;&lt; endl;
<a name="l00609"></a>00609             <span class="keywordtype">bool</span> done = fDeviceCommThread-&gt;wait(5000);
<a name="l00610"></a>00610             <span class="keywordflow">if</span> (!done)
<a name="l00611"></a>00611             {
<a name="l00612"></a>00612                 DEBUGKPILOT &lt;&lt; fname
<a name="l00613"></a>00613                     &lt;&lt; <span class="stringliteral">": comm thread still running "</span>
<a name="l00614"></a>00614                     &lt;&lt; <span class="stringliteral">"after wait(). "</span>
<a name="l00615"></a>00615                     &lt;&lt; <span class="stringliteral">"going to have to terminate it."</span>
<a name="l00616"></a>00616                     &lt;&lt; endl;
<a name="l00617"></a>00617                 <span class="comment">// not normally to be done, but we must make sure</span>
<a name="l00618"></a>00618                 <span class="comment">// that this device doesn't come back alive</span>
<a name="l00619"></a>00619                 fDeviceCommThread-&gt;terminate();
<a name="l00620"></a>00620                 fDeviceCommThread-&gt;wait();
<a name="l00621"></a>00621             }
<a name="l00622"></a>00622         }
<a name="l00623"></a>00623 
<a name="l00624"></a>00624         fDeviceCommThread-&gt;<a class="code" href="classDeviceCommThread.html#f7ce6f4b50cfcaf53685fbe375918be6">close</a>();
<a name="l00625"></a>00625 
<a name="l00626"></a>00626         KPILOT_DELETE(fDeviceCommThread);
<a name="l00627"></a>00627     }
<a name="l00628"></a>00628 }
<a name="l00629"></a>00629 
<a name="l00630"></a><a class="code" href="classKPilotDeviceLink.html#b7e0347f592550521f4c967975e66d1c">00630</a> <span class="keywordtype">void</span> <a class="code" href="classKPilotDeviceLink.html#b7e0347f592550521f4c967975e66d1c" title="Release all resources, including the master pilot socket, timers, etc.">KPilotDeviceLink::close</a>()
<a name="l00631"></a>00631 {
<a name="l00632"></a>00632     FUNCTIONSETUP;
<a name="l00633"></a>00633 
<a name="l00634"></a>00634     stopCommThread();
<a name="l00635"></a>00635 
<a name="l00636"></a>00636     <a class="code" href="classKPilotDeviceLink.html#16e64a051920f58eda67086e9d8d308e" title="Pilot-link library handles for the device once it&amp;#39;s opened.">fPilotSocket</a> = (-1);
<a name="l00637"></a>00637 }
<a name="l00638"></a>00638 
<a name="l00639"></a><a class="code" href="classKPilotDeviceLink.html#997017c2733fb8fbba41a3a34857263f">00639</a> <span class="keywordtype">void</span> <a class="code" href="classKPilotDeviceLink.html#cbf1ed11ea1969ebbebf0970d1eae9c3" title="Assuming things have been set up at least once already by a call to reset() with...">KPilotDeviceLink::reset</a>(<span class="keyword">const</span> QString &amp; dP)
<a name="l00640"></a>00640 {
<a name="l00641"></a>00641     FUNCTIONSETUP;
<a name="l00642"></a>00642 
<a name="l00643"></a>00643     fLinkStatus = Init;
<a name="l00644"></a>00644 
<a name="l00645"></a>00645     <span class="comment">// Release all resources</span>
<a name="l00646"></a>00646     <span class="comment">//</span>
<a name="l00647"></a>00647     <a class="code" href="classKPilotDeviceLink.html#b7e0347f592550521f4c967975e66d1c" title="Release all resources, including the master pilot socket, timers, etc.">close</a>();
<a name="l00648"></a>00648     <a class="code" href="classKPilotLink.html#49e621f9a9aaea2e96bae802fa3b9cea" title="Path of the device special file that will be used.">fPilotPath</a> = QString::null;
<a name="l00649"></a>00649 
<a name="l00650"></a>00650     <a class="code" href="classKPilotLink.html#49e621f9a9aaea2e96bae802fa3b9cea" title="Path of the device special file that will be used.">fPilotPath</a> = dP;
<a name="l00651"></a>00651     <span class="keywordflow">if</span> (<a class="code" href="classKPilotLink.html#49e621f9a9aaea2e96bae802fa3b9cea" title="Path of the device special file that will be used.">fPilotPath</a>.isEmpty())
<a name="l00652"></a>00652         <a class="code" href="classKPilotLink.html#49e621f9a9aaea2e96bae802fa3b9cea" title="Path of the device special file that will be used.">fPilotPath</a> = fTempDevice;
<a name="l00653"></a>00653     <span class="keywordflow">if</span> (<a class="code" href="classKPilotLink.html#49e621f9a9aaea2e96bae802fa3b9cea" title="Path of the device special file that will be used.">fPilotPath</a>.isEmpty())
<a name="l00654"></a>00654         <span class="keywordflow">return</span>;
<a name="l00655"></a>00655 
<a name="l00656"></a>00656     <a class="code" href="classKPilotDeviceLink.html#cbf1ed11ea1969ebbebf0970d1eae9c3" title="Assuming things have been set up at least once already by a call to reset() with...">reset</a>();
<a name="l00657"></a>00657 }
<a name="l00658"></a>00658 
<a name="l00659"></a><a class="code" href="classKPilotDeviceLink.html#c620a1e28305efbd4b66bb5ed4799ebd">00659</a> <span class="keywordtype">void</span> <a class="code" href="classKPilotDeviceLink.html#c620a1e28305efbd4b66bb5ed4799ebd" title="Start/Stop our device communication thread.">KPilotDeviceLink::startCommThread</a>()
<a name="l00660"></a>00660 {
<a name="l00661"></a>00661     FUNCTIONSETUP;
<a name="l00662"></a>00662 
<a name="l00663"></a>00663     stopCommThread();
<a name="l00664"></a>00664 
<a name="l00665"></a>00665     <span class="keywordflow">if</span> (fTempDevice.isEmpty() &amp;&amp; <a class="code" href="classKPilotLink.html#17da9e490e5929d6b5ada57b9488b85b" title="Information on what kind of device we&amp;#39;re dealing with.">pilotPath</a>().isEmpty())
<a name="l00666"></a>00666     {
<a name="l00667"></a>00667         WARNINGKPILOT &lt;&lt; <span class="stringliteral">"No point in trying empty device."</span>
<a name="l00668"></a>00668             &lt;&lt; endl;
<a name="l00669"></a>00669 
<a name="l00670"></a>00670         QString msg = i18n(<span class="stringliteral">"The Pilot device is not configured yet."</span>);
<a name="l00671"></a>00671         WARNINGKPILOT &lt;&lt; msg &lt;&lt; endl;
<a name="l00672"></a>00672 
<a name="l00673"></a>00673         fLinkStatus = PilotLinkError;
<a name="l00674"></a>00674 
<a name="l00675"></a>00675         emit <a class="code" href="classKPilotLink.html#3900f1762d5e4ea34eb6e1a55d996495" title="Signal that an error has occurred, for logging.">logError</a>(msg);
<a name="l00676"></a>00676         <span class="keywordflow">return</span>;
<a name="l00677"></a>00677     }
<a name="l00678"></a>00678 
<a name="l00679"></a>00679     fDeviceCommThread = <span class="keyword">new</span> <a class="code" href="classDeviceCommThread.html" title="Class that handles all device communications.">DeviceCommThread</a>(<span class="keyword">this</span>);
<a name="l00680"></a>00680     fDeviceCommThread-&gt;start();
<a name="l00681"></a>00681 }
<a name="l00682"></a>00682 
<a name="l00683"></a><a class="code" href="classKPilotDeviceLink.html#cbf1ed11ea1969ebbebf0970d1eae9c3">00683</a> <span class="keywordtype">void</span> <a class="code" href="classKPilotDeviceLink.html#cbf1ed11ea1969ebbebf0970d1eae9c3" title="Assuming things have been set up at least once already by a call to reset() with...">KPilotDeviceLink::reset</a>()
<a name="l00684"></a>00684 {
<a name="l00685"></a>00685     FUNCTIONSETUP;
<a name="l00686"></a>00686 
<a name="l00687"></a>00687     fMessages-&gt;reset();
<a name="l00688"></a>00688     <a class="code" href="classKPilotDeviceLink.html#b7e0347f592550521f4c967975e66d1c" title="Release all resources, including the master pilot socket, timers, etc.">close</a>();
<a name="l00689"></a>00689 
<a name="l00690"></a>00690     <a class="code" href="classKPilotDeviceLink.html#1b77adddd947f35a4806fff3294cb47c" title="Check for device permissions and existence, emitting warnings for weird situations...">checkDevice</a>();
<a name="l00691"></a>00691 
<a name="l00692"></a>00692     fLinkStatus = WaitingForDevice;
<a name="l00693"></a>00693 
<a name="l00694"></a>00694     <a class="code" href="classKPilotDeviceLink.html#c620a1e28305efbd4b66bb5ed4799ebd" title="Start/Stop our device communication thread.">startCommThread</a>();
<a name="l00695"></a>00695 }
<a name="l00696"></a>00696 
<a name="l00697"></a><a class="code" href="classKPilotDeviceLink.html#1b77adddd947f35a4806fff3294cb47c">00697</a> <span class="keywordtype">void</span> <a class="code" href="classKPilotDeviceLink.html#1b77adddd947f35a4806fff3294cb47c" title="Check for device permissions and existence, emitting warnings for weird situations...">KPilotDeviceLink::checkDevice</a>()
<a name="l00698"></a>00698 {
<a name="l00699"></a>00699     <span class="comment">// If the device exists yet doesn't have the right</span>
<a name="l00700"></a>00700     <span class="comment">// permissions, complain and then continue anyway.</span>
<a name="l00701"></a>00701     <span class="comment">//</span>
<a name="l00702"></a>00702     QFileInfo fi(<a class="code" href="classKPilotLink.html#49e621f9a9aaea2e96bae802fa3b9cea" title="Path of the device special file that will be used.">fPilotPath</a>);
<a name="l00703"></a>00703     <span class="keywordflow">if</span> (fi.exists())
<a name="l00704"></a>00704     {
<a name="l00705"></a>00705         <span class="comment">// If it exists, it ought to be RW already.</span>
<a name="l00706"></a>00706         <span class="comment">//</span>
<a name="l00707"></a>00707         <span class="keywordflow">if</span> (!(fi.isReadable() &amp;&amp; fi.isWritable()))
<a name="l00708"></a>00708         {
<a name="l00709"></a>00709             emit <a class="code" href="classKPilotLink.html#3900f1762d5e4ea34eb6e1a55d996495" title="Signal that an error has occurred, for logging.">logError</a>(i18n(<span class="stringliteral">"Pilot device %1 is not read-write."</span>)
<a name="l00710"></a>00710             .arg(<a class="code" href="classKPilotLink.html#49e621f9a9aaea2e96bae802fa3b9cea" title="Path of the device special file that will be used.">fPilotPath</a>));
<a name="l00711"></a>00711         }
<a name="l00712"></a>00712     }
<a name="l00713"></a>00713     <span class="keywordflow">else</span>
<a name="l00714"></a>00714     {
<a name="l00715"></a>00715         <span class="comment">// It doesn't exist, mention this in the log</span>
<a name="l00716"></a>00716         <span class="comment">// (relevant as long as we use only one device type)</span>
<a name="l00717"></a>00717         <span class="comment">//</span>
<a name="l00718"></a>00718         emit
<a name="l00719"></a>00719                 <a class="code" href="classKPilotLink.html#3900f1762d5e4ea34eb6e1a55d996495" title="Signal that an error has occurred, for logging.">logError</a>(i18n(<span class="stringliteral">"Pilot device %1 does not exist. "</span>
<a name="l00720"></a>00720                         <span class="stringliteral">"Probably it is a USB device and will appear during a HotSync."</span>)
<a name="l00721"></a>00721                 .arg(<a class="code" href="classKPilotLink.html#49e621f9a9aaea2e96bae802fa3b9cea" title="Path of the device special file that will be used.">fPilotPath</a>));
<a name="l00722"></a>00722         <span class="comment">// Suppress all normal and error messages about opening the device.</span>
<a name="l00723"></a>00723         fMessages-&gt;block(Messages::OpenMessage | Messages::OpenFailMessage,
<a name="l00724"></a>00724                 <span class="keyword">true</span>);
<a name="l00725"></a>00725     }
<a name="l00726"></a>00726 }
<a name="l00727"></a>00727 
<a name="l00728"></a><a class="code" href="classKPilotDeviceLink.html#536b002a63217f4ce290ad3862f904aa">00728</a> <span class="keywordtype">void</span> <a class="code" href="classKPilotDeviceLink.html#536b002a63217f4ce290ad3862f904aa" title="Sets an additional device, which should be tried as fallback.">KPilotDeviceLink::setTempDevice</a>(<span class="keyword">const</span> QString &amp;d)
<a name="l00729"></a>00729 {
<a name="l00730"></a>00730     fTempDevice = d;
<a name="l00731"></a>00731     DeviceMap::self()-&gt;bindDevice(fTempDevice);
<a name="l00732"></a>00732 }
<a name="l00733"></a>00733 
<a name="l00734"></a><a class="code" href="classKPilotDeviceLink.html#4827a40029f4afa11448a8e62773221e">00734</a> <span class="comment">/* virtual */</span><span class="keywordtype">bool</span> <a class="code" href="classKPilotDeviceLink.html#4827a40029f4afa11448a8e62773221e" title="Tickle the underlying device exactly once.">KPilotDeviceLink::tickle</a>()
<a name="l00735"></a>00735 {
<a name="l00736"></a>00736     <span class="comment">// No FUNCTIONSETUP here because it may be called from</span>
<a name="l00737"></a>00737     <span class="comment">// a separate thread.</span>
<a name="l00738"></a>00738     <span class="keywordflow">return</span> pi_tickle(<a class="code" href="classKPilotDeviceLink.html#8b128f57d6ce5004fc928d5b3ca31542" title="Returns a file handle for raw operations.">pilotSocket</a>()) &gt;= 0;
<a name="l00739"></a>00739 }
<a name="l00740"></a>00740 
<a name="l00741"></a><a class="code" href="classKPilotDeviceLink.html#87873247d80d8e3304de111e1cb33fb4">00741</a> <span class="comment">/* virtual */</span><span class="keywordtype">void</span> <a class="code" href="classKPilotDeviceLink.html#87873247d80d8e3304de111e1cb33fb4" title="Actually write an entry to the device link.">KPilotDeviceLink::addSyncLogEntryImpl</a>(<span class="keyword">const</span> QString &amp;entry)
<a name="l00742"></a>00742 {
<a name="l00743"></a>00743     dlp_AddSyncLogEntry(<a class="code" href="classKPilotDeviceLink.html#16e64a051920f58eda67086e9d8d308e" title="Pilot-link library handles for the device once it&amp;#39;s opened.">fPilotSocket</a>,
<a name="l00744"></a>00744             const_cast&lt;char *&gt;((<span class="keyword">const</span> <span class="keywordtype">char</span> *)<a class="code" href="namespacePilot.html#9d13e87df66389043e9db1a76c413f57" title="Static translation function that maps a QString onto the native 8 bit encoding of...">Pilot::toPilot</a>(entry)));
<a name="l00745"></a>00745 }
<a name="l00746"></a>00746 
<a name="l00747"></a><a class="code" href="classKPilotDeviceLink.html#d4162fd05917ccc1be4083050e1bada9">00747</a> <span class="keywordtype">bool</span> <a class="code" href="classKPilotDeviceLink.html#d4162fd05917ccc1be4083050e1bada9" title="Install a single file onto the device link.">KPilotDeviceLink::installFile</a>(<span class="keyword">const</span> QString &amp; f, <span class="keyword">const</span> <span class="keywordtype">bool</span> deleteFile)
<a name="l00748"></a>00748 {
<a name="l00749"></a>00749     FUNCTIONSETUP;
<a name="l00750"></a>00750 
<a name="l00751"></a>00751     DEBUGKPILOT &lt;&lt; fname &lt;&lt; <span class="stringliteral">": Installing file "</span> &lt;&lt; f &lt;&lt; endl;
<a name="l00752"></a>00752 
<a name="l00753"></a>00753     <span class="keywordflow">if</span> (!QFile::exists(f))
<a name="l00754"></a>00754         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00755"></a>00755 
<a name="l00756"></a>00756     <span class="keywordtype">char</span> buffer[PATH_MAX];
<a name="l00757"></a>00757     memset(buffer, 0, PATH_MAX);
<a name="l00758"></a>00758     strlcpy(buffer, QFile::encodeName(f), PATH_MAX);
<a name="l00759"></a>00759     <span class="keyword">struct </span>pi_file *pf = pi_file_open(buffer);
<a name="l00760"></a>00760 
<a name="l00761"></a>00761     <span class="keywordflow">if</span> (!f)
<a name="l00762"></a>00762     {
<a name="l00763"></a>00763         WARNINGKPILOT &lt;&lt; <span class="stringliteral">"Cannot open file "</span> &lt;&lt; f &lt;&lt; endl;
<a name="l00764"></a>00764         emit <a class="code" href="classKPilotLink.html#3900f1762d5e4ea34eb6e1a55d996495" title="Signal that an error has occurred, for logging.">logError</a>(i18n
<a name="l00765"></a>00765             (<span class="stringliteral">"&lt;qt&gt;Cannot install the file &amp;quot;%1&amp;quot;.&lt;/qt&gt;"</span>).
<a name="l00766"></a>00766         arg(f));
<a name="l00767"></a>00767         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00768"></a>00768     }
<a name="l00769"></a>00769 
<a name="l00770"></a>00770     <span class="keywordflow">if</span> (pi_file_install(pf, <a class="code" href="classKPilotDeviceLink.html#16e64a051920f58eda67086e9d8d308e" title="Pilot-link library handles for the device once it&amp;#39;s opened.">fPilotSocket</a>, 0, 0L) &lt; 0)
<a name="l00771"></a>00771     {
<a name="l00772"></a>00772         WARNINGKPILOT &lt;&lt; <span class="stringliteral">"Cannot pi_file_install "</span> &lt;&lt; f &lt;&lt; endl;
<a name="l00773"></a>00773         emit <a class="code" href="classKPilotLink.html#3900f1762d5e4ea34eb6e1a55d996495" title="Signal that an error has occurred, for logging.">logError</a>(i18n
<a name="l00774"></a>00774                 (<span class="stringliteral">"&lt;qt&gt;Cannot install the file &amp;quot;%1&amp;quot;.&lt;/qt&gt;"</span>).
<a name="l00775"></a>00775         arg(f));
<a name="l00776"></a>00776         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00777"></a>00777     }
<a name="l00778"></a>00778 
<a name="l00779"></a>00779     pi_file_close(pf);
<a name="l00780"></a>00780     <span class="keywordflow">if</span> (deleteFile)
<a name="l00781"></a>00781         QFile::remove(f);
<a name="l00782"></a>00782 
<a name="l00783"></a>00783     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00784"></a>00784 }
<a name="l00785"></a>00785 
<a name="l00786"></a><a class="code" href="classKPilotDeviceLink.html#e9be6b060599f0243c354ba7072e0310">00786</a> <span class="keywordtype">int</span> <a class="code" href="classKPilotDeviceLink.html#e9be6b060599f0243c354ba7072e0310" title="Notify the Pilot user that a conduit is running now.">KPilotDeviceLink::openConduit</a>()
<a name="l00787"></a>00787 {
<a name="l00788"></a>00788     <span class="keywordflow">return</span> dlp_OpenConduit(<a class="code" href="classKPilotDeviceLink.html#16e64a051920f58eda67086e9d8d308e" title="Pilot-link library handles for the device once it&amp;#39;s opened.">fPilotSocket</a>);
<a name="l00789"></a>00789 }
<a name="l00790"></a>00790 
<a name="l00791"></a><a class="code" href="classKPilotDeviceLink.html#99cffe9febf5b12705f1df88a66be351">00791</a> QString <a class="code" href="classKPilotDeviceLink.html#19b0915f37803193e5b32c527a8b8505" title="Provides a human-readable status string.">KPilotDeviceLink::statusString</a>(LinkStatus l)
<a name="l00792"></a>00792 {
<a name="l00793"></a>00793     QString s= CSL1(<span class="stringliteral">"KPilotDeviceLink="</span>);
<a name="l00794"></a>00794 
<a name="l00795"></a>00795     <span class="keywordflow">switch</span> (l)
<a name="l00796"></a>00796     {
<a name="l00797"></a>00797     <span class="keywordflow">case</span> Init:
<a name="l00798"></a>00798         s.append(CSL1(<span class="stringliteral">"Init"</span>));
<a name="l00799"></a>00799         <span class="keywordflow">break</span>;
<a name="l00800"></a>00800     <span class="keywordflow">case</span> WaitingForDevice:
<a name="l00801"></a>00801         s.append(CSL1(<span class="stringliteral">"WaitingForDevice"</span>));
<a name="l00802"></a>00802         <span class="keywordflow">break</span>;
<a name="l00803"></a>00803     <span class="keywordflow">case</span> FoundDevice:
<a name="l00804"></a>00804         s.append(CSL1(<span class="stringliteral">"FoundDevice"</span>));
<a name="l00805"></a>00805         <span class="keywordflow">break</span>;
<a name="l00806"></a>00806     <span class="keywordflow">case</span> CreatedSocket:
<a name="l00807"></a>00807         s.append(CSL1(<span class="stringliteral">"CreatedSocket"</span>));
<a name="l00808"></a>00808         <span class="keywordflow">break</span>;
<a name="l00809"></a>00809     <span class="keywordflow">case</span> DeviceOpen:
<a name="l00810"></a>00810         s.append(CSL1(<span class="stringliteral">"DeviceOpen"</span>));
<a name="l00811"></a>00811         <span class="keywordflow">break</span>;
<a name="l00812"></a>00812     <span class="keywordflow">case</span> AcceptedDevice:
<a name="l00813"></a>00813         s.append(CSL1(<span class="stringliteral">"AcceptedDevice"</span>));
<a name="l00814"></a>00814         <span class="keywordflow">break</span>;
<a name="l00815"></a>00815     <span class="keywordflow">case</span> SyncDone:
<a name="l00816"></a>00816         s.append(CSL1(<span class="stringliteral">"SyncDone"</span>));
<a name="l00817"></a>00817         <span class="keywordflow">break</span>;
<a name="l00818"></a>00818     <span class="keywordflow">case</span> PilotLinkError:
<a name="l00819"></a>00819         s.append(CSL1(<span class="stringliteral">"PilotLinkError"</span>));
<a name="l00820"></a>00820         <span class="keywordflow">break</span>;
<a name="l00821"></a>00821     <span class="keywordflow">case</span> WorkaroundUSB:
<a name="l00822"></a>00822         s.append(CSL1(<span class="stringliteral">"WorkaroundUSB"</span>));
<a name="l00823"></a>00823         <span class="keywordflow">break</span>;
<a name="l00824"></a>00824     }
<a name="l00825"></a>00825 
<a name="l00826"></a>00826     <span class="keywordflow">return</span> s;
<a name="l00827"></a>00827 }
<a name="l00828"></a>00828 
<a name="l00829"></a><a class="code" href="classKPilotDeviceLink.html#19b0915f37803193e5b32c527a8b8505">00829</a> QString <a class="code" href="classKPilotDeviceLink.html#19b0915f37803193e5b32c527a8b8505" title="Provides a human-readable status string.">KPilotDeviceLink::statusString</a>()<span class="keyword"> const</span>
<a name="l00830"></a>00830 <span class="keyword"></span>{
<a name="l00831"></a>00831     <span class="keywordflow">return</span> <a class="code" href="classKPilotDeviceLink.html#19b0915f37803193e5b32c527a8b8505" title="Provides a human-readable status string.">statusString</a>(<a class="code" href="classKPilotDeviceLink.html#15ab53812c739ea99b1eb06c894d10e3" title="Get the status (state enum) of this link.">status</a>() );
<a name="l00832"></a>00832 }
<a name="l00833"></a>00833 
<a name="l00834"></a><a class="code" href="classKPilotDeviceLink.html#06c7682d047d5c3a37adbaf59116a213">00834</a> <span class="keywordtype">void</span> <a class="code" href="classKPilotDeviceLink.html#06c7682d047d5c3a37adbaf59116a213" title="End the sync in a gracuful manner.">KPilotDeviceLink::endSync</a>(<a class="code" href="classKPilotLink.html#61758d52e6a0684866d82f5ba224f8c9" title="When ending the sync, you can do so gracefully, updating the last-sync time to indicate...">EndOfSyncFlags</a> f)
<a name="l00835"></a>00835 {
<a name="l00836"></a>00836     FUNCTIONSETUP;
<a name="l00837"></a>00837 
<a name="l00838"></a>00838     <span class="keywordflow">if</span> (<a class="code" href="classKPilotLink.html#61758d52e6a0684866d82f5ba224f8c985394b99f137dd96d2410e4a03729454" title="Update user info and last successful sync date.">UpdateUserInfo</a> == f)
<a name="l00839"></a>00839     {
<a name="l00840"></a>00840         <a class="code" href="classKPilotLink.html#5aa7b902245c4533efa16eebb6454eaf" title="Retrieve the user information from the device.">getPilotUser</a>().setLastSyncPC((<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span>) gethostid());
<a name="l00841"></a>00841         <a class="code" href="classKPilotLink.html#5aa7b902245c4533efa16eebb6454eaf" title="Retrieve the user information from the device.">getPilotUser</a>().setLastSyncDate(time(0));
<a name="l00842"></a>00842 
<a name="l00843"></a>00843         DEBUGKPILOT &lt;&lt; fname &lt;&lt; <span class="stringliteral">": Writing username "</span> &lt;&lt; <a class="code" href="classKPilotLink.html#5aa7b902245c4533efa16eebb6454eaf" title="Retrieve the user information from the device.">getPilotUser</a>().name() &lt;&lt; endl;
<a name="l00844"></a>00844 
<a name="l00845"></a>00845         dlp_WriteUserInfo(<a class="code" href="classKPilotDeviceLink.html#8b128f57d6ce5004fc928d5b3ca31542" title="Returns a file handle for raw operations.">pilotSocket</a>(), <a class="code" href="classKPilotLink.html#5aa7b902245c4533efa16eebb6454eaf" title="Retrieve the user information from the device.">getPilotUser</a>().data());
<a name="l00846"></a>00846         <a class="code" href="classKPilotLink.html#326f972174eb56ce38050d9783620590" title="Write a log entry to the handheld.">addSyncLogEntry</a>(i18n(<span class="stringliteral">"End of HotSync\n"</span>));
<a name="l00847"></a>00847     }
<a name="l00848"></a>00848     dlp_EndOfSync(<a class="code" href="classKPilotDeviceLink.html#8b128f57d6ce5004fc928d5b3ca31542" title="Returns a file handle for raw operations.">pilotSocket</a>(), 0);
<a name="l00849"></a>00849     KPILOT_DELETE(<a class="code" href="classKPilotLink.html#6cc39da0ab26bde7a7c88193028bb500" title="System information about the device.">fPilotSysInfo</a>);
<a name="l00850"></a>00850     KPILOT_DELETE(<a class="code" href="classKPilotLink.html#1e899f38254dd6afc3067726d1a08aa9" title="User information structure.">fPilotUser</a>);
<a name="l00851"></a>00851 }
<a name="l00852"></a>00852 
<a name="l00853"></a><a class="code" href="classKPilotDeviceLink.html#b3e1e57ce7870b2a3dc04be1fd036066">00853</a> <span class="keywordtype">int</span> <a class="code" href="classKPilotDeviceLink.html#b3e1e57ce7870b2a3dc04be1fd036066" title="Fill the DBInfo structure db with information about the next database (in some ordering)...">KPilotDeviceLink::getNextDatabase</a>(<span class="keywordtype">int</span> index, <span class="keyword">struct</span> DBInfo *dbinfo)
<a name="l00854"></a>00854 {
<a name="l00855"></a>00855     FUNCTIONSETUP;
<a name="l00856"></a>00856 
<a name="l00857"></a>00857     pi_buffer_t buf =   { 0, 0, 0 };
<a name="l00858"></a>00858     <span class="keywordtype">int</span> r = dlp_ReadDBList(<a class="code" href="classKPilotDeviceLink.html#8b128f57d6ce5004fc928d5b3ca31542" title="Returns a file handle for raw operations.">pilotSocket</a>(), 0, dlpDBListRAM, index, &amp;buf);
<a name="l00859"></a>00859     <span class="keywordflow">if</span> (r &gt;= 0)
<a name="l00860"></a>00860     {
<a name="l00861"></a>00861         memcpy(dbinfo, buf.data, <span class="keyword">sizeof</span>(<span class="keyword">struct</span> DBInfo));
<a name="l00862"></a>00862     }
<a name="l00863"></a>00863     <span class="keywordflow">return</span> r;
<a name="l00864"></a>00864 }
<a name="l00865"></a>00865 
<a name="l00866"></a>00866 <span class="comment">// Find a database with the given name. Info about the DB is stored into dbinfo (e.g. to be used later on with retrieveDatabase).</span>
<a name="l00867"></a><a class="code" href="classKPilotDeviceLink.html#de0eb7ed274842e4285b85b218b6f292">00867</a> <span class="keywordtype">int</span> <a class="code" href="classKPilotDeviceLink.html#de0eb7ed274842e4285b85b218b6f292" title="Find a database with the given name (and optionally, type type and creator ID (from...">KPilotDeviceLink::findDatabase</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *name, <span class="keyword">struct</span> DBInfo *dbinfo,
<a name="l00868"></a>00868         <span class="keywordtype">int</span> index, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> type, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> creator)
<a name="l00869"></a>00869 {
<a name="l00870"></a>00870     FUNCTIONSETUP;
<a name="l00871"></a>00871     <span class="keywordflow">return</span> dlp_FindDBInfo(<a class="code" href="classKPilotDeviceLink.html#8b128f57d6ce5004fc928d5b3ca31542" title="Returns a file handle for raw operations.">pilotSocket</a>(), 0, index, const_cast&lt;char *&gt;(name),
<a name="l00872"></a>00872             type, creator, dbinfo);
<a name="l00873"></a>00873 }
<a name="l00874"></a>00874 
<a name="l00875"></a><a class="code" href="classKPilotDeviceLink.html#9fc53fd112900f26760a093709b9c82a">00875</a> <span class="keywordtype">bool</span> <a class="code" href="classKPilotDeviceLink.html#9fc53fd112900f26760a093709b9c82a" title="Retrieve the database indicated by DBInfo *db into the local file path.">KPilotDeviceLink::retrieveDatabase</a>(<span class="keyword">const</span> QString &amp;fullBackupName,
<a name="l00876"></a>00876         DBInfo *info)
<a name="l00877"></a>00877 {
<a name="l00878"></a>00878     FUNCTIONSETUP;
<a name="l00879"></a>00879 
<a name="l00880"></a>00880     <span class="keywordflow">if</span> (fullBackupName.isEmpty() || !info)
<a name="l00881"></a>00881     {
<a name="l00882"></a>00882         <span class="comment">// Don't even bother trying to convert or retrieve.</span>
<a name="l00883"></a>00883         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00884"></a>00884     }
<a name="l00885"></a>00885 
<a name="l00886"></a>00886     DEBUGKPILOT &lt;&lt; fname &lt;&lt; <span class="stringliteral">": Writing DB &lt;"</span> &lt;&lt; info-&gt;name &lt;&lt; <span class="stringliteral">"&gt; "</span>
<a name="l00887"></a>00887         &lt;&lt; <span class="stringliteral">" to "</span> &lt;&lt; fullBackupName &lt;&lt; endl;
<a name="l00888"></a>00888 
<a name="l00889"></a>00889     QCString encodedName = QFile::encodeName(fullBackupName);
<a name="l00890"></a>00890     <span class="keyword">struct </span>pi_file *f = pi_file_create(encodedName, info);
<a name="l00891"></a>00891 
<a name="l00892"></a>00892     <span class="keywordflow">if</span> (!f)
<a name="l00893"></a>00893     {
<a name="l00894"></a>00894         WARNINGKPILOT &lt;&lt; <span class="stringliteral">"Failed, unable to create file"</span> &lt;&lt; endl;
<a name="l00895"></a>00895         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00896"></a>00896     }
<a name="l00897"></a>00897 
<a name="l00898"></a>00898     <span class="keywordflow">if</span> (pi_file_retrieve(f, <a class="code" href="classKPilotDeviceLink.html#8b128f57d6ce5004fc928d5b3ca31542" title="Returns a file handle for raw operations.">pilotSocket</a>(), 0, 0L) &lt; 0)
<a name="l00899"></a>00899     {
<a name="l00900"></a>00900         WARNINGKPILOT &lt;&lt; <span class="stringliteral">"Failed, unable to back up database"</span> &lt;&lt; endl;
<a name="l00901"></a>00901 
<a name="l00902"></a>00902         pi_file_close(f);
<a name="l00903"></a>00903         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00904"></a>00904     }
<a name="l00905"></a>00905 
<a name="l00906"></a>00906     pi_file_close(f);
<a name="l00907"></a>00907     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00908"></a>00908 }
<a name="l00909"></a>00909 
<a name="l00910"></a><a class="code" href="classKPilotDeviceLink.html#5878a9b7a49f69b0cb71a0251ee0f412">00910</a> <a class="code" href="classKPilotLink.html#a36b97890b47c51a47d2dcd60a84c1d3" title="A list of DBInfo structures.">KPilotLink::DBInfoList</a> <a class="code" href="classKPilotDeviceLink.html#5878a9b7a49f69b0cb71a0251ee0f412" title="Returns a list of DBInfo structures describing all the databases available on the...">KPilotDeviceLink::getDBList</a>(<span class="keywordtype">int</span> cardno, <span class="keywordtype">int</span> flags)
<a name="l00911"></a>00911 {
<a name="l00912"></a>00912     <span class="keywordtype">bool</span> cont=<span class="keyword">true</span>;
<a name="l00913"></a>00913     <a class="code" href="classKPilotLink.html#a36b97890b47c51a47d2dcd60a84c1d3" title="A list of DBInfo structures.">DBInfoList</a> dbs;
<a name="l00914"></a>00914     <span class="keywordtype">int</span> index=0;
<a name="l00915"></a>00915     <span class="keywordflow">while</span> (cont)
<a name="l00916"></a>00916     {
<a name="l00917"></a>00917         pi_buffer_t buf = { 0, 0, 0 };
<a name="l00918"></a>00918         pi_buffer_clear(&amp;buf);
<a name="l00919"></a>00919         <span class="comment">// DBInfo*dbi=new DBInfo();</span>
<a name="l00920"></a>00920         <span class="keywordflow">if</span> (dlp_ReadDBList(<a class="code" href="classKPilotDeviceLink.html#8b128f57d6ce5004fc928d5b3ca31542" title="Returns a file handle for raw operations.">pilotSocket</a>(), cardno, flags | dlpDBListMultiple,
<a name="l00921"></a>00921                 index, &amp;buf)&lt;0)
<a name="l00922"></a>00922         {
<a name="l00923"></a>00923             cont=<span class="keyword">false</span>;
<a name="l00924"></a>00924         }
<a name="l00925"></a>00925         <span class="keywordflow">else</span>
<a name="l00926"></a>00926         {
<a name="l00927"></a>00927             DBInfo db_n;
<a name="l00928"></a>00928             DBInfo *db_it = (DBInfo *)buf.data;
<a name="l00929"></a>00929             <span class="keywordtype">int</span> info_count = buf.used / <span class="keyword">sizeof</span>(<span class="keyword">struct</span> DBInfo);
<a name="l00930"></a>00930 
<a name="l00931"></a>00931             <span class="keywordflow">while</span> (info_count&gt;0)
<a name="l00932"></a>00932             {
<a name="l00933"></a>00933                 memcpy(&amp;db_n, db_it, <span class="keyword">sizeof</span>(<span class="keyword">struct</span> DBInfo));
<a name="l00934"></a>00934                 ++db_it;
<a name="l00935"></a>00935                 info_count--;
<a name="l00936"></a>00936                 dbs.append(db_n);
<a name="l00937"></a>00937             }
<a name="l00938"></a>00938             index=db_n.index+1;
<a name="l00939"></a>00939         }
<a name="l00940"></a>00940     }
<a name="l00941"></a>00941     <span class="keywordflow">return</span> dbs;
<a name="l00942"></a>00942 }
<a name="l00943"></a>00943 
<a name="l00944"></a><a class="code" href="classKPilotDeviceLink.html#a6dee82037705d799d978b247360b327">00944</a> <span class="keyword">const</span> KPilotCard *<a class="code" href="classKPilotDeviceLink.html#a6dee82037705d799d978b247360b327" title="Retrieve information about the data card card; I don&amp;#39;t think that any pilot supports...">KPilotDeviceLink::getCardInfo</a>(<span class="keywordtype">int</span> card)
<a name="l00945"></a>00945 {
<a name="l00946"></a>00946     KPilotCard *cardinfo=<span class="keyword">new</span> KPilotCard();
<a name="l00947"></a>00947     <span class="keywordflow">if</span> (dlp_ReadStorageInfo(<a class="code" href="classKPilotDeviceLink.html#8b128f57d6ce5004fc928d5b3ca31542" title="Returns a file handle for raw operations.">pilotSocket</a>(), card, cardinfo-&gt;cardInfo())&lt;0)
<a name="l00948"></a>00948     {
<a name="l00949"></a>00949         WARNINGKPILOT &lt;&lt; <span class="stringliteral">"Could not get info for card "</span> &lt;&lt; card &lt;&lt; endl;
<a name="l00950"></a>00950 
<a name="l00951"></a>00951         KPILOT_DELETE(cardinfo);
<a name="l00952"></a>00952         <span class="keywordflow">return</span> 0L;
<a name="l00953"></a>00953     }
<a name="l00954"></a>00954     <span class="keywordflow">return</span> cardinfo;
<a name="l00955"></a>00955 }
<a name="l00956"></a>00956 
<a name="l00957"></a><a class="code" href="classKPilotDeviceLink.html#b7f7e09a732403d532457f87c623fece">00957</a> <a class="code" href="classPilotDatabase.html" title="Methods to access a database on the pilot.">PilotDatabase</a> *<a class="code" href="classKPilotDeviceLink.html#b7f7e09a732403d532457f87c623fece" title="Return a database object for manipulating the database with name name on the link...">KPilotDeviceLink::database</a>(<span class="keyword">const</span> QString &amp;name)
<a name="l00958"></a>00958 {
<a name="l00959"></a>00959     <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classPilotSerialDatabase.html" title="PilotSerialDatabase represents databases stored on the handheld and accessed through...">PilotSerialDatabase</a>( <span class="keyword">this</span>, name );
<a name="l00960"></a>00960 }
<a name="l00961"></a>00961 
<a name="l00962"></a><a class="code" href="classKPilotDeviceLink.html#2bf83ecafe0f72ff4765a11cc0780cd7">00962</a> <a class="code" href="classPilotDatabase.html" title="Methods to access a database on the pilot.">PilotDatabase</a> *<a class="code" href="classKPilotDeviceLink.html#b7f7e09a732403d532457f87c623fece" title="Return a database object for manipulating the database with name name on the link...">KPilotDeviceLink::database</a>(<span class="keyword">const</span> DBInfo *info)
<a name="l00963"></a>00963 {
<a name="l00964"></a>00964     <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classPilotSerialDatabase.html" title="PilotSerialDatabase represents databases stored on the handheld and accessed through...">PilotSerialDatabase</a>( <span class="keyword">this</span>, info );
<a name="l00965"></a>00965 }
<a name="l00966"></a>00966 
</pre></div></div>
    </div></div>


      </td>
  </tr>
  <tr>
    <td valign="top" id="leftmenu" width="25%">
      <a name="navigation"></a>
      <div class="menu_box"><h2>kpilot/lib</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="classActionQueue.html">actionqueue</option>,  <option value="classCleanupAction.html">cleanupaction</option>,  <option value="classConduitAction.html">conduitaction</option>,  <option value="classConduitConfigBase.html">conduitconfigbase</option>,  <option value="classConduitFactory.html">conduitfactory</option>,  <option value="classConduitProxy.html">conduitproxy</option>,  <option value="classCUDCounter.html">cudcounter</option>,  <option value="classDatabaseInterpreter.html">databaseinterpreter</option>,  <option value="classDeviceCommThread.html">devicecommthread</option>,  <option value="classIDMapper.html">idmapper</option>,  <option value="classKPilotDeviceLink.html">kpilotdevicelink</option>,  <option value="classKPilotLink.html">kpilotlink</option>,  <option value="classKPilotLocalLink.html">kpilotlocallink</option>,  <option value="classNullMapper.html">nullmapper</option>,  <option value="classPhoneSlot.html">phoneslot</option>,  <option value="classPilotAddress.html">pilotaddress</option>,  <option value="classPilotAppInfo.html">pilotappinfo</option>,  <option value="classPilotAppInfoBase.html">pilotappinfobase</option>,  <option value="classPilotDatabase.html">pilotdatabase</option>,  <option value="classPilotDateEntry.html">pilotdateentry</option>,  <option value="classPilotLocalDatabase.html">pilotlocaldatabase</option>,  <option value="classPilotRecord.html">pilotrecord</option>,  <option value="classPilotRecordBase.html">pilotrecordbase</option>,  <option value="classPilotSerialDatabase.html">pilotserialdatabase</option>,  <option value="classPilotTodoEntry.html">pilottodoentry</option>,  <option value="classRecordConduitBase.html">recordconduitbase</option>,  <option value="classSorryAction.html">sorryaction</option>,  <option value="classSyncAction_1_1SyncMode.html">syncaction::syncmode</option>,  <option value="classTestLink.html">testlink</option>,  <option value="classWelcomeAction.html">welcomeaction</option>,
</select>
</form>
</div>
-->
</div></div>
<div class="menu_box"><h2>API Dox</h2>
<div class="nav_list">
<ul>
<li><a href="../../../akregator/html/index.html">akregator</a></li><li>&nbsp;&nbsp;<a href="../../../akregator/src/html/index.html">src</a></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../../../akregator/src/librss/html/index.html">librss</a></li><li><a href="../../../certmanager/html/index.html">certmanager</a></li><li>&nbsp;&nbsp;<a href="../../../certmanager/lib/html/index.html">lib</a></li><li><a href="../../../kaddressbook/html/index.html">kaddressbook</a></li><li><a href="../../../kalarm/html/index.html">kalarm</a></li><li>&nbsp;&nbsp;<a href="../../../kalarm/lib/html/index.html">lib</a></li><li><a href="../../../kandy/html/index.html">kandy</a></li><li><a href="../../../karm/html/index.html">karm</a></li><li><a href="../../../kdgantt/html/index.html">kdgantt</a></li><li><a href="../../../kgantt/html/index.html">kgantt</a></li><li><a href="../../../kioslaves/html/index.html">kioslaves</a></li><li>&nbsp;&nbsp;<a href="../../../kioslaves/imap4/html/index.html">imap4</a></li><li>&nbsp;&nbsp;<a href="../../../kioslaves/mbox/html/index.html">mbox</a></li><li><a href="../../../kitchensync/html/index.html">kitchensync</a></li><li><a href="../../../kmail/html/index.html">kmail</a></li><li><a href="../../../knotes/html/index.html">knotes</a></li><li><a href="../../../konsolekalendar/html/index.html">konsolekalendar</a></li><li><a href="../../../kontact/html/index.html">kontact</a></li><li><a href="../../../korganizer/html/index.html">korganizer</a></li><li><a href="../../../kpilot/html/index.html">kpilot</a></li><li>&nbsp;&nbsp;<a href="../../../kpilot/kpilot/html/index.html">kpilot</a></li><li>&nbsp;&nbsp;<a href="../../../kpilot/lib/html/index.html">lib</a></li><li><a href="../../../libemailfunctions/html/index.html">libemailfunctions</a></li><li><a href="../../../libkcal/html/index.html">libkcal</a></li><li><a href="../../../libkdepim/html/index.html">libkdepim</a></li><li><a href="../../../libkholidays/html/index.html">libkholidays</a></li><li><a href="../../../libkmime/html/index.html">libkmime</a></li><li><a href="../../../libkpgp/html/index.html">libkpgp</a></li><li><a href="../../../libkpimidentities/html/index.html">libkpimidentities</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="&#109;&#97;&#105;&#108;&#116;&#111;&#58;groo&#116;&#64;kde&#46;or&#x67;">Adriaan de Groot</a>
and
<a href="&#109;a&#105;&#108;&#116;&#111;&#58;w&#105;nter&#64;kde&#46;or&#x67">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>