<?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>kmail: popaccount.cpp Source File (kmail)</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=".">kmail</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>kmail</h2> <!-- Generated by Doxygen 1.5.5 --> <h1>popaccount.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> This file is part of KMail, the KDE mail client.</span> <a name="l00003"></a>00003 <span class="comment"> Copyright (c) 2000 Don Sanders <sanders@kde.org></span> <a name="l00004"></a>00004 <span class="comment"></span> <a name="l00005"></a>00005 <span class="comment"> Based on popaccount by:</span> <a name="l00006"></a>00006 <span class="comment"> Stefan Taferner <taferner@kde.org></span> <a name="l00007"></a>00007 <span class="comment"> Markus Wuebben <markus.wuebben@kde.org></span> <a name="l00008"></a>00008 <span class="comment"></span> <a name="l00009"></a>00009 <span class="comment"> KMail is free software; you can redistribute it and/or modify it</span> <a name="l00010"></a>00010 <span class="comment"> under the terms of the GNU General Public License, version 2, as</span> <a name="l00011"></a>00011 <span class="comment"> published by the Free Software Foundation.</span> <a name="l00012"></a>00012 <span class="comment"></span> <a name="l00013"></a>00013 <span class="comment"> KMail is distributed in the hope that it will be useful, but</span> <a name="l00014"></a>00014 <span class="comment"> WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00015"></a>00015 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span> <a name="l00016"></a>00016 <span class="comment"> General Public License for more details.</span> <a name="l00017"></a>00017 <span class="comment"></span> <a name="l00018"></a>00018 <span class="comment"> You should have received a copy of the GNU General Public License</span> <a name="l00019"></a>00019 <span class="comment"> along with this program; if not, write to the Free Software</span> <a name="l00020"></a>00020 <span class="comment"> Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA</span> <a name="l00021"></a>00021 <span class="comment">*/</span> <a name="l00022"></a>00022 <a name="l00023"></a>00023 <span class="preprocessor">#ifdef HAVE_CONFIG_H</span> <a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#include <config.h></span> <a name="l00025"></a>00025 <span class="preprocessor">#endif</span> <a name="l00026"></a>00026 <span class="preprocessor"></span> <a name="l00027"></a>00027 <span class="preprocessor">#include "popaccount.h"</span> <a name="l00028"></a>00028 <a name="l00029"></a>00029 <span class="preprocessor">#include "broadcaststatus.h"</span> <a name="l00030"></a>00030 <span class="keyword">using</span> KPIM::BroadcastStatus; <a name="l00031"></a>00031 <span class="preprocessor">#include "progressmanager.h"</span> <a name="l00032"></a>00032 <span class="preprocessor">#include "kmfoldermgr.h"</span> <a name="l00033"></a>00033 <span class="preprocessor">#include "kmfiltermgr.h"</span> <a name="l00034"></a>00034 <span class="preprocessor">#include "kmpopfiltercnfrmdlg.h"</span> <a name="l00035"></a>00035 <span class="preprocessor">#include "protocols.h"</span> <a name="l00036"></a>00036 <span class="preprocessor">#include "kmglobal.h"</span> <a name="l00037"></a>00037 <span class="preprocessor">#include "util.h"</span> <a name="l00038"></a>00038 <span class="preprocessor">#include "accountmanager.h"</span> <a name="l00039"></a>00039 <a name="l00040"></a>00040 <span class="preprocessor">#include <kdebug.h></span> <a name="l00041"></a>00041 <span class="preprocessor">#include <kstandarddirs.h></span> <a name="l00042"></a>00042 <span class="preprocessor">#include <klocale.h></span> <a name="l00043"></a>00043 <span class="preprocessor">#include <kmessagebox.h></span> <a name="l00044"></a>00044 <span class="preprocessor">#include <kmainwindow.h></span> <a name="l00045"></a>00045 <span class="preprocessor">#include <kio/scheduler.h></span> <a name="l00046"></a>00046 <span class="preprocessor">#include <kio/passdlg.h></span> <a name="l00047"></a>00047 <span class="preprocessor">#include <kconfig.h></span> <a name="l00048"></a>00048 <span class="keyword">using</span> KIO::MetaData; <a name="l00049"></a>00049 <a name="l00050"></a>00050 <span class="preprocessor">#include <qstylesheet.h></span> <a name="l00051"></a>00051 <a name="l00052"></a>00052 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <span class="keywordtype">int</span> pop3DefaultPort = 110; <a name="l00053"></a>00053 <a name="l00054"></a>00054 <span class="keyword">namespace </span>KMail { <a name="l00055"></a>00055 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00056"></a>00056 PopAccount::PopAccount(AccountManager* aOwner, <span class="keyword">const</span> QString& aAccountName, uint <span class="keywordtype">id</span>) <a name="l00057"></a>00057 : NetworkAccount(aOwner, aAccountName, id), <a name="l00058"></a>00058 headerIt(headersOnServer), <a name="l00059"></a>00059 processMsgsTimer( 0, <span class="stringliteral">"processMsgsTimer"</span> ) <a name="l00060"></a>00060 { <a name="l00061"></a>00061 init(); <a name="l00062"></a>00062 job = 0; <a name="l00063"></a>00063 mSlave = 0; <a name="l00064"></a>00064 mPort = defaultPort(); <a name="l00065"></a>00065 stage = Idle; <a name="l00066"></a>00066 indexOfCurrentMsg = -1; <a name="l00067"></a>00067 curMsgStrm = 0; <a name="l00068"></a>00068 processingDelay = 2*100; <a name="l00069"></a>00069 mProcessing = <span class="keyword">false</span>; <a name="l00070"></a>00070 dataCounter = 0; <a name="l00071"></a>00071 mUidsOfSeenMsgsDict.setAutoDelete( <span class="keyword">false</span> ); <a name="l00072"></a>00072 mUidsOfNextSeenMsgsDict.setAutoDelete( <span class="keyword">false</span> ); <a name="l00073"></a>00073 <a name="l00074"></a>00074 headersOnServer.setAutoDelete(<span class="keyword">true</span>); <a name="l00075"></a>00075 connect(&processMsgsTimer,SIGNAL(timeout()),SLOT(slotProcessPendingMsgs())); <a name="l00076"></a>00076 KIO::Scheduler::connect( <a name="l00077"></a>00077 SIGNAL(slaveError(KIO::Slave *, <span class="keywordtype">int</span>, <span class="keyword">const</span> QString &)), <a name="l00078"></a>00078 <span class="keyword">this</span>, SLOT(slotSlaveError(KIO::Slave *, <span class="keywordtype">int</span>, <span class="keyword">const</span> QString &))); <a name="l00079"></a>00079 <a name="l00080"></a>00080 mHeaderDeleteUids.clear(); <a name="l00081"></a>00081 mHeaderDownUids.clear(); <a name="l00082"></a>00082 mHeaderLaterUids.clear(); <a name="l00083"></a>00083 } <a name="l00084"></a>00084 <a name="l00085"></a>00085 <a name="l00086"></a>00086 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00087"></a>00087 PopAccount::~PopAccount() <a name="l00088"></a>00088 { <a name="l00089"></a>00089 <span class="keywordflow">if</span> (job) { <a name="l00090"></a>00090 job->kill(); <a name="l00091"></a>00091 mMsgsPendingDownload.clear(); <a name="l00092"></a>00092 processRemainingQueuedMessages(); <a name="l00093"></a>00093 saveUidList(); <a name="l00094"></a>00094 } <a name="l00095"></a>00095 } <a name="l00096"></a>00096 <a name="l00097"></a>00097 <a name="l00098"></a>00098 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00099"></a><a class="code" href="classKMail_1_1PopAccount.html#8c5a462bc089423f630c3681e4ca4ca2">00099</a> QString <a class="code" href="classKMail_1_1PopAccount.html#8c5a462bc089423f630c3681e4ca4ca2" title="Inherited methods.">PopAccount::type</a>(<span class="keywordtype">void</span>)<span class="keyword"> const</span> <a name="l00100"></a>00100 <span class="keyword"></span>{ <a name="l00101"></a>00101 <span class="keywordflow">return</span> <span class="stringliteral">"pop"</span>; <a name="l00102"></a>00102 } <a name="l00103"></a>00103 <a name="l00104"></a>00104 QString PopAccount::protocol()<span class="keyword"> const </span>{ <a name="l00105"></a>00105 <span class="keywordflow">return</span> useSSL() ? POP_SSL_PROTOCOL : POP_PROTOCOL; <a name="l00106"></a>00106 } <a name="l00107"></a>00107 <a name="l00108"></a>00108 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <span class="keywordtype">int</span> PopAccount::defaultPort()<span class="keyword"> const </span>{ <a name="l00109"></a>00109 <span class="keywordflow">return</span> pop3DefaultPort; <a name="l00110"></a>00110 } <a name="l00111"></a>00111 <a name="l00112"></a>00112 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00113"></a>00113 <span class="keywordtype">void</span> PopAccount::init(<span class="keywordtype">void</span>) <a name="l00114"></a>00114 { <a name="l00115"></a>00115 NetworkAccount::init(); <a name="l00116"></a>00116 <a name="l00117"></a>00117 mUsePipelining = <span class="keyword">false</span>; <a name="l00118"></a>00118 mLeaveOnServer = <span class="keyword">false</span>; <a name="l00119"></a>00119 mLeaveOnServerDays = -1; <a name="l00120"></a>00120 mLeaveOnServerCount = -1; <a name="l00121"></a>00121 mLeaveOnServerSize = -1; <a name="l00122"></a>00122 mFilterOnServer = <span class="keyword">false</span>; <a name="l00123"></a>00123 <span class="comment">//tz todo</span> <a name="l00124"></a>00124 mFilterOnServerCheckSize = 50000; <a name="l00125"></a>00125 } <a name="l00126"></a>00126 <a name="l00127"></a>00127 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00128"></a><a class="code" href="classKMail_1_1PopAccount.html#60b4ec48af4beff5c3fa3bb66d820aac">00128</a> <span class="keywordtype">void</span> <a class="code" href="classKMail_1_1PopAccount.html#60b4ec48af4beff5c3fa3bb66d820aac" title="A weak assignment operator.">PopAccount::pseudoAssign</a>( <span class="keyword">const</span> KMAccount * a ) { <a name="l00129"></a>00129 <a class="code" href="classKMail_1_1PopAccount.html#ab59c6878e88f8c617e7517a2d9d836b" title="Kills the job if still stage == List.">slotAbortRequested</a>(); <a name="l00130"></a>00130 NetworkAccount::pseudoAssign( a ); <a name="l00131"></a>00131 <a name="l00132"></a>00132 <span class="keyword">const</span> <a class="code" href="classKMail_1_1PopAccount.html" title="KMail account for pop mail account.">PopAccount</a> * p = <span class="keyword">dynamic_cast<</span><span class="keyword">const </span><a class="code" href="classKMail_1_1PopAccount.html" title="KMail account for pop mail account.">PopAccount</a>*<span class="keyword">></span>( a ); <a name="l00133"></a>00133 <span class="keywordflow">if</span> ( !p ) <span class="keywordflow">return</span>; <a name="l00134"></a>00134 <a name="l00135"></a>00135 setUsePipelining( p-><a class="code" href="classKMail_1_1PopAccount.html#2de1d8bbbb00a976f4107a332cc5727d" title="Sending of several commands at once.">usePipelining</a>() ); <a name="l00136"></a>00136 setLeaveOnServer( p-><a class="code" href="classKMail_1_1PopAccount.html#2593a96421b02801ab735682786a846e" title="Shall messages be left on the server upon retreival (TRUE) or deleted (FALSE).">leaveOnServer</a>() ); <a name="l00137"></a>00137 setLeaveOnServerDays( p-><a class="code" href="classKMail_1_1PopAccount.html#a7684e050c97f7130be346291c8cbfb1" title="If value is positive, leave mail on the server for so many days.">leaveOnServerDays</a>() ); <a name="l00138"></a>00138 setLeaveOnServerCount( p-><a class="code" href="classKMail_1_1PopAccount.html#0e4f4fc71660575825586bfd476911bd" title="If value is positive, leave so many messages on the server.">leaveOnServerCount</a>() ); <a name="l00139"></a>00139 setLeaveOnServerSize( p-><a class="code" href="classKMail_1_1PopAccount.html#0a15ba565791cdc99d82debb1e3454ba" title="If value is positive, leave so many MBs on the server.">leaveOnServerSize</a>() ); <a name="l00140"></a>00140 setFilterOnServer( p-><a class="code" href="classKMail_1_1PopAccount.html#07bf2744edbb6ad3a0ff2d13b844af15" title="Shall messages be filter on the server (TRUE) or not (FALSE).">filterOnServer</a>() ); <a name="l00141"></a>00141 setFilterOnServerCheckSize( p-><a class="code" href="classKMail_1_1PopAccount.html#f9ee910c176cd37641947644f453efcc" title="Size of messages which should be check on the pop server before download.">filterOnServerCheckSize</a>() ); <a name="l00142"></a>00142 } <a name="l00143"></a>00143 <a name="l00144"></a>00144 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00145"></a>00145 <span class="keywordtype">void</span> PopAccount::processNewMail(<span class="keywordtype">bool</span> _interactive) <a name="l00146"></a>00146 { <a name="l00147"></a>00147 <span class="keywordflow">if</span> (stage == Idle) { <a name="l00148"></a>00148 <a name="l00149"></a>00149 <span class="keywordflow">if</span> ( (mAskAgain || passwd().isEmpty() || mLogin.isEmpty()) && <a name="l00150"></a>00150 mAuth != <span class="stringliteral">"GSSAPI"</span> ) { <a name="l00151"></a>00151 QString passwd = NetworkAccount::passwd(); <a name="l00152"></a>00152 <span class="keywordtype">bool</span> b = storePasswd(); <a name="l00153"></a>00153 <span class="keywordflow">if</span> (KIO::PasswordDialog::getNameAndPassword(mLogin, passwd, &b, <a name="l00154"></a>00154 i18n(<span class="stringliteral">"You need to supply a username and a password to access this "</span> <a name="l00155"></a>00155 <span class="stringliteral">"mailbox."</span>), <span class="keyword">false</span>, QString::null, mName, i18n(<span class="stringliteral">"Account:"</span>)) <a name="l00156"></a>00156 != QDialog::Accepted) <a name="l00157"></a>00157 { <a name="l00158"></a>00158 checkDone( <span class="keyword">false</span>, CheckAborted ); <a name="l00159"></a>00159 <span class="keywordflow">return</span>; <a name="l00160"></a>00160 } <span class="keywordflow">else</span> { <a name="l00161"></a>00161 setPasswd( passwd, b ); <a name="l00162"></a>00162 <span class="keywordflow">if</span> ( b ) { <a name="l00163"></a>00163 kmkernel->acctMgr()->writeConfig( <span class="keyword">true</span> ); <a name="l00164"></a>00164 } <a name="l00165"></a>00165 mAskAgain = <span class="keyword">false</span>; <a name="l00166"></a>00166 } <a name="l00167"></a>00167 } <a name="l00168"></a>00168 <a name="l00169"></a>00169 QString seenUidList = locateLocal( <span class="stringliteral">"data"</span>, <span class="stringliteral">"kmail/"</span> + mLogin + <span class="stringliteral">":"</span> + <span class="stringliteral">"@"</span> + <a name="l00170"></a>00170 mHost + <span class="stringliteral">":"</span> + QString(<span class="stringliteral">"%1"</span>).arg(mPort) ); <a name="l00171"></a>00171 KConfig config( seenUidList ); <a name="l00172"></a>00172 QStringList uidsOfSeenMsgs = config.readListEntry( <span class="stringliteral">"seenUidList"</span> ); <a name="l00173"></a>00173 QValueList<int> timeOfSeenMsgs = config.readIntListEntry( <span class="stringliteral">"seenUidTimeList"</span> ); <a name="l00174"></a>00174 mUidsOfSeenMsgsDict.clear(); <a name="l00175"></a>00175 mUidsOfSeenMsgsDict.resize( KMail::nextPrime( ( uidsOfSeenMsgs.count() * 11 ) / 10 ) ); <a name="l00176"></a>00176 <span class="keywordtype">int</span> idx = 1; <a name="l00177"></a>00177 <span class="keywordflow">for</span> ( QStringList::ConstIterator it = uidsOfSeenMsgs.begin(); <a name="l00178"></a>00178 it != uidsOfSeenMsgs.end(); ++it, idx++ ) { <a name="l00179"></a>00179 <span class="comment">// we use mUidsOfSeenMsgsDict to just provide fast random access to the</span> <a name="l00180"></a>00180 <span class="comment">// keys, so we can store the index(+1) that corresponds to the index of</span> <a name="l00181"></a>00181 <span class="comment">// mTimeOfSeenMsgsVector for use in PopAccount::slotData()</span> <a name="l00182"></a>00182 mUidsOfSeenMsgsDict.insert( *it, (<span class="keyword">const</span> <span class="keywordtype">int</span> *)idx ); <a name="l00183"></a>00183 } <a name="l00184"></a>00184 mTimeOfSeenMsgsVector.clear(); <a name="l00185"></a>00185 mTimeOfSeenMsgsVector.reserve( timeOfSeenMsgs.size() ); <a name="l00186"></a>00186 <span class="keywordflow">for</span> ( QValueList<int>::ConstIterator it = timeOfSeenMsgs.begin(); <a name="l00187"></a>00187 it != timeOfSeenMsgs.end(); ++it) { <a name="l00188"></a>00188 mTimeOfSeenMsgsVector.append( *it ); <a name="l00189"></a>00189 } <a name="l00190"></a>00190 <span class="comment">// If the counts differ then the config file has presumably been tampered</span> <a name="l00191"></a>00191 <span class="comment">// with and so to avoid possible unwanted message deletion we'll treat</span> <a name="l00192"></a>00192 <span class="comment">// them all as newly seen by clearing the seen times vector</span> <a name="l00193"></a>00193 <span class="keywordflow">if</span> ( mTimeOfSeenMsgsVector.count() != mUidsOfSeenMsgsDict.count() ) <a name="l00194"></a>00194 mTimeOfSeenMsgsVector.clear(); <a name="l00195"></a>00195 QStringList downloadLater = config.readListEntry( <span class="stringliteral">"downloadLater"</span> ); <a name="l00196"></a>00196 <span class="keywordflow">for</span> ( QStringList::Iterator it = downloadLater.begin(); it != downloadLater.end(); ++it ) { <a name="l00197"></a>00197 mHeaderLaterUids.insert( *it, <span class="keyword">true</span> ); <a name="l00198"></a>00198 } <a name="l00199"></a>00199 mUidsOfNextSeenMsgsDict.clear(); <a name="l00200"></a>00200 mTimeOfNextSeenMsgsMap.clear(); <a name="l00201"></a>00201 mSizeOfNextSeenMsgsDict.clear(); <a name="l00202"></a>00202 <a name="l00203"></a>00203 interactive = _interactive; <a name="l00204"></a>00204 mUidlFinished = <span class="keyword">false</span>; <a name="l00205"></a>00205 <a class="code" href="classKMail_1_1PopAccount.html#ae3ceda34b207ec50f38bf047e60905c" title="Start a KIO Job to get a list of messages on the pop server.">startJob</a>(); <a name="l00206"></a>00206 } <a name="l00207"></a>00207 <span class="keywordflow">else</span> { <a name="l00208"></a>00208 checkDone( <span class="keyword">false</span>, CheckIgnored ); <a name="l00209"></a>00209 <span class="keywordflow">return</span>; <a name="l00210"></a>00210 } <a name="l00211"></a>00211 } <a name="l00212"></a>00212 <a name="l00213"></a>00213 <a name="l00214"></a>00214 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00215"></a>00215 <span class="keywordtype">void</span> PopAccount::readConfig(KConfig& config) <a name="l00216"></a>00216 { <a name="l00217"></a>00217 NetworkAccount::readConfig(config); <a name="l00218"></a>00218 <a name="l00219"></a>00219 mUsePipelining = config.readNumEntry(<span class="stringliteral">"pipelining"</span>, <span class="keyword">false</span>); <a name="l00220"></a>00220 mLeaveOnServer = config.readNumEntry(<span class="stringliteral">"leave-on-server"</span>, <span class="keyword">false</span>); <a name="l00221"></a>00221 mLeaveOnServerDays = config.readNumEntry(<span class="stringliteral">"leave-on-server-days"</span>, -1); <a name="l00222"></a>00222 mLeaveOnServerCount = config.readNumEntry(<span class="stringliteral">"leave-on-server-count"</span>, -1); <a name="l00223"></a>00223 mLeaveOnServerSize = config.readNumEntry(<span class="stringliteral">"leave-on-server-size"</span>, -1); <a name="l00224"></a>00224 mFilterOnServer = config.readNumEntry(<span class="stringliteral">"filter-on-server"</span>, <span class="keyword">false</span>); <a name="l00225"></a>00225 mFilterOnServerCheckSize = config.readUnsignedNumEntry(<span class="stringliteral">"filter-os-check-size"</span>, 50000); <a name="l00226"></a>00226 } <a name="l00227"></a>00227 <a name="l00228"></a>00228 <a name="l00229"></a>00229 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00230"></a>00230 <span class="keywordtype">void</span> PopAccount::writeConfig(KConfig& config) <a name="l00231"></a>00231 { <a name="l00232"></a>00232 NetworkAccount::writeConfig(config); <a name="l00233"></a>00233 <a name="l00234"></a>00234 config.writeEntry(<span class="stringliteral">"pipelining"</span>, mUsePipelining); <a name="l00235"></a>00235 config.writeEntry(<span class="stringliteral">"leave-on-server"</span>, mLeaveOnServer); <a name="l00236"></a>00236 config.writeEntry(<span class="stringliteral">"leave-on-server-days"</span>, mLeaveOnServerDays); <a name="l00237"></a>00237 config.writeEntry(<span class="stringliteral">"leave-on-server-count"</span>, mLeaveOnServerCount); <a name="l00238"></a>00238 config.writeEntry(<span class="stringliteral">"leave-on-server-size"</span>, mLeaveOnServerSize); <a name="l00239"></a>00239 config.writeEntry(<span class="stringliteral">"filter-on-server"</span>, mFilterOnServer); <a name="l00240"></a>00240 config.writeEntry(<span class="stringliteral">"filter-os-check-size"</span>, mFilterOnServerCheckSize); <a name="l00241"></a>00241 } <a name="l00242"></a>00242 <a name="l00243"></a>00243 <a name="l00244"></a>00244 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00245"></a>00245 <span class="keywordtype">void</span> PopAccount::setUsePipelining(<span class="keywordtype">bool</span> b) <a name="l00246"></a>00246 { <a name="l00247"></a>00247 mUsePipelining = b; <a name="l00248"></a>00248 } <a name="l00249"></a>00249 <a name="l00250"></a>00250 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00251"></a>00251 <span class="keywordtype">void</span> PopAccount::setLeaveOnServer(<span class="keywordtype">bool</span> b) <a name="l00252"></a>00252 { <a name="l00253"></a>00253 mLeaveOnServer = b; <a name="l00254"></a>00254 } <a name="l00255"></a>00255 <a name="l00256"></a>00256 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00257"></a>00257 <span class="keywordtype">void</span> PopAccount::setLeaveOnServerDays(<span class="keywordtype">int</span> days) <a name="l00258"></a>00258 { <a name="l00259"></a>00259 mLeaveOnServerDays = days; <a name="l00260"></a>00260 } <a name="l00261"></a>00261 <a name="l00262"></a>00262 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00263"></a>00263 <span class="keywordtype">void</span> PopAccount::setLeaveOnServerCount(<span class="keywordtype">int</span> count) <a name="l00264"></a>00264 { <a name="l00265"></a>00265 mLeaveOnServerCount = count; <a name="l00266"></a>00266 } <a name="l00267"></a>00267 <a name="l00268"></a>00268 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00269"></a>00269 <span class="keywordtype">void</span> PopAccount::setLeaveOnServerSize(<span class="keywordtype">int</span> size) <a name="l00270"></a>00270 { <a name="l00271"></a>00271 mLeaveOnServerSize = size; <a name="l00272"></a>00272 } <a name="l00273"></a>00273 <a name="l00274"></a>00274 <span class="comment">//---------------------------------------------------------------------------</span> <a name="l00275"></a>00275 <span class="keywordtype">void</span> PopAccount::setFilterOnServer(<span class="keywordtype">bool</span> b) <a name="l00276"></a>00276 { <a name="l00277"></a>00277 mFilterOnServer = b; <a name="l00278"></a>00278 } <a name="l00279"></a>00279 <a name="l00280"></a>00280 <span class="comment">//---------------------------------------------------------------------------</span> <a name="l00281"></a>00281 <span class="keywordtype">void</span> PopAccount::setFilterOnServerCheckSize(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> aSize) <a name="l00282"></a>00282 { <a name="l00283"></a>00283 mFilterOnServerCheckSize = aSize; <a name="l00284"></a>00284 } <a name="l00285"></a>00285 <a name="l00286"></a>00286 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00287"></a><a class="code" href="classKMail_1_1PopAccount.html#6e7a06fc7c2ad07952973e8218726709">00287</a> <span class="keywordtype">void</span> <a class="code" href="classKMail_1_1PopAccount.html#6e7a06fc7c2ad07952973e8218726709" title="Connect up the standard signals/slots for the KIO Jobs.">PopAccount::connectJob</a>() { <a name="l00288"></a>00288 KIO::Scheduler::assignJobToSlave(mSlave, job); <a name="l00289"></a>00289 connect(job, SIGNAL( data( KIO::Job*, <span class="keyword">const</span> QByteArray &)), <a name="l00290"></a>00290 SLOT( <a class="code" href="classKMail_1_1PopAccount.html#d6f1490999f38147111a0a0f082bf1dd" title="New data has arrived append it to the end of the current message.">slotData</a>( KIO::Job*, <span class="keyword">const</span> QByteArray &))); <a name="l00291"></a>00291 connect(job, SIGNAL( result( KIO::Job * ) ), <a name="l00292"></a>00292 SLOT( <a class="code" href="classKMail_1_1PopAccount.html#9e00e63efc6bb495eafbef7967c3d47c" title="Finished downloading the current kio job, either due to an error or because the job...">slotResult</a>( KIO::Job * ) ) ); <a name="l00293"></a>00293 connect(job, SIGNAL(infoMessage( KIO::Job*, <span class="keyword">const</span> QString & )), <a name="l00294"></a>00294 SLOT( <a class="code" href="classKMail_1_1PopAccount.html#09db52443b8d23d7284bd940096101f4" title="A messages has been retrieved successfully.">slotMsgRetrieved</a>(KIO::Job*, <span class="keyword">const</span> QString &))); <a name="l00295"></a>00295 } <a name="l00296"></a>00296 <a name="l00297"></a>00297 <a name="l00298"></a>00298 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00299"></a><a class="code" href="classKMail_1_1PopAccount.html#2a631452b057e48537dd45bbe3b9ec2a">00299</a> <span class="keywordtype">void</span> <a class="code" href="classKMail_1_1PopAccount.html#2a631452b057e48537dd45bbe3b9ec2a" title="Cleans up after a user cancels the current job.">PopAccount::slotCancel</a>() <a name="l00300"></a>00300 { <a name="l00301"></a>00301 mMsgsPendingDownload.clear(); <a name="l00302"></a>00302 <a class="code" href="classKMail_1_1PopAccount.html#34d8d02f19eccc375c5fa760aa862f9c" title="Process any queued messages.">processRemainingQueuedMessages</a>(); <a name="l00303"></a>00303 <a class="code" href="classKMail_1_1PopAccount.html#a2db747504b4dc541729a0e911fbcdf4" title="Save the list of seen uids for this user/server.">saveUidList</a>(); <a name="l00304"></a>00304 <a class="code" href="classKMail_1_1PopAccount.html#f08e9c11a3001e24e37d93e81647ac0c" title="Called when a job is finished.">slotJobFinished</a>(); <a name="l00305"></a>00305 } <a name="l00306"></a>00306 <a name="l00307"></a>00307 <a name="l00308"></a>00308 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00309"></a><a class="code" href="classKMail_1_1PopAccount.html#1001ff6fc251b82f0fe7544817ce4ec3">00309</a> <span class="keywordtype">void</span> <a class="code" href="classKMail_1_1PopAccount.html#1001ff6fc251b82f0fe7544817ce4ec3" title="Messages are downloaded in the background and then once every x seconds a batch of...">PopAccount::slotProcessPendingMsgs</a>() <a name="l00310"></a>00310 { <a name="l00311"></a>00311 <span class="keywordflow">if</span> (mProcessing) <span class="comment">// not reentrant</span> <a name="l00312"></a>00312 <span class="keywordflow">return</span>; <a name="l00313"></a>00313 mProcessing = <span class="keyword">true</span>; <a name="l00314"></a>00314 <a name="l00315"></a>00315 <span class="keywordtype">bool</span> addedOk; <a name="l00316"></a>00316 QValueList<KMMessage*>::Iterator cur = msgsAwaitingProcessing.begin(); <a name="l00317"></a>00317 QStringList::Iterator curId = msgIdsAwaitingProcessing.begin(); <a name="l00318"></a>00318 QStringList::Iterator curUid = msgUidsAwaitingProcessing.begin(); <a name="l00319"></a>00319 <a name="l00320"></a>00320 <span class="keywordflow">while</span> (cur != msgsAwaitingProcessing.end()) { <a name="l00321"></a>00321 <span class="comment">// note we can actually end up processing events in processNewMsg</span> <a name="l00322"></a>00322 <span class="comment">// this happens when send receipts is turned on</span> <a name="l00323"></a>00323 <span class="comment">// hence the check for re-entry at the start of this method.</span> <a name="l00324"></a>00324 <span class="comment">// -sanders Update processNewMsg should no longer process events</span> <a name="l00325"></a>00325 <a name="l00326"></a>00326 addedOk = processNewMsg(*cur); <span class="comment">//added ok? Error displayed if not.</span> <a name="l00327"></a>00327 <a name="l00328"></a>00328 <span class="keywordflow">if</span> (!addedOk) { <a name="l00329"></a>00329 mMsgsPendingDownload.clear(); <a name="l00330"></a>00330 msgIdsAwaitingProcessing.clear(); <a name="l00331"></a>00331 msgUidsAwaitingProcessing.clear(); <a name="l00332"></a>00332 <span class="keywordflow">break</span>; <a name="l00333"></a>00333 } <a name="l00334"></a>00334 <span class="keywordflow">else</span> { <a name="l00335"></a>00335 idsOfMsgsToDelete.append( *curId ); <a name="l00336"></a>00336 mUidsOfNextSeenMsgsDict.insert( *curUid, (<span class="keyword">const</span> <span class="keywordtype">int</span> *)1 ); <a name="l00337"></a>00337 mTimeOfNextSeenMsgsMap.insert( *curUid, time(0) ); <a name="l00338"></a>00338 } <a name="l00339"></a>00339 ++cur; <a name="l00340"></a>00340 ++curId; <a name="l00341"></a>00341 ++curUid; <a name="l00342"></a>00342 } <a name="l00343"></a>00343 <a name="l00344"></a>00344 msgsAwaitingProcessing.clear(); <a name="l00345"></a>00345 msgIdsAwaitingProcessing.clear(); <a name="l00346"></a>00346 msgUidsAwaitingProcessing.clear(); <a name="l00347"></a>00347 mProcessing = <span class="keyword">false</span>; <a name="l00348"></a>00348 } <a name="l00349"></a>00349 <a name="l00350"></a>00350 <a name="l00351"></a>00351 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00352"></a><a class="code" href="classKMail_1_1PopAccount.html#ab59c6878e88f8c617e7517a2d9d836b">00352</a> <span class="keywordtype">void</span> <a class="code" href="classKMail_1_1PopAccount.html#ab59c6878e88f8c617e7517a2d9d836b" title="Kills the job if still stage == List.">PopAccount::slotAbortRequested</a>() <a name="l00353"></a>00353 { <a name="l00354"></a>00354 <span class="keywordflow">if</span> (stage == Idle) <span class="keywordflow">return</span>; <a name="l00355"></a>00355 <span class="keywordflow">if</span> ( mMailCheckProgressItem ) <a name="l00356"></a>00356 disconnect( mMailCheckProgressItem, SIGNAL( progressItemCanceled( KPIM::ProgressItem* ) ), <a name="l00357"></a>00357 <span class="keyword">this</span>, SLOT( <a class="code" href="classKMail_1_1PopAccount.html#ab59c6878e88f8c617e7517a2d9d836b" title="Kills the job if still stage == List.">slotAbortRequested</a>() ) ); <a name="l00358"></a>00358 stage = Quit; <a name="l00359"></a>00359 <span class="keywordflow">if</span> (job) job->kill(); <a name="l00360"></a>00360 job = 0; <a name="l00361"></a>00361 mSlave = 0; <a name="l00362"></a>00362 <a class="code" href="classKMail_1_1PopAccount.html#2a631452b057e48537dd45bbe3b9ec2a" title="Cleans up after a user cancels the current job.">slotCancel</a>(); <a name="l00363"></a>00363 } <a name="l00364"></a>00364 <a name="l00365"></a>00365 <a name="l00366"></a>00366 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00367"></a><a class="code" href="classKMail_1_1PopAccount.html#ae3ceda34b207ec50f38bf047e60905c">00367</a> <span class="keywordtype">void</span> <a class="code" href="classKMail_1_1PopAccount.html#ae3ceda34b207ec50f38bf047e60905c" title="Start a KIO Job to get a list of messages on the pop server.">PopAccount::startJob</a>() <a name="l00368"></a>00368 { <a name="l00369"></a>00369 <span class="comment">// Run the precommand</span> <a name="l00370"></a>00370 <span class="keywordflow">if</span> (!runPrecommand(precommand())) <a name="l00371"></a>00371 { <a name="l00372"></a>00372 KMessageBox::sorry(0, <a name="l00373"></a>00373 i18n(<span class="stringliteral">"Could not execute precommand: %1"</span>).arg(precommand()), <a name="l00374"></a>00374 i18n(<span class="stringliteral">"KMail Error Message"</span>)); <a name="l00375"></a>00375 checkDone( <span class="keyword">false</span>, CheckError ); <a name="l00376"></a>00376 <span class="keywordflow">return</span>; <a name="l00377"></a>00377 } <a name="l00378"></a>00378 <span class="comment">// end precommand code</span> <a name="l00379"></a>00379 <a name="l00380"></a>00380 KURL url = getUrl(); <a name="l00381"></a>00381 <a name="l00382"></a>00382 <span class="keywordflow">if</span> ( !url.isValid() ) { <a name="l00383"></a>00383 KMessageBox::error(0, i18n(<span class="stringliteral">"Source URL is malformed"</span>), <a name="l00384"></a>00384 i18n(<span class="stringliteral">"Kioslave Error Message"</span>) ); <a name="l00385"></a>00385 <span class="keywordflow">return</span>; <a name="l00386"></a>00386 } <a name="l00387"></a>00387 <a name="l00388"></a>00388 mMsgsPendingDownload.clear(); <a name="l00389"></a>00389 idsOfMsgs.clear(); <a name="l00390"></a>00390 mUidForIdMap.clear(); <a name="l00391"></a>00391 idsOfMsgsToDelete.clear(); <a name="l00392"></a>00392 <span class="comment">//delete any headers if there are some this have to be done because of check again</span> <a name="l00393"></a>00393 headersOnServer.clear(); <a name="l00394"></a>00394 headers = <span class="keyword">false</span>; <a name="l00395"></a>00395 indexOfCurrentMsg = -1; <a name="l00396"></a>00396 <a name="l00397"></a>00397 Q_ASSERT( !mMailCheckProgressItem ); <a name="l00398"></a>00398 QString escapedName = QStyleSheet::escape( mName ); <a name="l00399"></a>00399 mMailCheckProgressItem = KPIM::ProgressManager::createProgressItem( <a name="l00400"></a>00400 <span class="stringliteral">"MailCheck"</span> + mName, <a name="l00401"></a>00401 escapedName, <a name="l00402"></a>00402 i18n(<span class="stringliteral">"Preparing transmission from \"%1\"..."</span>).arg( escapedName ), <a name="l00403"></a>00403 <span class="keyword">true</span>, <span class="comment">// can be canceled</span> <a name="l00404"></a>00404 useSSL() || useTLS() ); <a name="l00405"></a>00405 connect( mMailCheckProgressItem, SIGNAL( progressItemCanceled( KPIM::ProgressItem* ) ), <a name="l00406"></a>00406 <span class="keyword">this</span>, SLOT( <a class="code" href="classKMail_1_1PopAccount.html#ab59c6878e88f8c617e7517a2d9d836b" title="Kills the job if still stage == List.">slotAbortRequested</a>() ) ); <a name="l00407"></a>00407 <a name="l00408"></a>00408 numBytes = 0; <a name="l00409"></a>00409 numBytesRead = 0; <a name="l00410"></a>00410 stage = List; <a name="l00411"></a>00411 mSlave = KIO::Scheduler::getConnectedSlave( url, slaveConfig() ); <a name="l00412"></a>00412 <span class="keywordflow">if</span> (!mSlave) <a name="l00413"></a>00413 { <a name="l00414"></a>00414 <a class="code" href="classKMail_1_1PopAccount.html#e623b2627ce87cea2db8b0f459563d62" title="Slave error handling.">slotSlaveError</a>(0, KIO::ERR_CANNOT_LAUNCH_PROCESS, url.protocol()); <a name="l00415"></a>00415 <span class="keywordflow">return</span>; <a name="l00416"></a>00416 } <a name="l00417"></a>00417 url.setPath(QString(<span class="stringliteral">"/index"</span>)); <a name="l00418"></a>00418 job = KIO::get( url, <span class="keyword">false</span>, <span class="keyword">false</span> ); <a name="l00419"></a>00419 <a class="code" href="classKMail_1_1PopAccount.html#6e7a06fc7c2ad07952973e8218726709" title="Connect up the standard signals/slots for the KIO Jobs.">connectJob</a>(); <a name="l00420"></a>00420 } <a name="l00421"></a>00421 <a name="l00422"></a>00422 MetaData PopAccount::slaveConfig()<span class="keyword"> const </span>{ <a name="l00423"></a>00423 MetaData m = NetworkAccount::slaveConfig(); <a name="l00424"></a>00424 <a name="l00425"></a>00425 m.insert(<span class="stringliteral">"progress"</span>, <span class="stringliteral">"off"</span>); <a name="l00426"></a>00426 m.insert(<span class="stringliteral">"pipelining"</span>, (mUsePipelining) ? <span class="stringliteral">"on"</span> : <span class="stringliteral">"off"</span>); <a name="l00427"></a>00427 <span class="keywordflow">if</span> (mAuth == <span class="stringliteral">"PLAIN"</span> || mAuth == <span class="stringliteral">"LOGIN"</span> || mAuth == <span class="stringliteral">"CRAM-MD5"</span> || <a name="l00428"></a>00428 mAuth == <span class="stringliteral">"DIGEST-MD5"</span> || mAuth == <span class="stringliteral">"NTLM"</span> || mAuth == <span class="stringliteral">"GSSAPI"</span>) { <a name="l00429"></a>00429 m.insert(<span class="stringliteral">"auth"</span>, <span class="stringliteral">"SASL"</span>); <a name="l00430"></a>00430 m.insert(<span class="stringliteral">"sasl"</span>, mAuth); <a name="l00431"></a>00431 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( mAuth == <span class="stringliteral">"*"</span> ) <a name="l00432"></a>00432 m.insert(<span class="stringliteral">"auth"</span>, <span class="stringliteral">"USER"</span>); <a name="l00433"></a>00433 <span class="keywordflow">else</span> <a name="l00434"></a>00434 m.insert(<span class="stringliteral">"auth"</span>, mAuth); <a name="l00435"></a>00435 <a name="l00436"></a>00436 <span class="keywordflow">return</span> m; <a name="l00437"></a>00437 } <a name="l00438"></a>00438 <a name="l00439"></a>00439 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00440"></a>00440 <span class="comment">// one message is finished</span> <a name="l00441"></a>00441 <span class="comment">// add data to a KMMessage</span> <a name="l00442"></a><a class="code" href="classKMail_1_1PopAccount.html#09db52443b8d23d7284bd940096101f4">00442</a> <span class="keywordtype">void</span> <a class="code" href="classKMail_1_1PopAccount.html#09db52443b8d23d7284bd940096101f4" title="A messages has been retrieved successfully.">PopAccount::slotMsgRetrieved</a>(KIO::Job*, <span class="keyword">const</span> QString & infoMsg) <a name="l00443"></a>00443 { <a name="l00444"></a>00444 <span class="keywordflow">if</span> (infoMsg != <span class="stringliteral">"message complete"</span>) <span class="keywordflow">return</span>; <a name="l00445"></a>00445 <a class="code" href="classKMMessage.html" title="This is a Mime Message.">KMMessage</a> *msg = <span class="keyword">new</span> <a class="code" href="classKMMessage.html" title="This is a Mime Message.">KMMessage</a>; <a name="l00446"></a>00446 msg-><a class="code" href="classKMMessage.html#abd4c5528d72e909766b5aff2bb4ac68" title="Set if the message is a complete message.">setComplete</a>(<span class="keyword">true</span>); <a name="l00447"></a>00447 <span class="comment">// Make sure to use LF as line ending to make the processing easier</span> <a name="l00448"></a>00448 <span class="comment">// when piping through external programs</span> <a name="l00449"></a>00449 uint newSize = <a class="code" href="namespaceKMail_1_1Util.html#fd680b9adf53e03ccf6c814da9106d0a" title="Convert all sequences of &quot;\r\n&quot; (carriage return followed by a line feed)...">Util::crlf2lf</a>( curMsgData.data(), curMsgData.size() ); <a name="l00450"></a>00450 curMsgData.resize( newSize ); <a name="l00451"></a>00451 msg-><a class="code" href="classKMMessage.html#087fec453773583f1952aadbe4f537e7">fromByteArray</a>( curMsgData , <span class="keyword">true</span> ); <a name="l00452"></a>00452 <span class="keywordflow">if</span> (stage == Head) <a name="l00453"></a>00453 { <a name="l00454"></a>00454 <span class="keywordtype">int</span> size = mMsgsPendingDownload[ headerIt.current()->id() ]; <a name="l00455"></a>00455 kdDebug(5006) << <span class="stringliteral">"Size of Message: "</span> << size << endl; <a name="l00456"></a>00456 msg-><a class="code" href="classKMMessage.html#0f30bda0dd87b037d0f571058839a4cc">setMsgLength</a>( size ); <a name="l00457"></a>00457 headerIt.current()->setHeader(msg); <a name="l00458"></a>00458 ++headerIt; <a name="l00459"></a>00459 <a class="code" href="classKMail_1_1PopAccount.html#d2269660cc794c2ce64f68236fb913b0" title="If there are more headers to be downloaded then start a new kio job to get the next...">slotGetNextHdr</a>(); <a name="l00460"></a>00460 } <span class="keywordflow">else</span> { <a name="l00461"></a>00461 <span class="comment">//kdDebug(5006) << kfuncinfo << "stage == Retr" << endl;</span> <a name="l00462"></a>00462 <span class="comment">//kdDebug(5006) << "curMsgData.size() = " << curMsgData.size() << endl;</span> <a name="l00463"></a>00463 msg-><a class="code" href="classKMMessage.html#0f30bda0dd87b037d0f571058839a4cc">setMsgLength</a>( curMsgData.size() ); <a name="l00464"></a>00464 msgsAwaitingProcessing.append(msg); <a name="l00465"></a>00465 msgIdsAwaitingProcessing.append(idsOfMsgs[indexOfCurrentMsg]); <a name="l00466"></a>00466 msgUidsAwaitingProcessing.append( mUidForIdMap[idsOfMsgs[indexOfCurrentMsg]] ); <a name="l00467"></a>00467 <a class="code" href="classKMail_1_1PopAccount.html#f66a08e4edca22f91d8fd3909c301816" title="If there are more messages to be downloaded then start a new kio job to get the message...">slotGetNextMsg</a>(); <a name="l00468"></a>00468 } <a name="l00469"></a>00469 } <a name="l00470"></a>00470 <a name="l00471"></a>00471 <a name="l00472"></a>00472 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00473"></a>00473 <span class="comment">// finit state machine to cycle trow the stages</span> <a name="l00474"></a><a class="code" href="classKMail_1_1PopAccount.html#f08e9c11a3001e24e37d93e81647ac0c">00474</a> <span class="keywordtype">void</span> <a class="code" href="classKMail_1_1PopAccount.html#f08e9c11a3001e24e37d93e81647ac0c" title="Called when a job is finished.">PopAccount::slotJobFinished</a>() { <a name="l00475"></a>00475 QStringList emptyList; <a name="l00476"></a>00476 <span class="keywordflow">if</span> (stage == List) { <a name="l00477"></a>00477 kdDebug(5006) << k_funcinfo << <span class="stringliteral">"stage == List"</span> << endl; <a name="l00478"></a>00478 <span class="comment">// set the initial size of mUidsOfNextSeenMsgsDict to the number of</span> <a name="l00479"></a>00479 <span class="comment">// messages on the server + 10%</span> <a name="l00480"></a>00480 mUidsOfNextSeenMsgsDict.resize( KMail::nextPrime( ( idsOfMsgs.count() * 11 ) / 10 ) ); <a name="l00481"></a>00481 KURL url = getUrl(); <a name="l00482"></a>00482 url.setPath(QString(<span class="stringliteral">"/uidl"</span>)); <a name="l00483"></a>00483 job = KIO::get( url, <span class="keyword">false</span>, <span class="keyword">false</span> ); <a name="l00484"></a>00484 <a class="code" href="classKMail_1_1PopAccount.html#6e7a06fc7c2ad07952973e8218726709" title="Connect up the standard signals/slots for the KIO Jobs.">connectJob</a>(); <a name="l00485"></a>00485 stage = Uidl; <a name="l00486"></a>00486 } <a name="l00487"></a>00487 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (stage == Uidl) { <a name="l00488"></a>00488 kdDebug(5006) << k_funcinfo << <span class="stringliteral">"stage == Uidl"</span> << endl; <a name="l00489"></a>00489 mUidlFinished = <span class="keyword">true</span>; <a name="l00490"></a>00490 <a name="l00491"></a>00491 <span class="keywordflow">if</span> ( mLeaveOnServer && mUidForIdMap.isEmpty() && <a name="l00492"></a>00492 mUidsOfNextSeenMsgsDict.isEmpty() && !idsOfMsgs.isEmpty() ) { <a name="l00493"></a>00493 KMessageBox::sorry(0, i18n(<span class="stringliteral">"Your POP3 server (Account: %1) does not support "</span> <a name="l00494"></a>00494 <span class="stringliteral">"the UIDL command: this command is required to determine, in a reliable way, "</span> <a name="l00495"></a>00495 <span class="stringliteral">"which of the mails on the server KMail has already seen before;\n"</span> <a name="l00496"></a>00496 <span class="stringliteral">"the feature to leave the mails on the server will therefore not "</span> <a name="l00497"></a>00497 <span class="stringliteral">"work properly."</span>).arg(NetworkAccount::name()) ); <a name="l00498"></a>00498 <span class="comment">// An attempt to work around buggy pop servers, these seem to be popular.</span> <a name="l00499"></a>00499 mUidsOfNextSeenMsgsDict = mUidsOfSeenMsgsDict; <a name="l00500"></a>00500 } <a name="l00501"></a>00501 <a name="l00502"></a>00502 <span class="comment">//check if filter on server</span> <a name="l00503"></a>00503 <span class="keywordflow">if</span> (mFilterOnServer == <span class="keyword">true</span>) { <a name="l00504"></a>00504 QMap<QString, int>::Iterator hids; <a name="l00505"></a>00505 <span class="keywordflow">for</span> ( hids = mMsgsPendingDownload.begin(); <a name="l00506"></a>00506 hids != mMsgsPendingDownload.end(); hids++ ) { <a name="l00507"></a>00507 kdDebug(5006) << <span class="stringliteral">"Length: "</span> << hids.data() << endl; <a name="l00508"></a>00508 <span class="comment">//check for mails bigger mFilterOnServerCheckSize</span> <a name="l00509"></a>00509 <span class="keywordflow">if</span> ( (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)hids.data() >= mFilterOnServerCheckSize ) { <a name="l00510"></a>00510 kdDebug(5006) << <span class="stringliteral">"bigger than "</span> << mFilterOnServerCheckSize << endl; <a name="l00511"></a>00511 headersOnServer.append(<span class="keyword">new</span> KMPopHeaders( hids.key(), <a name="l00512"></a>00512 mUidForIdMap[hids.key()], <a name="l00513"></a>00513 Later));<span class="comment">//TODO</span> <a name="l00514"></a>00514 <span class="comment">//set Action if already known</span> <a name="l00515"></a>00515 <span class="keywordflow">if</span>( mHeaderDeleteUids.contains( headersOnServer.current()->uid() ) ) { <a name="l00516"></a>00516 headersOnServer.current()->setAction(Delete); <a name="l00517"></a>00517 } <a name="l00518"></a>00518 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( mHeaderDownUids.contains( headersOnServer.current()->uid() ) ) { <a name="l00519"></a>00519 headersOnServer.current()->setAction(Down); <a name="l00520"></a>00520 } <a name="l00521"></a>00521 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( mHeaderLaterUids.contains( headersOnServer.current()->uid() ) ) { <a name="l00522"></a>00522 headersOnServer.current()->setAction(Later); <a name="l00523"></a>00523 } <a name="l00524"></a>00524 } <a name="l00525"></a>00525 } <a name="l00526"></a>00526 <span class="comment">// delete the uids so that you don't get them twice in the list</span> <a name="l00527"></a>00527 mHeaderDeleteUids.clear(); <a name="l00528"></a>00528 mHeaderDownUids.clear(); <a name="l00529"></a>00529 mHeaderLaterUids.clear(); <a name="l00530"></a>00530 } <a name="l00531"></a>00531 <span class="comment">// kdDebug(5006) << "Num of Msgs to Filter: " << headersOnServer.count() << endl;</span> <a name="l00532"></a>00532 <span class="comment">// if there are mails which should be checkedc download the headers</span> <a name="l00533"></a>00533 <span class="keywordflow">if</span> ((headersOnServer.count() > 0) && (mFilterOnServer == <span class="keyword">true</span>)) { <a name="l00534"></a>00534 headerIt.toFirst(); <a name="l00535"></a>00535 KURL url = getUrl(); <a name="l00536"></a>00536 QString headerIds; <a name="l00537"></a>00537 <span class="keywordflow">while</span> (headerIt.current()) <a name="l00538"></a>00538 { <a name="l00539"></a>00539 headerIds += headerIt.current()->id(); <a name="l00540"></a>00540 <span class="keywordflow">if</span> (!headerIt.atLast()) headerIds += <span class="stringliteral">","</span>; <a name="l00541"></a>00541 ++headerIt; <a name="l00542"></a>00542 } <a name="l00543"></a>00543 headerIt.toFirst(); <a name="l00544"></a>00544 url.setPath(QString(<span class="stringliteral">"/headers/"</span>) + headerIds); <a name="l00545"></a>00545 job = KIO::get( url, <span class="keyword">false</span>, <span class="keyword">false</span> ); <a name="l00546"></a>00546 <a class="code" href="classKMail_1_1PopAccount.html#6e7a06fc7c2ad07952973e8218726709" title="Connect up the standard signals/slots for the KIO Jobs.">connectJob</a>(); <a name="l00547"></a>00547 <a class="code" href="classKMail_1_1PopAccount.html#d2269660cc794c2ce64f68236fb913b0" title="If there are more headers to be downloaded then start a new kio job to get the next...">slotGetNextHdr</a>(); <a name="l00548"></a>00548 stage = Head; <a name="l00549"></a>00549 } <a name="l00550"></a>00550 <span class="keywordflow">else</span> { <a name="l00551"></a>00551 stage = Retr; <a name="l00552"></a>00552 numMsgs = mMsgsPendingDownload.count(); <a name="l00553"></a>00553 numBytesToRead = 0; <a name="l00554"></a>00554 QMap<QString, int>::Iterator len; <a name="l00555"></a>00555 <span class="keywordflow">for</span> ( len = mMsgsPendingDownload.begin(); <a name="l00556"></a>00556 len != mMsgsPendingDownload.end(); len++ ) <a name="l00557"></a>00557 numBytesToRead += len.data(); <a name="l00558"></a>00558 idsOfMsgs = QStringList( mMsgsPendingDownload.keys() ); <a name="l00559"></a>00559 KURL url = getUrl(); <a name="l00560"></a>00560 url.setPath( <span class="stringliteral">"/download/"</span> + idsOfMsgs.join(<span class="stringliteral">","</span>) ); <a name="l00561"></a>00561 job = KIO::get( url, <span class="keyword">false</span>, <span class="keyword">false</span> ); <a name="l00562"></a>00562 <a class="code" href="classKMail_1_1PopAccount.html#6e7a06fc7c2ad07952973e8218726709" title="Connect up the standard signals/slots for the KIO Jobs.">connectJob</a>(); <a name="l00563"></a>00563 <a class="code" href="classKMail_1_1PopAccount.html#f66a08e4edca22f91d8fd3909c301816" title="If there are more messages to be downloaded then start a new kio job to get the message...">slotGetNextMsg</a>(); <a name="l00564"></a>00564 processMsgsTimer.start(processingDelay); <a name="l00565"></a>00565 } <a name="l00566"></a>00566 } <a name="l00567"></a>00567 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (stage == Head) { <a name="l00568"></a>00568 kdDebug(5006) << k_funcinfo << <span class="stringliteral">"stage == Head"</span> << endl; <a name="l00569"></a>00569 <a name="l00570"></a>00570 <span class="comment">// All headers have been downloaded, check which mail you want to get</span> <a name="l00571"></a>00571 <span class="comment">// data is in list headersOnServer</span> <a name="l00572"></a>00572 <a name="l00573"></a>00573 <span class="comment">// check if headers apply to a filter</span> <a name="l00574"></a>00574 <span class="comment">// if set the action of the filter</span> <a name="l00575"></a>00575 KMPopFilterAction action; <a name="l00576"></a>00576 <span class="keywordtype">bool</span> dlgPopup = <span class="keyword">false</span>; <a name="l00577"></a>00577 <span class="keywordflow">for</span> (headersOnServer.first(); headersOnServer.current(); headersOnServer.next()) { <a name="l00578"></a>00578 action = (KMPopFilterAction)kmkernel->popFilterMgr()->process(headersOnServer.current()->header()); <a name="l00579"></a>00579 <span class="comment">//debug todo</span> <a name="l00580"></a>00580 <span class="keywordflow">switch</span> ( action ) { <a name="l00581"></a>00581 <span class="keywordflow">case</span> NoAction: <a name="l00582"></a>00582 kdDebug(5006) << <span class="stringliteral">"PopFilterAction = NoAction"</span> << endl; <a name="l00583"></a>00583 <span class="keywordflow">break</span>; <a name="l00584"></a>00584 <span class="keywordflow">case</span> Later: <a name="l00585"></a>00585 kdDebug(5006) << <span class="stringliteral">"PopFilterAction = Later"</span> << endl; <a name="l00586"></a>00586 <span class="keywordflow">break</span>; <a name="l00587"></a>00587 <span class="keywordflow">case</span> Delete: <a name="l00588"></a>00588 kdDebug(5006) << <span class="stringliteral">"PopFilterAction = Delete"</span> << endl; <a name="l00589"></a>00589 <span class="keywordflow">break</span>; <a name="l00590"></a>00590 <span class="keywordflow">case</span> Down: <a name="l00591"></a>00591 kdDebug(5006) << <span class="stringliteral">"PopFilterAction = Down"</span> << endl; <a name="l00592"></a>00592 <span class="keywordflow">break</span>; <a name="l00593"></a>00593 <span class="keywordflow">default</span>: <a name="l00594"></a>00594 kdDebug(5006) << <span class="stringliteral">"PopFilterAction = default oops!"</span> << endl; <a name="l00595"></a>00595 <span class="keywordflow">break</span>; <a name="l00596"></a>00596 } <a name="l00597"></a>00597 <span class="keywordflow">switch</span> ( action ) { <a name="l00598"></a>00598 <span class="keywordflow">case</span> NoAction: <a name="l00599"></a>00599 <span class="comment">//kdDebug(5006) << "PopFilterAction = NoAction" << endl;</span> <a name="l00600"></a>00600 dlgPopup = <span class="keyword">true</span>; <a name="l00601"></a>00601 <span class="keywordflow">break</span>; <a name="l00602"></a>00602 <span class="keywordflow">case</span> Later: <a name="l00603"></a>00603 <span class="keywordflow">if</span> (kmkernel->popFilterMgr()->showLaterMsgs()) <a name="l00604"></a>00604 dlgPopup = <span class="keyword">true</span>; <a name="l00605"></a>00605 <span class="comment">// fall through</span> <a name="l00606"></a>00606 <span class="keywordflow">default</span>: <a name="l00607"></a>00607 headersOnServer.current()->setAction(action); <a name="l00608"></a>00608 headersOnServer.current()->setRuleMatched(<span class="keyword">true</span>); <a name="l00609"></a>00609 <span class="keywordflow">break</span>; <a name="l00610"></a>00610 } <a name="l00611"></a>00611 } <a name="l00612"></a>00612 <a name="l00613"></a>00613 <span class="comment">// if there are some messages which are not coverd by a filter</span> <a name="l00614"></a>00614 <span class="comment">// show the dialog</span> <a name="l00615"></a>00615 headers = <span class="keyword">true</span>; <a name="l00616"></a>00616 <span class="keywordflow">if</span> (dlgPopup) { <a name="l00617"></a>00617 KMPopFilterCnfrmDlg dlg(&headersOnServer, this->name(), kmkernel->popFilterMgr()->showLaterMsgs()); <a name="l00618"></a>00618 dlg.exec(); <a name="l00619"></a>00619 } <a name="l00620"></a>00620 <a name="l00621"></a>00621 <span class="keywordflow">for</span> (headersOnServer.first(); headersOnServer.current(); headersOnServer.next()) { <a name="l00622"></a>00622 <span class="keywordflow">if</span> (headersOnServer.current()->action() == Delete || <a name="l00623"></a>00623 headersOnServer.current()->action() == Later) { <a name="l00624"></a>00624 <span class="comment">//remove entries from the lists when the mails should not be downloaded</span> <a name="l00625"></a>00625 <span class="comment">//(deleted or downloaded later)</span> <a name="l00626"></a>00626 <span class="keywordflow">if</span> ( mMsgsPendingDownload.contains( headersOnServer.current()->id() ) ) { <a name="l00627"></a>00627 mMsgsPendingDownload.remove( headersOnServer.current()->id() ); <a name="l00628"></a>00628 } <a name="l00629"></a>00629 <span class="keywordflow">if</span> (headersOnServer.current()->action() == Delete) { <a name="l00630"></a>00630 mHeaderDeleteUids.insert(headersOnServer.current()->uid(), <span class="keyword">true</span>); <a name="l00631"></a>00631 mUidsOfNextSeenMsgsDict.insert( headersOnServer.current()->uid(), <a name="l00632"></a>00632 (<span class="keyword">const</span> <span class="keywordtype">int</span> *)1 ); <a name="l00633"></a>00633 idsOfMsgsToDelete.append(headersOnServer.current()->id()); <a name="l00634"></a>00634 mTimeOfNextSeenMsgsMap.insert( headersOnServer.current()->uid(), <a name="l00635"></a>00635 time(0) ); <a name="l00636"></a>00636 } <a name="l00637"></a>00637 <span class="keywordflow">else</span> { <a name="l00638"></a>00638 mHeaderLaterUids.insert(headersOnServer.current()->uid(), <span class="keyword">true</span>); <a name="l00639"></a>00639 } <a name="l00640"></a>00640 } <a name="l00641"></a>00641 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (headersOnServer.current()->action() == Down) { <a name="l00642"></a>00642 mHeaderDownUids.insert(headersOnServer.current()->uid(), <span class="keyword">true</span>); <a name="l00643"></a>00643 } <a name="l00644"></a>00644 } <a name="l00645"></a>00645 <a name="l00646"></a>00646 headersOnServer.clear(); <a name="l00647"></a>00647 stage = Retr; <a name="l00648"></a>00648 numMsgs = mMsgsPendingDownload.count(); <a name="l00649"></a>00649 numBytesToRead = 0; <a name="l00650"></a>00650 QMap<QString, int>::Iterator len; <a name="l00651"></a>00651 <span class="keywordflow">for</span> (len = mMsgsPendingDownload.begin(); <a name="l00652"></a>00652 len != mMsgsPendingDownload.end(); len++) <a name="l00653"></a>00653 numBytesToRead += len.data(); <a name="l00654"></a>00654 idsOfMsgs = QStringList( mMsgsPendingDownload.keys() ); <a name="l00655"></a>00655 KURL url = getUrl(); <a name="l00656"></a>00656 url.setPath( <span class="stringliteral">"/download/"</span> + idsOfMsgs.join(<span class="stringliteral">","</span>) ); <a name="l00657"></a>00657 job = KIO::get( url, <span class="keyword">false</span>, <span class="keyword">false</span> ); <a name="l00658"></a>00658 <a class="code" href="classKMail_1_1PopAccount.html#6e7a06fc7c2ad07952973e8218726709" title="Connect up the standard signals/slots for the KIO Jobs.">connectJob</a>(); <a name="l00659"></a>00659 <a class="code" href="classKMail_1_1PopAccount.html#f66a08e4edca22f91d8fd3909c301816" title="If there are more messages to be downloaded then start a new kio job to get the message...">slotGetNextMsg</a>(); <a name="l00660"></a>00660 processMsgsTimer.start(processingDelay); <a name="l00661"></a>00661 } <a name="l00662"></a>00662 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (stage == Retr) { <a name="l00663"></a>00663 <span class="keywordflow">if</span> ( mMailCheckProgressItem ) <a name="l00664"></a>00664 mMailCheckProgressItem->setProgress( 100 ); <a name="l00665"></a>00665 <a class="code" href="classKMail_1_1PopAccount.html#34d8d02f19eccc375c5fa760aa862f9c" title="Process any queued messages.">processRemainingQueuedMessages</a>(); <a name="l00666"></a>00666 <a name="l00667"></a>00667 mHeaderDeleteUids.clear(); <a name="l00668"></a>00668 mHeaderDownUids.clear(); <a name="l00669"></a>00669 mHeaderLaterUids.clear(); <a name="l00670"></a>00670 <a name="l00671"></a>00671 kmkernel->folderMgr()->syncAllFolders(); <a name="l00672"></a>00672 <a name="l00673"></a>00673 KURL url = getUrl(); <a name="l00674"></a>00674 QMap< QPair<time_t, QString>, <span class="keywordtype">int</span> > idsToSave; <a name="l00675"></a>00675 idsToSave.clear(); <a name="l00676"></a>00676 <span class="comment">// Check if we want to keep any messages</span> <a name="l00677"></a>00677 <span class="keywordflow">if</span> ( mLeaveOnServer && !idsOfMsgsToDelete.isEmpty() ) { <a name="l00678"></a>00678 <span class="comment">// Keep all messages on server</span> <a name="l00679"></a>00679 <span class="keywordflow">if</span> ( mLeaveOnServerDays == -1 && mLeaveOnServerCount <= 0 && <a name="l00680"></a>00680 mLeaveOnServerSize <= 0) <a name="l00681"></a>00681 idsOfMsgsToDelete.clear(); <a name="l00682"></a>00682 <span class="comment">// Delete old messages</span> <a name="l00683"></a>00683 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( mLeaveOnServerDays > 0 && !mTimeOfNextSeenMsgsMap.isEmpty() ) { <a name="l00684"></a>00684 time_t timeLimit = time(0) - (86400 * mLeaveOnServerDays); <a name="l00685"></a>00685 kdDebug() << <span class="stringliteral">"timeLimit is "</span> << timeLimit << endl; <a name="l00686"></a>00686 QStringList::Iterator cur = idsOfMsgsToDelete.begin(); <a name="l00687"></a>00687 <span class="keywordflow">for</span> ( ; cur != idsOfMsgsToDelete.end(); ++cur) { <a name="l00688"></a>00688 time_t msgTime = mTimeOfNextSeenMsgsMap[mUidForIdMap[*cur]]; <a name="l00689"></a>00689 kdDebug() << <span class="stringliteral">"id: "</span> << *cur << <span class="stringliteral">" msgTime: "</span> << msgTime << endl; <a name="l00690"></a>00690 <span class="keywordflow">if</span> (msgTime >= timeLimit || <a name="l00691"></a>00691 !mTimeOfNextSeenMsgsMap[mUidForIdMap[*cur]]) { <a name="l00692"></a>00692 kdDebug() << <span class="stringliteral">"Saving msg id "</span> << *cur << endl; <a name="l00693"></a>00693 QPair<time_t, QString> msg(msgTime, *cur); <a name="l00694"></a>00694 idsToSave.insert( msg, 1 ); <a name="l00695"></a>00695 } <a name="l00696"></a>00696 } <a name="l00697"></a>00697 } <a name="l00698"></a>00698 <span class="comment">// Delete more old messages if there are more than mLeaveOnServerCount</span> <a name="l00699"></a>00699 <span class="keywordflow">if</span> ( mLeaveOnServerCount > 0 ) { <a name="l00700"></a>00700 <span class="keywordtype">int</span> numToDelete = idsToSave.count() - mLeaveOnServerCount; <a name="l00701"></a>00701 kdDebug() << <span class="stringliteral">"numToDelete is "</span> << numToDelete << endl; <a name="l00702"></a>00702 <span class="keywordflow">if</span> ( numToDelete > 0 && (<span class="keywordtype">unsigned</span>)numToDelete < idsToSave.count() ) { <a name="l00703"></a>00703 QMap< QPair<time_t, QString>, <span class="keywordtype">int</span> >::Iterator cur = idsToSave.begin(); <a name="l00704"></a>00704 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> deleted = 0; deleted < numToDelete && cur != idsToSave.end() <a name="l00705"></a>00705 ; deleted++, cur++ ) { <a name="l00706"></a>00706 kdDebug() << <span class="stringliteral">"deleting msg id "</span> << cur.key().second << endl; <a name="l00707"></a>00707 idsToSave.remove( cur ); <a name="l00708"></a>00708 } <a name="l00709"></a>00709 } <a name="l00710"></a>00710 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( numToDelete > 0 && (<span class="keywordtype">unsigned</span>)numToDelete >= idsToSave.count() ) <a name="l00711"></a>00711 idsToSave.clear(); <a name="l00712"></a>00712 } <a name="l00713"></a>00713 <span class="comment">// Delete more old messages until we're under mLeaveOnServerSize MBs</span> <a name="l00714"></a>00714 <span class="keywordflow">if</span> ( mLeaveOnServerSize > 0 ) { <a name="l00715"></a>00715 <span class="keywordtype">double</span> sizeOnServer = 0; <a name="l00716"></a>00716 QMap< QPair<time_t, QString>, <span class="keywordtype">int</span> >::Iterator cur = idsToSave.begin(); <a name="l00717"></a>00717 <span class="keywordflow">for</span> ( ; cur != idsToSave.end(); cur++ ) { <a name="l00718"></a>00718 sizeOnServer += <a name="l00719"></a>00719 *mSizeOfNextSeenMsgsDict[ mUidForIdMap[ cur.key().second ] ]; <a name="l00720"></a>00720 } <a name="l00721"></a>00721 kdDebug() << <span class="stringliteral">"sizeOnServer is "</span> << sizeOnServer/(1024*1024) << <span class="stringliteral">"MB"</span> << endl; <a name="l00722"></a>00722 <span class="keywordtype">long</span> limitInBytes = mLeaveOnServerSize * ( 1024 * 1024 ); <a name="l00723"></a>00723 <span class="keywordflow">for</span> ( cur = idsToSave.begin(); cur != idsToSave.end() <a name="l00724"></a>00724 && sizeOnServer > limitInBytes; cur++ ) { <a name="l00725"></a>00725 sizeOnServer -= <a name="l00726"></a>00726 *mSizeOfNextSeenMsgsDict[ mUidForIdMap[ cur.key().second ] ]; <a name="l00727"></a>00727 idsToSave.remove( cur ); <a name="l00728"></a>00728 } <a name="l00729"></a>00729 } <a name="l00730"></a>00730 <span class="comment">// Save msgs from deletion</span> <a name="l00731"></a>00731 QMap< QPair<time_t, QString>, <span class="keywordtype">int</span> >::Iterator it = idsToSave.begin(); <a name="l00732"></a>00732 kdDebug() << <span class="stringliteral">"Going to save "</span> << idsToSave.count() << endl; <a name="l00733"></a>00733 <span class="keywordflow">for</span> ( ; it != idsToSave.end(); ++it ) { <a name="l00734"></a>00734 kdDebug() << <span class="stringliteral">"saving msg id "</span> << it.key().second << endl; <a name="l00735"></a>00735 idsOfMsgsToDelete.remove( it.key().second ); <a name="l00736"></a>00736 } <a name="l00737"></a>00737 } <a name="l00738"></a>00738 <span class="comment">// If there are messages to delete then delete them</span> <a name="l00739"></a>00739 <span class="keywordflow">if</span> ( !idsOfMsgsToDelete.isEmpty() ) { <a name="l00740"></a>00740 stage = Dele; <a name="l00741"></a>00741 <span class="keywordflow">if</span> ( mMailCheckProgressItem ) <a name="l00742"></a>00742 mMailCheckProgressItem->setStatus( <a name="l00743"></a>00743 i18n( <span class="stringliteral">"Fetched 1 message from %1. Deleting messages from server..."</span>, <a name="l00744"></a>00744 <span class="stringliteral">"Fetched %n messages from %1. Deleting messages from server..."</span>, <a name="l00745"></a>00745 numMsgs ) <a name="l00746"></a>00746 .arg( mHost ) ); <a name="l00747"></a>00747 url.setPath(<span class="stringliteral">"/remove/"</span> + idsOfMsgsToDelete.join(<span class="stringliteral">","</span>)); <a name="l00748"></a>00748 kdDebug(5006) << <span class="stringliteral">"url: "</span> << url.prettyURL() << endl; <a name="l00749"></a>00749 } <span class="keywordflow">else</span> { <a name="l00750"></a>00750 stage = Quit; <a name="l00751"></a>00751 <span class="keywordflow">if</span> ( mMailCheckProgressItem ) <a name="l00752"></a>00752 mMailCheckProgressItem->setStatus( <a name="l00753"></a>00753 i18n( <span class="stringliteral">"Fetched 1 message from %1. Terminating transmission..."</span>, <a name="l00754"></a>00754 <span class="stringliteral">"Fetched %n messages from %1. Terminating transmission..."</span>, <a name="l00755"></a>00755 numMsgs ) <a name="l00756"></a>00756 .arg( mHost ) ); <a name="l00757"></a>00757 url.setPath(QString(<span class="stringliteral">"/commit"</span>)); <a name="l00758"></a>00758 kdDebug(5006) << <span class="stringliteral">"url: "</span> << url.prettyURL() << endl; <a name="l00759"></a>00759 } <a name="l00760"></a>00760 job = KIO::get( url, <span class="keyword">false</span>, <span class="keyword">false</span> ); <a name="l00761"></a>00761 <a class="code" href="classKMail_1_1PopAccount.html#6e7a06fc7c2ad07952973e8218726709" title="Connect up the standard signals/slots for the KIO Jobs.">connectJob</a>(); <a name="l00762"></a>00762 } <a name="l00763"></a>00763 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (stage == Dele) { <a name="l00764"></a>00764 kdDebug(5006) << k_funcinfo << <span class="stringliteral">"stage == Dele"</span> << endl; <a name="l00765"></a>00765 <span class="comment">// remove the uids of all messages which have been deleted</span> <a name="l00766"></a>00766 <span class="keywordflow">for</span> ( QStringList::ConstIterator it = idsOfMsgsToDelete.begin(); <a name="l00767"></a>00767 it != idsOfMsgsToDelete.end(); ++it ) { <a name="l00768"></a>00768 mUidsOfNextSeenMsgsDict.remove( mUidForIdMap[*it] ); <a name="l00769"></a>00769 } <a name="l00770"></a>00770 idsOfMsgsToDelete.clear(); <a name="l00771"></a>00771 <span class="keywordflow">if</span> ( mMailCheckProgressItem ) <a name="l00772"></a>00772 mMailCheckProgressItem->setStatus( <a name="l00773"></a>00773 i18n( <span class="stringliteral">"Fetched 1 message from %1. Terminating transmission..."</span>, <a name="l00774"></a>00774 <span class="stringliteral">"Fetched %n messages from %1. Terminating transmission..."</span>, <a name="l00775"></a>00775 numMsgs ) <a name="l00776"></a>00776 .arg( mHost ) ); <a name="l00777"></a>00777 KURL url = getUrl(); <a name="l00778"></a>00778 url.setPath(QString(<span class="stringliteral">"/commit"</span>)); <a name="l00779"></a>00779 job = KIO::get( url, <span class="keyword">false</span>, <span class="keyword">false</span> ); <a name="l00780"></a>00780 stage = Quit; <a name="l00781"></a>00781 <a class="code" href="classKMail_1_1PopAccount.html#6e7a06fc7c2ad07952973e8218726709" title="Connect up the standard signals/slots for the KIO Jobs.">connectJob</a>(); <a name="l00782"></a>00782 } <a name="l00783"></a>00783 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (stage == Quit) { <a name="l00784"></a>00784 kdDebug(5006) << k_funcinfo << <span class="stringliteral">"stage == Quit"</span> << endl; <a name="l00785"></a>00785 <a class="code" href="classKMail_1_1PopAccount.html#a2db747504b4dc541729a0e911fbcdf4" title="Save the list of seen uids for this user/server.">saveUidList</a>(); <a name="l00786"></a>00786 job = 0; <a name="l00787"></a>00787 <span class="keywordflow">if</span> (mSlave) KIO::Scheduler::disconnectSlave(mSlave); <a name="l00788"></a>00788 mSlave = 0; <a name="l00789"></a>00789 stage = Idle; <a name="l00790"></a>00790 <span class="keywordflow">if</span>( mMailCheckProgressItem ) { <span class="comment">// do this only once...</span> <a name="l00791"></a>00791 <span class="keywordtype">bool</span> canceled = !kmkernel || kmkernel->mailCheckAborted() || mMailCheckProgressItem->canceled(); <a name="l00792"></a>00792 <span class="keywordtype">int</span> numMessages = canceled ? indexOfCurrentMsg : idsOfMsgs.count(); <a name="l00793"></a>00793 BroadcastStatus::instance()->setStatusMsgTransmissionCompleted( <a name="l00794"></a>00794 this->name(), numMessages, numBytes, numBytesRead, numBytesToRead, mLeaveOnServer, mMailCheckProgressItem ); <a name="l00795"></a>00795 <span class="comment">// set mMailCheckProgressItem = 0 before calling setComplete() to prevent</span> <a name="l00796"></a>00796 <span class="comment">// a race condition</span> <a name="l00797"></a>00797 ProgressItem *savedMailCheckProgressItem = mMailCheckProgressItem; <a name="l00798"></a>00798 mMailCheckProgressItem = 0; <a name="l00799"></a>00799 savedMailCheckProgressItem->setComplete(); <span class="comment">// that will delete it</span> <a name="l00800"></a>00800 checkDone( ( numMessages > 0 ), canceled ? CheckAborted : CheckOK ); <a name="l00801"></a>00801 } <a name="l00802"></a>00802 } <a name="l00803"></a>00803 } <a name="l00804"></a>00804 <a name="l00805"></a>00805 <a name="l00806"></a>00806 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00807"></a><a class="code" href="classKMail_1_1PopAccount.html#34d8d02f19eccc375c5fa760aa862f9c">00807</a> <span class="keywordtype">void</span> <a class="code" href="classKMail_1_1PopAccount.html#34d8d02f19eccc375c5fa760aa862f9c" title="Process any queued messages.">PopAccount::processRemainingQueuedMessages</a>() <a name="l00808"></a>00808 { <a name="l00809"></a>00809 kdDebug(5006) << k_funcinfo << endl; <a name="l00810"></a>00810 <a class="code" href="classKMail_1_1PopAccount.html#1001ff6fc251b82f0fe7544817ce4ec3" title="Messages are downloaded in the background and then once every x seconds a batch of...">slotProcessPendingMsgs</a>(); <span class="comment">// Force processing of any messages still in the queue</span> <a name="l00811"></a>00811 processMsgsTimer.stop(); <a name="l00812"></a>00812 <a name="l00813"></a>00813 stage = Quit; <a name="l00814"></a>00814 <span class="keywordflow">if</span> ( kmkernel && kmkernel->folderMgr() ) { <a name="l00815"></a>00815 kmkernel->folderMgr()->syncAllFolders(); <a name="l00816"></a>00816 } <a name="l00817"></a>00817 } <a name="l00818"></a>00818 <a name="l00819"></a>00819 <a name="l00820"></a>00820 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00821"></a><a class="code" href="classKMail_1_1PopAccount.html#a2db747504b4dc541729a0e911fbcdf4">00821</a> <span class="keywordtype">void</span> <a class="code" href="classKMail_1_1PopAccount.html#a2db747504b4dc541729a0e911fbcdf4" title="Save the list of seen uids for this user/server.">PopAccount::saveUidList</a>() <a name="l00822"></a>00822 { <a name="l00823"></a>00823 kdDebug(5006) << k_funcinfo << endl; <a name="l00824"></a>00824 <span class="comment">// Don't update the seen uid list unless we successfully got</span> <a name="l00825"></a>00825 <span class="comment">// a new list from the server</span> <a name="l00826"></a>00826 <span class="keywordflow">if</span> (!mUidlFinished) <span class="keywordflow">return</span>; <a name="l00827"></a>00827 <a name="l00828"></a>00828 QStringList uidsOfNextSeenMsgs; <a name="l00829"></a>00829 QValueList<int> seenUidTimeList; <a name="l00830"></a>00830 QDictIterator<int> it( mUidsOfNextSeenMsgsDict ); <a name="l00831"></a>00831 <span class="keywordflow">for</span>( ; it.current(); ++it ) { <a name="l00832"></a>00832 uidsOfNextSeenMsgs.append( it.currentKey() ); <a name="l00833"></a>00833 seenUidTimeList.append( mTimeOfNextSeenMsgsMap[it.currentKey()] ); <a name="l00834"></a>00834 } <a name="l00835"></a>00835 QString seenUidList = locateLocal( <span class="stringliteral">"data"</span>, <span class="stringliteral">"kmail/"</span> + mLogin + <span class="stringliteral">":"</span> + <span class="stringliteral">"@"</span> + <a name="l00836"></a>00836 mHost + <span class="stringliteral">":"</span> + QString(<span class="stringliteral">"%1"</span>).arg(mPort) ); <a name="l00837"></a>00837 KConfig config( seenUidList ); <a name="l00838"></a>00838 config.writeEntry( <span class="stringliteral">"seenUidList"</span>, uidsOfNextSeenMsgs ); <a name="l00839"></a>00839 config.writeEntry( <span class="stringliteral">"seenUidTimeList"</span>, seenUidTimeList ); <a name="l00840"></a>00840 config.writeEntry( <span class="stringliteral">"downloadLater"</span>, QStringList( mHeaderLaterUids.keys() ) ); <a name="l00841"></a>00841 config.sync(); <a name="l00842"></a>00842 } <a name="l00843"></a>00843 <a name="l00844"></a>00844 <a name="l00845"></a>00845 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00846"></a><a class="code" href="classKMail_1_1PopAccount.html#f66a08e4edca22f91d8fd3909c301816">00846</a> <span class="keywordtype">void</span> <a class="code" href="classKMail_1_1PopAccount.html#f66a08e4edca22f91d8fd3909c301816" title="If there are more messages to be downloaded then start a new kio job to get the message...">PopAccount::slotGetNextMsg</a>() <a name="l00847"></a>00847 { <a name="l00848"></a>00848 QMap<QString, int>::Iterator next = mMsgsPendingDownload.begin(); <a name="l00849"></a>00849 <a name="l00850"></a>00850 curMsgData.resize(0); <a name="l00851"></a>00851 numMsgBytesRead = 0; <a name="l00852"></a>00852 curMsgLen = 0; <a name="l00853"></a>00853 <span class="keyword">delete</span> curMsgStrm; <a name="l00854"></a>00854 curMsgStrm = 0; <a name="l00855"></a>00855 <a name="l00856"></a>00856 <span class="keywordflow">if</span> ( next != mMsgsPendingDownload.end() ) { <a name="l00857"></a>00857 <span class="comment">// get the next message</span> <a name="l00858"></a>00858 <span class="keywordtype">int</span> nextLen = next.data(); <a name="l00859"></a>00859 curMsgStrm = <span class="keyword">new</span> QDataStream( curMsgData, IO_WriteOnly ); <a name="l00860"></a>00860 curMsgLen = nextLen; <a name="l00861"></a>00861 ++indexOfCurrentMsg; <a name="l00862"></a>00862 kdDebug(5006) << QString(<span class="stringliteral">"Length of message about to get %1"</span>).arg( nextLen ) << endl; <a name="l00863"></a>00863 mMsgsPendingDownload.remove( next.key() ); <a name="l00864"></a>00864 } <a name="l00865"></a>00865 } <a name="l00866"></a>00866 <a name="l00867"></a>00867 <a name="l00868"></a>00868 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00869"></a><a class="code" href="classKMail_1_1PopAccount.html#d6f1490999f38147111a0a0f082bf1dd">00869</a> <span class="keywordtype">void</span> <a class="code" href="classKMail_1_1PopAccount.html#d6f1490999f38147111a0a0f082bf1dd" title="New data has arrived append it to the end of the current message.">PopAccount::slotData</a>( KIO::Job* job, <span class="keyword">const</span> QByteArray &data) <a name="l00870"></a>00870 { <a name="l00871"></a>00871 <span class="keywordflow">if</span> (data.size() == 0) { <a name="l00872"></a>00872 kdDebug(5006) << <span class="stringliteral">"Data: <End>"</span> << endl; <a name="l00873"></a>00873 <span class="keywordflow">if</span> ((stage == Retr) && (numMsgBytesRead < curMsgLen)) <a name="l00874"></a>00874 numBytesRead += curMsgLen - numMsgBytesRead; <a name="l00875"></a>00875 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (stage == Head){ <a name="l00876"></a>00876 kdDebug(5006) << <span class="stringliteral">"Head: <End>"</span> << endl; <a name="l00877"></a>00877 } <a name="l00878"></a>00878 <span class="keywordflow">return</span>; <a name="l00879"></a>00879 } <a name="l00880"></a>00880 <a name="l00881"></a>00881 <span class="keywordtype">int</span> oldNumMsgBytesRead = numMsgBytesRead; <a name="l00882"></a>00882 <span class="keywordflow">if</span> (stage == Retr) { <a name="l00883"></a>00883 headers = <span class="keyword">false</span>; <a name="l00884"></a>00884 curMsgStrm->writeRawBytes( data.data(), data.size() ); <a name="l00885"></a>00885 numMsgBytesRead += data.size(); <a name="l00886"></a>00886 <span class="keywordflow">if</span> (numMsgBytesRead > curMsgLen) <a name="l00887"></a>00887 numMsgBytesRead = curMsgLen; <a name="l00888"></a>00888 numBytesRead += numMsgBytesRead - oldNumMsgBytesRead; <a name="l00889"></a>00889 dataCounter++; <a name="l00890"></a>00890 <span class="keywordflow">if</span> ( mMailCheckProgressItem && <a name="l00891"></a>00891 ( dataCounter % 5 == 0 || <a name="l00892"></a>00892 ( indexOfCurrentMsg + 1 == numMsgs && numMsgBytesRead == curMsgLen ) ) ) <a name="l00893"></a>00893 { <a name="l00894"></a>00894 QString msg; <a name="l00895"></a>00895 <span class="keywordflow">if</span> (numBytes != numBytesToRead && mLeaveOnServer) <a name="l00896"></a>00896 { <a name="l00897"></a>00897 msg = i18n(<span class="stringliteral">"Fetching message %1 of %2 (%3 of %4 KB) for %5@%6 "</span> <a name="l00898"></a>00898 <span class="stringliteral">"(%7 KB remain on the server)."</span>) <a name="l00899"></a>00899 .arg(indexOfCurrentMsg+1).arg(numMsgs).arg(numBytesRead/1024) <a name="l00900"></a>00900 .arg(numBytesToRead/1024).arg(mLogin).arg(mHost).arg(numBytes/1024); <a name="l00901"></a>00901 } <a name="l00902"></a>00902 <span class="keywordflow">else</span> <a name="l00903"></a>00903 { <a name="l00904"></a>00904 msg = i18n(<span class="stringliteral">"Fetching message %1 of %2 (%3 of %4 KB) for %5@%6."</span>) <a name="l00905"></a>00905 .arg(indexOfCurrentMsg+1).arg(numMsgs).arg(numBytesRead/1024) <a name="l00906"></a>00906 .arg(numBytesToRead/1024).arg(mLogin).arg(mHost); <a name="l00907"></a>00907 } <a name="l00908"></a>00908 mMailCheckProgressItem->setStatus( msg ); <a name="l00909"></a>00909 mMailCheckProgressItem->setProgress( <a name="l00910"></a>00910 (numBytesToRead <= 100) ? 50 <span class="comment">// We never know what the server tells us</span> <a name="l00911"></a>00911 <span class="comment">// This way of dividing is required for > 21MB of mail</span> <a name="l00912"></a>00912 : (numBytesRead / (numBytesToRead / 100)) ); <a name="l00913"></a>00913 } <a name="l00914"></a>00914 <span class="keywordflow">return</span>; <a name="l00915"></a>00915 } <a name="l00916"></a>00916 <a name="l00917"></a>00917 <span class="keywordflow">if</span> (stage == Head) { <a name="l00918"></a>00918 curMsgStrm->writeRawBytes( data.data(), data.size() ); <a name="l00919"></a>00919 <span class="keywordflow">return</span>; <a name="l00920"></a>00920 } <a name="l00921"></a>00921 <a name="l00922"></a>00922 <span class="comment">// otherwise stage is List Or Uidl</span> <a name="l00923"></a>00923 QString qdata = data; <a name="l00924"></a>00924 qdata = qdata.simplifyWhiteSpace(); <span class="comment">// Workaround for Maillennium POP3/UNIBOX</span> <a name="l00925"></a>00925 <span class="keywordtype">int</span> spc = qdata.find( <span class="charliteral">' '</span> ); <a name="l00926"></a>00926 <span class="keywordflow">if</span> (spc > 0) { <a name="l00927"></a>00927 <span class="keywordflow">if</span> (stage == List) { <a name="l00928"></a>00928 QString length = qdata.mid(spc+1); <a name="l00929"></a>00929 <span class="keywordflow">if</span> (length.find(<span class="charliteral">' '</span>) != -1) length.truncate(length.find(<span class="charliteral">' '</span>)); <a name="l00930"></a>00930 <span class="keywordtype">int</span> len = length.toInt(); <a name="l00931"></a>00931 numBytes += len; <a name="l00932"></a>00932 QString <span class="keywordtype">id</span> = qdata.left(spc); <a name="l00933"></a>00933 idsOfMsgs.append( <span class="keywordtype">id</span> ); <a name="l00934"></a>00934 mMsgsPendingDownload.insert( <span class="keywordtype">id</span>, len ); <a name="l00935"></a>00935 } <a name="l00936"></a>00936 <span class="keywordflow">else</span> { <span class="comment">// stage == Uidl</span> <a name="l00937"></a>00937 <span class="keyword">const</span> QString <span class="keywordtype">id</span> = qdata.left(spc); <a name="l00938"></a>00938 <span class="keyword">const</span> QString uid = qdata.mid(spc + 1); <a name="l00939"></a>00939 <span class="keywordtype">int</span> *size = <span class="keyword">new</span> int; <span class="comment">//malloc(size_of(int));</span> <a name="l00940"></a>00940 *size = mMsgsPendingDownload[id]; <a name="l00941"></a>00941 mSizeOfNextSeenMsgsDict.insert( uid, size ); <a name="l00942"></a>00942 <span class="keywordflow">if</span> ( mUidsOfSeenMsgsDict.find( uid ) != 0 ) { <a name="l00943"></a>00943 <a name="l00944"></a>00944 <span class="keywordflow">if</span> ( mMsgsPendingDownload.contains( <span class="keywordtype">id</span> ) ) { <a name="l00945"></a>00945 mMsgsPendingDownload.remove( <span class="keywordtype">id</span> ); <a name="l00946"></a>00946 } <a name="l00947"></a>00947 <span class="keywordflow">else</span> <a name="l00948"></a>00948 kdDebug(5006) << <span class="stringliteral">"PopAccount::slotData synchronization failure."</span> << endl; <a name="l00949"></a>00949 idsOfMsgsToDelete.append( <span class="keywordtype">id</span> ); <a name="l00950"></a>00950 mUidsOfNextSeenMsgsDict.insert( uid, (<span class="keyword">const</span> <span class="keywordtype">int</span> *)1 ); <a name="l00951"></a>00951 <span class="keywordflow">if</span> ( mTimeOfSeenMsgsVector.empty() ) { <a name="l00952"></a>00952 mTimeOfNextSeenMsgsMap.insert( uid, time(0) ); <a name="l00953"></a>00953 } <a name="l00954"></a>00954 <span class="keywordflow">else</span> { <a name="l00955"></a>00955 <span class="comment">// cast the int* with a long to can convert it to a int, BTW</span> <a name="l00956"></a>00956 <span class="comment">// works with g++-4.0 and amd64</span> <a name="l00957"></a>00957 mTimeOfNextSeenMsgsMap.insert( uid, <a name="l00958"></a>00958 mTimeOfSeenMsgsVector[(<span class="keywordtype">int</span>)( <span class="keywordtype">long</span> )mUidsOfSeenMsgsDict[uid] - 1] ); <a name="l00959"></a>00959 } <a name="l00960"></a>00960 } <a name="l00961"></a>00961 mUidForIdMap.insert( <span class="keywordtype">id</span>, uid ); <a name="l00962"></a>00962 } <a name="l00963"></a>00963 } <a name="l00964"></a>00964 <span class="keywordflow">else</span> { <a name="l00965"></a>00965 stage = Idle; <a name="l00966"></a>00966 <span class="keywordflow">if</span> (job) job->kill(); <a name="l00967"></a>00967 job = 0; <a name="l00968"></a>00968 mSlave = 0; <a name="l00969"></a>00969 KMessageBox::error(0, i18n( <span class="stringliteral">"Unable to complete LIST operation."</span> ), <a name="l00970"></a>00970 i18n(<span class="stringliteral">"Invalid Response From Server"</span>)); <a name="l00971"></a>00971 <span class="keywordflow">return</span>; <a name="l00972"></a>00972 } <a name="l00973"></a>00973 } <a name="l00974"></a>00974 <a name="l00975"></a>00975 <a name="l00976"></a>00976 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l00977"></a><a class="code" href="classKMail_1_1PopAccount.html#9e00e63efc6bb495eafbef7967c3d47c">00977</a> <span class="keywordtype">void</span> <a class="code" href="classKMail_1_1PopAccount.html#9e00e63efc6bb495eafbef7967c3d47c" title="Finished downloading the current kio job, either due to an error or because the job...">PopAccount::slotResult</a>( KIO::Job* ) <a name="l00978"></a>00978 { <a name="l00979"></a>00979 <span class="keywordflow">if</span> (!job) <span class="keywordflow">return</span>; <a name="l00980"></a>00980 <span class="keywordflow">if</span> ( job->error() ) <a name="l00981"></a>00981 { <a name="l00982"></a>00982 <span class="keywordflow">if</span> (interactive) { <a name="l00983"></a>00983 <span class="keywordflow">if</span> (headers) { <span class="comment">// nothing to be done for headers</span> <a name="l00984"></a>00984 idsOfMsgs.clear(); <a name="l00985"></a>00985 } <a name="l00986"></a>00986 <span class="keywordflow">if</span> (stage == Head && job->error() == KIO::ERR_COULD_NOT_READ) <a name="l00987"></a>00987 { <a name="l00988"></a>00988 KMessageBox::error(0, i18n(<span class="stringliteral">"Your server does not support the "</span> <a name="l00989"></a>00989 <span class="stringliteral">"TOP command. Therefore it is not possible to fetch the headers "</span> <a name="l00990"></a>00990 <span class="stringliteral">"of large emails first, before downloading them."</span>)); <a name="l00991"></a>00991 <a class="code" href="classKMail_1_1PopAccount.html#2a631452b057e48537dd45bbe3b9ec2a" title="Cleans up after a user cancels the current job.">slotCancel</a>(); <a name="l00992"></a>00992 <span class="keywordflow">return</span>; <a name="l00993"></a>00993 } <a name="l00994"></a>00994 <span class="comment">// force the dialog to be shown next time the account is checked</span> <a name="l00995"></a>00995 <span class="keywordflow">if</span> (!mStorePasswd) mPasswd = <span class="stringliteral">""</span>; <a name="l00996"></a>00996 job->showErrorDialog(); <a name="l00997"></a>00997 } <a name="l00998"></a>00998 <a class="code" href="classKMail_1_1PopAccount.html#2a631452b057e48537dd45bbe3b9ec2a" title="Cleans up after a user cancels the current job.">slotCancel</a>(); <a name="l00999"></a>00999 } <a name="l01000"></a>01000 <span class="keywordflow">else</span> <a name="l01001"></a>01001 <a class="code" href="classKMail_1_1PopAccount.html#f08e9c11a3001e24e37d93e81647ac0c" title="Called when a job is finished.">slotJobFinished</a>(); <a name="l01002"></a>01002 } <a name="l01003"></a>01003 <a name="l01004"></a>01004 <a name="l01005"></a>01005 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l01006"></a><a class="code" href="classKMail_1_1PopAccount.html#e623b2627ce87cea2db8b0f459563d62">01006</a> <span class="keywordtype">void</span> <a class="code" href="classKMail_1_1PopAccount.html#e623b2627ce87cea2db8b0f459563d62" title="Slave error handling.">PopAccount::slotSlaveError</a>(KIO::Slave *aSlave, <span class="keywordtype">int</span> error, <a name="l01007"></a>01007 <span class="keyword">const</span> QString &errorMsg) <a name="l01008"></a>01008 { <a name="l01009"></a>01009 <span class="keywordflow">if</span> (aSlave != mSlave) <span class="keywordflow">return</span>; <a name="l01010"></a>01010 <span class="keywordflow">if</span> (error == KIO::ERR_SLAVE_DIED) mSlave = 0; <a name="l01011"></a>01011 <a name="l01012"></a>01012 <span class="comment">// explicitely disconnect the slave if the connection went down</span> <a name="l01013"></a>01013 <span class="keywordflow">if</span> ( error == KIO::ERR_CONNECTION_BROKEN && mSlave ) { <a name="l01014"></a>01014 KIO::Scheduler::disconnectSlave( mSlave ); <a name="l01015"></a>01015 mSlave = 0; <a name="l01016"></a>01016 } <a name="l01017"></a>01017 <a name="l01018"></a>01018 <span class="keywordflow">if</span> (interactive && kmkernel) { <a name="l01019"></a>01019 KMessageBox::error(kmkernel->mainWin(), KIO::buildErrorString(error, errorMsg)); <a name="l01020"></a>01020 } <a name="l01021"></a>01021 <a name="l01022"></a>01022 <a name="l01023"></a>01023 stage = Quit; <a name="l01024"></a>01024 <span class="keywordflow">if</span> (error == KIO::ERR_COULD_NOT_LOGIN && !mStorePasswd) <a name="l01025"></a>01025 mAskAgain = <span class="keyword">true</span>; <a name="l01026"></a>01026 <span class="comment">/* We need a timer, otherwise slotSlaveError of the next account is also</span> <a name="l01027"></a>01027 <span class="comment"> executed, if it reuses the slave, because the slave member variable</span> <a name="l01028"></a>01028 <span class="comment"> is changed too early */</span> <a name="l01029"></a>01029 QTimer::singleShot(0, <span class="keyword">this</span>, SLOT(<a class="code" href="classKMail_1_1PopAccount.html#2a631452b057e48537dd45bbe3b9ec2a" title="Cleans up after a user cancels the current job.">slotCancel</a>())); <a name="l01030"></a>01030 } <a name="l01031"></a>01031 <a name="l01032"></a>01032 <span class="comment">//-----------------------------------------------------------------------------</span> <a name="l01033"></a><a class="code" href="classKMail_1_1PopAccount.html#d2269660cc794c2ce64f68236fb913b0">01033</a> <span class="keywordtype">void</span> <a class="code" href="classKMail_1_1PopAccount.html#d2269660cc794c2ce64f68236fb913b0" title="If there are more headers to be downloaded then start a new kio job to get the next...">PopAccount::slotGetNextHdr</a>(){ <a name="l01034"></a>01034 kdDebug(5006) << <span class="stringliteral">"slotGetNextHeader"</span> << endl; <a name="l01035"></a>01035 <a name="l01036"></a>01036 curMsgData.resize(0); <a name="l01037"></a>01037 <span class="keyword">delete</span> curMsgStrm; <a name="l01038"></a>01038 curMsgStrm = 0; <a name="l01039"></a>01039 <a name="l01040"></a>01040 curMsgStrm = <span class="keyword">new</span> QDataStream( curMsgData, IO_WriteOnly ); <a name="l01041"></a>01041 } <a name="l01042"></a>01042 <a name="l01043"></a>01043 <span class="keywordtype">void</span> PopAccount::killAllJobs( <span class="keywordtype">bool</span> ) { <a name="l01044"></a>01044 <span class="comment">// must reimpl., but we don't use it yet</span> <a name="l01045"></a>01045 } <a name="l01046"></a>01046 <a name="l01047"></a>01047 } <span class="comment">// namespace KMail</span> <a name="l01048"></a>01048 <span class="preprocessor">#include "popaccount.moc"</span> </pre></div></div> </div></div> </td> </tr> <tr> <td valign="top" id="leftmenu" width="25%"> <a name="navigation"></a> <div class="menu_box"><h2>kmail</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><li><a href="pages.html">Related Pages</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="classAccountUpdater.html">accountupdater</option>, <option value="classAttachmentModifyCommand.html">attachmentmodifycommand</option>, <option value="classFolderStorage.html">folderstorage</option>, <option value="classKCursorSaver.html">kcursorsaver</option>, <option value="classKleo_1_1KeyResolver.html">kleo::keyresolver</option>, <option value="classKListViewIndexedSearchLine.html">klistviewindexedsearchline</option>, <option value="classKMAcctFolder.html">kmacctfolder</option>, <option value="classKMAcctSelDlg.html">kmacctseldlg</option>, <option value="classKMail_1_1AccountComboBox.html">kmail::accountcombobox</option>, <option value="classKMail_1_1AccountManager.html">kmail::accountmanager</option>, <option value="classKMail_1_1ACLEntryDialog.html">kmail::aclentrydialog</option>, <option value="classKMail_1_1ACLJobs_1_1DeleteACLJob.html">kmail::acljobs::deleteacljob</option>, <option value="classKMail_1_1ACLJobs_1_1GetACLJob.html">kmail::acljobs::getacljob</option>, <option value="classKMail_1_1ACLJobs_1_1GetUserRightsJob.html">kmail::acljobs::getuserrightsjob</option>, <option value="classKMail_1_1ACLJobs_1_1MultiSetACLJob.html">kmail::acljobs::multisetacljob</option>, <option value="classKMail_1_1AnnotationJobs_1_1GetAnnotationJob.html">kmail::annotationjobs::getannotationjob</option>, <option value="classKMail_1_1AnnotationJobs_1_1MultiGetAnnotationJob.html">kmail::annotationjobs::multigetannotationjob</option>, <option value="classKMail_1_1AnnotationJobs_1_1MultiSetAnnotationJob.html">kmail::annotationjobs::multisetannotationjob</option>, <option value="classKMail_1_1AnnotationJobs_1_1MultiUrlGetAnnotationJob.html">kmail::annotationjobs::multiurlgetannotationjob</option>, <option value="classKMail_1_1AntiSpamConfig.html">kmail::antispamconfig</option>, <option value="classKMail_1_1AntiSpamWizard.html">kmail::antispamwizard</option>, <option value="classKMail_1_1AntiSpamWizard_1_1ConfigReader.html">kmail::antispamwizard::configreader</option>, <option value="classKMail_1_1AntiSpamWizard_1_1SpamToolConfig.html">kmail::antispamwizard::spamtoolconfig</option>, <option value="classKMail_1_1Callback.html">kmail::callback</option>, <option value="classKMail_1_1CopyFolderJob.html">kmail::copyfolderjob</option>, <option value="classKMail_1_1DictionaryComboBox.html">kmail::dictionarycombobox</option>, <option value="classKMail_1_1EditorWatcher.html">kmail::editorwatcher</option>, <option value="classKMail_1_1FilterImporterExporter.html">kmail::filterimporterexporter</option>, <option value="classKMail_1_1FilterLog.html">kmail::filterlog</option>, <option value="classKMail_1_1FilterLogDialog.html">kmail::filterlogdialog</option>, <option value="classKMail_1_1FolderDiaACLTab.html">kmail::folderdiaacltab</option>, <option value="classKMail_1_1FolderDiaGeneralTab.html">kmail::folderdiageneraltab</option>, <option value="classKMail_1_1FolderDiaQuotaTab.html">kmail::folderdiaquotatab</option>, <option value="classKMail_1_1FolderDiaTab.html">kmail::folderdiatab</option>, <option value="classKMail_1_1FolderDiaTemplatesTab.html">kmail::folderdiatemplatestab</option>, <option value="classKMail_1_1FolderRequester.html">kmail::folderrequester</option>, <option value="classKMail_1_1HeaderItem.html">kmail::headeritem</option>, <option value="classKMail_1_1HeaderStyle.html">kmail::headerstyle</option>, <option value="classKMail_1_1HtmlStatusBar.html">kmail::htmlstatusbar</option>, <option value="classKMail_1_1HtmlWriter.html">kmail::htmlwriter</option>, <option value="classKMail_1_1IdentityDrag.html">kmail::identitydrag</option>, <option value="classKMail_1_1IdentityListView.html">kmail::identitylistview</option>, <option value="classKMail_1_1IdentityListViewItem.html">kmail::identitylistviewitem</option>, <option value="classKMail_1_1Interface_1_1BodyPart.html">kmail::interface::bodypart</option>, <option value="classKMail_1_1Interface_1_1BodyPartFormatterPlugin.html">kmail::interface::bodypartformatterplugin</option>, <option value="classKMail_1_1Interface_1_1BodyPartMemento.html">kmail::interface::bodypartmemento</option>, <option value="classKMail_1_1Interface_1_1BodyPartURLHandler.html">kmail::interface::bodyparturlhandler</option>, <option value="classKMail_1_1Interface_1_1Observable.html">kmail::interface::observable</option>, <option value="classKMail_1_1Interface_1_1Observer.html">kmail::interface::observer</option>, <option value="classKMail_1_1JobScheduler.html">kmail::jobscheduler</option>, <option value="classKMail_1_1ListJob.html">kmail::listjob</option>, <option value="classKMail_1_1MaildirCompactionJob.html">kmail::maildircompactionjob</option>, <option value="classKMail_1_1MailingList.html">kmail::mailinglist</option>, <option value="classKMail_1_1MboxCompactionJob.html">kmail::mboxcompactionjob</option>, <option value="classKMail_1_1MessageActions.html">kmail::messageactions</option>, <option value="classKMail_1_1MessageCopyHelper.html">kmail::messagecopyhelper</option>, <option value="classKMail_1_1PartNodeBodyPart.html">kmail::partnodebodypart</option>, <option value="classKMail_1_1PopAccount.html">kmail::popaccount</option>, <option value="classKMail_1_1QuotaJobs_1_1GetQuotarootJob.html">kmail::quotajobs::getquotarootjob</option>, <option value="classKMail_1_1QuotaJobs_1_1GetStorageQuotaJob.html">kmail::quotajobs::getstoragequotajob</option>, <option value="classKMail_1_1RedirectDialog.html">kmail::redirectdialog</option>, <option value="classKMail_1_1RenameJob.html">kmail::renamejob</option>, <option value="classKMail_1_1RuleWidgetHandler.html">kmail::rulewidgethandler</option>, <option value="classKMail_1_1RuleWidgetHandlerManager.html">kmail::rulewidgethandlermanager</option>, <option value="classKMail_1_1ScheduledCompactionTask.html">kmail::scheduledcompactiontask</option>, <option value="classKMail_1_1ScheduledExpireTask.html">kmail::scheduledexpiretask</option>, <option value="classKMail_1_1ScheduledJob.html">kmail::scheduledjob</option>, <option value="classKMail_1_1ScheduledTask.html">kmail::scheduledtask</option>, <option value="classKMail_1_1SearchJob.html">kmail::searchjob</option>, <option value="classKMail_1_1SearchWindow.html">kmail::searchwindow</option>, <option value="classKMail_1_1SecondaryWindow.html">kmail::secondarywindow</option>, <option value="classKMail_1_1SieveDebugDialog.html">kmail::sievedebugdialog</option>, <option value="classKMail_1_1SortCacheItem.html">kmail::sortcacheitem</option>, <option value="classKMail_1_1SpamHeaderAnalyzer.html">kmail::spamheaderanalyzer</option>, <option value="classKMail_1_1SpamScore.html">kmail::spamscore</option>, <option value="classKMail_1_1TeeHtmlWriter.html">kmail::teehtmlwriter</option>, <option value="classKMail_1_1TransportManager.html">kmail::transportmanager</option>, <option value="classKMail_1_1UndoInfo.html">kmail::undoinfo</option>, <option value="classKMail_1_1URLHandler.html">kmail::urlhandler</option>, <option value="classKMail_1_1URLHandlerManager.html">kmail::urlhandlermanager</option>, <option value="classKMail_1_1Util_1_1LaterDeleter.html">kmail::util::laterdeleter</option>, <option value="classKMailICalIfaceImpl.html">kmailicalifaceimpl</option>, <option value="classKMailIface.html">kmailiface</option>, <option value="classKMDict.html">kmdict</option>, <option value="classKMDictItem.html">kmdictitem</option>, <option value="classKMFilterAction.html">kmfilteraction</option>, <option value="classKMFilterActionDict.html">kmfilteractiondict</option>, <option value="classKMFilterActionWidget.html">kmfilteractionwidget</option>, <option value="classKMFilterActionWithAddress.html">kmfilteractionwithaddress</option>, <option value="classKMFilterActionWithFolder.html">kmfilteractionwithfolder</option>, <option value="classKMFilterActionWithNone.html">kmfilteractionwithnone</option>, <option value="classKMFilterActionWithString.html">kmfilteractionwithstring</option>, <option value="classKMFilterActionWithStringList.html">kmfilteractionwithstringlist</option>, <option value="classKMFilterActionWithUOID.html">kmfilteractionwithuoid</option>, <option value="classKMFilterActionWithUrl.html">kmfilteractionwithurl</option>, <option value="classKMFilterDlg.html">kmfilterdlg</option>, <option value="classKMFilterListBox.html">kmfilterlistbox</option>, <option value="classKMFolder.html">kmfolder</option>, <option value="classKMFolderDialog.html">kmfolderdialog</option>, <option value="classKMFolderDir.html">kmfolderdir</option>, <option value="classKMFolderIndex.html">kmfolderindex</option>, <option value="classKMFolderOpener.html">kmfolderopener</option>, <option value="classKMHeaders.html">kmheaders</option>, <option value="classKMKernel.html">kmkernel</option>, <option value="classKMMenuCommand.html">kmmenucommand</option>, <option value="classKMMessage.html">kmmessage</option>, <option value="classKMMsgDict.html">kmmsgdict</option>, <option value="classKMMsgList.html">kmmsglist</option>, <option value="classKMMsgPartDialog.html">kmmsgpartdialog</option>, <option value="classKMMsgPartDialogCompat.html">kmmsgpartdialogcompat</option>, <option value="classKMPopHeadersView.html">kmpopheadersview</option>, <option value="classKMReaderWin.html">kmreaderwin</option>, <option value="classKMSearchPattern.html">kmsearchpattern</option>, <option value="classKMSearchPatternEdit.html">kmsearchpatternedit</option>, <option value="classKMSearchRule.html">kmsearchrule</option>, <option value="classKMSearchRuleNumerical.html">kmsearchrulenumerical</option>, <option value="classKMSearchRuleStatus.html">kmsearchrulestatus</option>, <option value="classKMSearchRuleString.html">kmsearchrulestring</option>, <option value="classKMSearchRuleWidget.html">kmsearchrulewidget</option>, <option value="classKMSystemTray.html">kmsystemtray</option>, <option value="classMailComposerIface.html">mailcomposeriface</option>, <option value="classScalix_1_1FolderAttributeParser.html">scalix::folderattributeparser</option>, <option value="classSnippetConfig.html">snippetconfig</option>, <option value="classSnippetGroup.html">snippetgroup</option>, <option value="classSnippetItem.html">snippetitem</option>, <option value="classSnippetSettings.html">snippetsettings</option>, <option value="classSnippetWidget.html">snippetwidget</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> <a href="../../akregator/src/html/index.html">src</a></li><li> <a href="../../akregator/src/librss/html/index.html">librss</a></li><li><a href="../../certmanager/html/index.html">certmanager</a></li><li> <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> <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> <a href="../../kioslaves/imap4/html/index.html">imap4</a></li><li> <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> <a href="../../kpilot/kpilot/html/index.html">kpilot</a></li><li> <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="mailto:groot@kde.org">Adriaan de Groot</a> and <a href="mailto:winter@kde.org">Allen Winter</a>. <br/> KDE and K Desktop Environment are trademarks of <a href="http://www.kde.org/areas/kde-ev/" title="Homepage of the KDE non-profit Organization">KDE e.V.</a> | <a href="http://www.kde.org/contact/impressum.php">Legal</a> </div> <div id="footer_right"><img src="/media/images/footer_right.png" style="margin: 0px" alt="" /></div> </div> <!-- WARNING: DO NOT SEND MAIL TO THE FOLLOWING EMAIL ADDRESS! YOU WILL BE BLOCKED INSTANTLY AND PERMANENTLY! <a href="mailto:aaaatrap-425acc3b5374943f@kde.org">Block me</a> WARNING END --> </body> </html>