~ubuntu-branches/ubuntu/vivid/akonadi/vivid

« back to all changes in this revision

Viewing changes to server/src/akonadiconnection.cpp

  • Committer: Package Import Robot
  • Author(s): Rohan Garg, Rohan Garg, Philip Muškovac
  • Date: 2013-06-13 08:46:15 UTC
  • mfrom: (1.1.42)
  • Revision ID: package-import@ubuntu.com-20130613084615-e37v5pdoe2p2xu9d
Tags: 1.9.80-0ubuntu1
[ Rohan Garg ]
* New upstream release
  - Update symbols
  - Install asapcat with akonadi-server for now
  - Install notificationmessagev2_p.h with -dev package
  - Refresh disable_dbus_requiring_tests.diff

[ Philip Muškovac ]
* libkonadi-dev needs to depend on akonadi-server for the dbus service 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/***************************************************************************
2
2
 *   Copyright (C) 2006 by Till Adam <adam@kde.org>                        *
 
3
 *   Copyright (C) 2013 by Volker Krause <vkrause@kde.org>                 *
3
4
 *                                                                         *
4
5
 *   This program is free software; you can redistribute it and/or modify  *
5
6
 *   it under the terms of the GNU Library General Public License as       *
14
15
 *   You should have received a copy of the GNU Library General Public     *
15
16
 *   License along with this program; if not, write to the                 *
16
17
 *   Free Software Foundation, Inc.,                                       *
17
 
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
 
18
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
18
19
 ***************************************************************************/
19
20
#include "akonadiconnection.h"
20
21
 
21
22
#include <QtCore/QDebug>
22
23
#include <QtCore/QEventLoop>
23
24
#include <QtCore/QLatin1String>
 
25
#include <QSettings>
24
26
 
25
27
#include "storage/datastore.h"
26
28
#include "handler.h"
27
29
#include "response.h"
28
30
#include "tracer.h"
 
31
#include "clientcapabilityaggregator.h"
29
32
 
30
33
#include "imapstreamparser.h"
31
34
#include "shared/akdebug.h"
32
35
#include "shared/akcrash.h"
33
36
 
 
37
#include <akstandarddirs.h>
 
38
 
34
39
#include <assert.h>
35
40
 
36
41
using namespace Akonadi;
48
53
    , m_backend( 0 )
49
54
    , m_selectedConnection( 0 )
50
55
    , m_streamParser( 0 )
 
56
    , m_verifyCacheOnRetrieval(false)
51
57
{
52
58
    m_identifier.sprintf( "%p", static_cast<void*>( this ) );
 
59
    ClientCapabilityAggregator::addSession(m_clientCapabilities);
 
60
 
 
61
    const QSettings settings(AkStandardDirs::serverConfigFile(), QSettings::IniFormat);
 
62
    m_verifyCacheOnRetrieval = settings.value(QLatin1String("Cache/VerifyOnRetrieval"), m_verifyCacheOnRetrieval).toBool();
53
63
}
54
64
 
55
65
DataStore * Akonadi::AkonadiConnection::storageBackend()
62
72
 
63
73
AkonadiConnection::~AkonadiConnection()
64
74
{
 
75
    ClientCapabilityAggregator::removeSession(m_clientCapabilities);
65
76
    Tracer::self()->endConnection( m_identifier, QString() );
66
77
}
67
78
 
97
108
    connect( m_socket, SIGNAL(disconnected()),
98
109
             this, SLOT(slotDisconnected()), Qt::DirectConnection );
99
110
 
100
 
    writeOut( "* OK Akonadi Almost IMAP Server [PROTOCOL 29]");
101
 
 
102
111
    m_streamParser = new ImapStreamParser( m_socket );
103
112
    m_streamParser->setTracerIdentifier( m_identifier );
 
113
 
 
114
    Response greeting;
 
115
    greeting.setUntagged();
 
116
    greeting.setString("OK Akonadi Almost IMAP Server [PROTOCOL 32]");
 
117
    // don't send before the event loop is active, since waitForBytesWritten() can cause interesting reentrancy issues
 
118
    // TODO should be QueueConnection, but unfortunately that doesn't work (yet), since
 
119
    // "this" belongs to the wrong thread, but that requires a slightly larger refactoring
 
120
    QMetaObject::invokeMethod(this, "slotResponseAvailable", Qt::DirectConnection, Q_ARG(Akonadi::Response, greeting));
 
121
 
104
122
    exec();
105
123
    delete m_socket;
106
124
    m_socket = 0;
129
147
      Tracer::self()->connectionInput( m_identifier, (tag + ' ' + command + ' ' + m_streamParser->readRemainingData()) );
130
148
      m_currentHandler = findHandlerForCommand( command );
131
149
      assert( m_currentHandler );
132
 
      connect( m_currentHandler, SIGNAL(responseAvailable(Response)),
133
 
              this, SLOT(slotResponseAvailable(Response)), Qt::DirectConnection );
 
150
      connect( m_currentHandler, SIGNAL(responseAvailable(Akonadi::Response)),
 
151
              this, SLOT(slotResponseAvailable(Akonadi::Response)), Qt::DirectConnection );
134
152
      connect( m_currentHandler, SIGNAL(connectionStateChange(ConnectionState)),
135
153
              this, SLOT(slotConnectionStateChange(ConnectionState)),
136
154
               Qt::DirectConnection );
184
202
Handler * AkonadiConnection::findHandlerForCommand( const QByteArray & command )
185
203
{
186
204
    Handler * handler = Handler::findHandlerForCommandAlwaysAllowed( command );
187
 
    if ( handler ) return handler;
 
205
    if ( handler ) {
 
206
      handler->setConnection( this );
 
207
      return handler;
 
208
    }
188
209
 
189
210
    switch ( m_connectionState ) {
190
211
        case NonAuthenticated:
204
225
    return handler;
205
226
}
206
227
 
207
 
void AkonadiConnection::slotResponseAvailable( const Response& response )
 
228
void AkonadiConnection::slotResponseAvailable( const Akonadi::Response &response )
208
229
{
209
230
    // FIXME handle reentrancy in the presence of continuation. Something like:
210
231
    // "if continuation pending, queue responses, once continuation is done, replay them"
311
332
  return false;
312
333
}
313
334
 
 
335
const ClientCapabilities& AkonadiConnection::capabilities() const
 
336
{
 
337
  return m_clientCapabilities;
 
338
}
 
339
 
 
340
void AkonadiConnection::setCapabilities(const ClientCapabilities& capabilities)
 
341
{
 
342
  ClientCapabilityAggregator::removeSession(m_clientCapabilities);
 
343
  m_clientCapabilities = capabilities;
 
344
  ClientCapabilityAggregator::addSession(m_clientCapabilities);
 
345
}
 
346
 
 
347
bool AkonadiConnection::verifyCacheOnRetrieval() const
 
348
{
 
349
  return m_verifyCacheOnRetrieval;
 
350
}