summaryrefslogtreecommitdiffstats
path: root/src/libraries/qmfclient/qmailmessageserver.cpp
blob: 6bec1b038c118836e380fabc032130c5537effd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the Qt Messaging Framework.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/

#include "qmailmessageserver.h"
#include <qcopadaptor_p.h>
#include <qcopchannel_p.h>
#include <qcopserver_p.h>

static bool connectIpc( QObject *sender, const QByteArray& signal,
        QObject *receiver, const QByteArray& member)
{
    return QCopAdaptor::connect(sender,signal,receiver,member);
}

class QMF_EXPORT QMailMessageServerPrivate : public QObject
{
    Q_OBJECT

    friend class QMailMessageServer;

public:
    QMailMessageServerPrivate(QMailMessageServer* parent);
    ~QMailMessageServerPrivate();

signals:
    void initialise();

    void transmitMessages(quint64, const QMailAccountId &accountId);
    void transmitMessage(quint64, const QMailMessageId &messageId);

    void retrieveFolderList(quint64, const QMailAccountId &accountId, const QMailFolderId &folderId, bool descending);
    void retrieveMessageLists(quint64, const QMailAccountId &accountId, const QMailFolderIdList &folderIds, uint minimum, const QMailMessageSortKey &sort);
    void retrieveMessageList(quint64, const QMailAccountId &accountId, const QMailFolderId &folderId, uint minimum, const QMailMessageSortKey &sort);
    void retrieveNewMessages(quint64, const QMailAccountId &accountId, const QMailFolderIdList &folderIds);

    void createStandardFolders(quint64, const QMailAccountId &accountId);

    void retrieveMessages(quint64, const QMailMessageIdList &messageIds, QMailRetrievalAction::RetrievalSpecification spec);
    void retrieveMessagePart(quint64, const QMailMessagePart::Location &partLocation);

    void retrieveMessageRange(quint64, const QMailMessageId &messageId, uint minimum);
    void retrieveMessagePartRange(quint64, const QMailMessagePart::Location &partLocation, uint minimum);

    void retrieveAll(quint64, const QMailAccountId &accountId);
    void exportUpdates(quint64, const QMailAccountId &accountId);

    void synchronize(quint64, const QMailAccountId &accountId);

    void onlineCopyMessages(quint64, const QMailMessageIdList& mailList, const QMailFolderId &destination);
    void onlineMoveMessages(quint64, const QMailMessageIdList& mailList, const QMailFolderId &destination);
    void onlineFlagMessagesAndMoveToStandardFolder(quint64, const QMailMessageIdList& mailList, quint64 setMask, quint64 unsetMask);
    void addMessages(quint64, const QString &filename);
    void addMessages(quint64, const QMailMessageMetaDataList &list);
    void updateMessages(quint64, const QString &filename);
    void updateMessages(quint64, const QMailMessageMetaDataList &list);
    void deleteMessages(quint64, const QMailMessageIdList &ids);
    void rollBackUpdates(quint64, const QMailAccountId &mailAccountId);
    void moveToStandardFolder(quint64, const QMailMessageIdList& ids, quint64 standardFolder);
    void moveToFolder(quint64, const QMailMessageIdList& ids, const QMailFolderId& folderId);
    void flagMessages(quint64, const QMailMessageIdList& ids, quint64 setMask, quint64 unsetMask);
    void restoreToPreviousFolder(quint64, const QMailMessageKey& key);
    void onlineCreateFolder(quint64, const QString &name, const QMailAccountId &accountId, const QMailFolderId &parentId);
    void onlineRenameFolder(quint64, const QMailFolderId &folderId, const QString &name);
    void onlineDeleteFolder(quint64, const QMailFolderId &folderId);
    void onlineMoveFolder(quint64, const QMailFolderId &folderId, const QMailFolderId &newParentId);

    void cancelTransfer(quint64);

    void onlineDeleteMessages(quint64, const QMailMessageIdList& id, QMailStore::MessageRemovalOption);

    void searchMessages(quint64, const QMailMessageKey& filter, const QString& bodyText, QMailSearchAction::SearchSpecification spec, const QMailMessageSortKey &sort);
    void searchMessages(quint64, const QMailMessageKey& filter, const QString& bodyText, QMailSearchAction::SearchSpecification spec, quint64 limit, const QMailMessageSortKey &sort);
    void countMessages(quint64, const QMailMessageKey& filter, const QString& bodyText);

    void cancelSearch(quint64);

    void shutdown();

    void listActions();

    void protocolRequest(quint64, const QMailAccountId &accountId, const QString &request, const QVariant &data);

    void acknowledgeNewMessages(const QMailMessageTypeList&);

private:
    QCopAdaptor* adaptor;
};


QMailMessageServerPrivate::QMailMessageServerPrivate(QMailMessageServer* parent)
    : QObject(parent),
      adaptor(new QCopAdaptor(QLatin1String("QPE/QMailMessageServer"), this))
{
    // Forward signals to the message server
    connectIpc(adaptor, MESSAGE(newCountChanged(QMailMessageCountMap)),
               parent, SIGNAL(newCountChanged(QMailMessageCountMap)));
    connectIpc(this, SIGNAL(acknowledgeNewMessages(QMailMessageTypeList)),
               adaptor, MESSAGE(acknowledgeNewMessages(QMailMessageTypeList)));

    connectIpc(this, SIGNAL(initialise()),
               adaptor, MESSAGE(initialise()));
    connectIpc(this, SIGNAL(transmitMessages(quint64, QMailAccountId)),
               adaptor, MESSAGE(transmitMessages(quint64, QMailAccountId)));
    connectIpc(this, SIGNAL(transmitMessage(quint64, QMailMessageId)),
               adaptor, MESSAGE(transmitMessage(quint64, QMailMessageId)));
    connectIpc(this, SIGNAL(retrieveFolderList(quint64, QMailAccountId, QMailFolderId, bool)),
               adaptor, MESSAGE(retrieveFolderList(quint64, QMailAccountId, QMailFolderId, bool)));
    connectIpc(this, SIGNAL(retrieveMessageList(quint64, QMailAccountId, QMailFolderId, uint, QMailMessageSortKey)),
               adaptor, MESSAGE(retrieveMessageList(quint64, QMailAccountId, QMailFolderId, uint, QMailMessageSortKey)));
    connectIpc(this, SIGNAL(retrieveMessageLists(quint64, QMailAccountId, QMailFolderIdList, uint, QMailMessageSortKey)),
               adaptor, MESSAGE(retrieveMessageLists(quint64, QMailAccountId, QMailFolderIdList, uint, QMailMessageSortKey)));
    connectIpc(this, SIGNAL(retrieveNewMessages(quint64, QMailAccountId, QMailFolderIdList)),
               adaptor, MESSAGE(retrieveNewMessages(quint64, QMailAccountId, QMailFolderIdList)));
    connectIpc(this, SIGNAL(createStandardFolders(quint64, QMailAccountId)),
               adaptor, MESSAGE(createStandardFolders(quint64, QMailAccountId)));
    connectIpc(this, SIGNAL(retrieveMessages(quint64, QMailMessageIdList, QMailRetrievalAction::RetrievalSpecification)),
               adaptor, MESSAGE(retrieveMessages(quint64, QMailMessageIdList, QMailRetrievalAction::RetrievalSpecification)));
    connectIpc(this, SIGNAL(retrieveMessagePart(quint64, QMailMessagePart::Location)),
               adaptor, MESSAGE(retrieveMessagePart(quint64, QMailMessagePart::Location)));
    connectIpc(this, SIGNAL(retrieveMessageRange(quint64, QMailMessageId, uint)),
               adaptor, MESSAGE(retrieveMessageRange(quint64, QMailMessageId, uint)));
    connectIpc(this, SIGNAL(retrieveMessagePartRange(quint64, QMailMessagePart::Location, uint)),
               adaptor, MESSAGE(retrieveMessagePartRange(quint64, QMailMessagePart::Location, uint)));
    connectIpc(this, SIGNAL(retrieveAll(quint64, QMailAccountId)),
               adaptor, MESSAGE(retrieveAll(quint64, QMailAccountId)));
    connectIpc(this, SIGNAL(exportUpdates(quint64, QMailAccountId)),
               adaptor, MESSAGE(exportUpdates(quint64, QMailAccountId)));
    connectIpc(this, SIGNAL(synchronize(quint64, QMailAccountId)),
               adaptor, MESSAGE(synchronize(quint64, QMailAccountId)));
    connectIpc(this, SIGNAL(cancelTransfer(quint64)),
               adaptor, MESSAGE(cancelTransfer(quint64)));
    connectIpc(this, SIGNAL(onlineCopyMessages(quint64, QMailMessageIdList, QMailFolderId)),
               adaptor, MESSAGE(onlineCopyMessages(quint64, QMailMessageIdList, QMailFolderId)));
    connectIpc(this, SIGNAL(onlineMoveMessages(quint64, QMailMessageIdList, QMailFolderId)),
               adaptor, MESSAGE(onlineMoveMessages(quint64, QMailMessageIdList, QMailFolderId)));
    connectIpc(this, SIGNAL(onlineDeleteMessages(quint64, QMailMessageIdList, QMailStore::MessageRemovalOption)),
               adaptor, MESSAGE(onlineDeleteMessages(quint64, QMailMessageIdList, QMailStore::MessageRemovalOption)));
    connectIpc(this, SIGNAL(onlineFlagMessagesAndMoveToStandardFolder(quint64, QMailMessageIdList, quint64, quint64)),
               adaptor, MESSAGE(onlineFlagMessagesAndMoveToStandardFolder(quint64, QMailMessageIdList, quint64, quint64)));
    connectIpc(this, SIGNAL(addMessages(quint64, QString)),
               adaptor, MESSAGE(addMessages(quint64, QString)));
    connectIpc(this, SIGNAL(addMessages(quint64, QMailMessageMetaDataList)),
               adaptor, MESSAGE(addMessages(quint64, QMailMessageMetaDataList)));
    connectIpc(this, SIGNAL(updateMessages(quint64, QString)),
               adaptor, MESSAGE(updateMessages(quint64, QString)));
    connectIpc(this, SIGNAL(updateMessages(quint64, QMailMessageMetaDataList)),
               adaptor, MESSAGE(updateMessages(quint64, QMailMessageMetaDataList)));
    connectIpc(this, SIGNAL(onlineCreateFolder(quint64, QString, QMailAccountId, QMailFolderId)),
               adaptor, MESSAGE(onlineCreateFolder(quint64, QString, QMailAccountId, QMailFolderId)));
    connectIpc(this, SIGNAL(onlineRenameFolder(quint64, QMailFolderId, QString)),
               adaptor, MESSAGE(onlineRenameFolder(quint64, QMailFolderId, QString)));
    connectIpc(this, SIGNAL(onlineMoveFolder(quint64, QMailFolderId, QMailFolderId)),
               adaptor, MESSAGE(onlineMoveFolder(quint64, QMailFolderId, QMailFolderId)));
    connectIpc(this, SIGNAL(onlineDeleteFolder(quint64, QMailFolderId)),
               adaptor, MESSAGE(onlineDeleteFolder(quint64, QMailFolderId)));
    connectIpc(this, SIGNAL(deleteMessages(quint64, QMailMessageIdList)),
               adaptor, MESSAGE(deleteMessages(quint64, QMailMessageIdList)));
    connectIpc(this, SIGNAL(rollBackUpdates(quint64, QMailAccountId)),
               adaptor, MESSAGE(rollBackUpdates(quint64, QMailAccountId)));
    connectIpc(this, SIGNAL(moveToStandardFolder(quint64, QMailMessageIdList, quint64)),
               adaptor, MESSAGE(moveToStandardFolder(quint64, QMailMessageIdList, quint64)));
    connectIpc(this, SIGNAL(moveToFolder(quint64, QMailMessageIdList, QMailFolderId)),
               adaptor, MESSAGE(moveToFolder(quint64, QMailMessageIdList, QMailFolderId)));
    connectIpc(this, SIGNAL(flagMessages(quint64, QMailMessageIdList, quint64, quint64)),
               adaptor, MESSAGE(flagMessages(quint64, QMailMessageIdList, quint64, quint64)));
    connectIpc(this, SIGNAL(restoreToPreviousFolder(quint64, QMailMessageKey)),
               adaptor, MESSAGE(restoreToPreviousFolder(quint64, QMailMessageKey)));
    connectIpc(this, SIGNAL(searchMessages(quint64, QMailMessageKey, QString, QMailSearchAction::SearchSpecification, QMailMessageSortKey)),
               adaptor, MESSAGE(searchMessages(quint64, QMailMessageKey, QString, QMailSearchAction::SearchSpecification, QMailMessageSortKey)));
    connectIpc(this, SIGNAL(searchMessages(quint64, QMailMessageKey, QString, QMailSearchAction::SearchSpecification, quint64, QMailMessageSortKey)),
               adaptor, MESSAGE(searchMessages(quint64, QMailMessageKey, QString, QMailSearchAction::SearchSpecification, quint64, QMailMessageSortKey)));
    connectIpc(this, SIGNAL(countMessages(quint64, QMailMessageKey, QString)),
               adaptor, MESSAGE(countMessages(quint64, QMailMessageKey, QString)));
    connectIpc(this, SIGNAL(cancelSearch(quint64)),
               adaptor, MESSAGE(cancelSearch(quint64)));
    connectIpc(this, SIGNAL(shutdown()),
               adaptor, MESSAGE(shutdown()));
    connectIpc(this, SIGNAL(listActions()),
               adaptor, MESSAGE(listActions()));
    connectIpc(this, SIGNAL(protocolRequest(quint64, QMailAccountId, QString, QVariant)),
               adaptor, MESSAGE(protocolRequest(quint64, QMailAccountId, QString, QVariant)));

    // Propagate received events as exposed signals
    connectIpc(adaptor, MESSAGE(actionStarted(QMailActionData)),
               parent, SIGNAL(actionStarted(QMailActionData)));
    connectIpc(adaptor, MESSAGE(activityChanged(quint64, QMailServiceAction::Activity)),
               parent, SIGNAL(activityChanged(quint64, QMailServiceAction::Activity)));
    connectIpc(adaptor, MESSAGE(connectivityChanged(quint64, QMailServiceAction::Connectivity)),
               parent, SIGNAL(connectivityChanged(quint64, QMailServiceAction::Connectivity)));
    connectIpc(adaptor, MESSAGE(statusChanged(quint64, const QMailServiceAction::Status)),
               parent, SIGNAL(statusChanged(quint64, const QMailServiceAction::Status)));
    connectIpc(adaptor, MESSAGE(progressChanged(quint64, uint, uint)),
               parent, SIGNAL(progressChanged(quint64, uint, uint)));
    connectIpc(adaptor, MESSAGE(messagesDeleted(quint64, QMailMessageIdList)),
               parent, SIGNAL(messagesDeleted(quint64, QMailMessageIdList)));
    connectIpc(adaptor, MESSAGE(messagesCopied(quint64, QMailMessageIdList)),
               parent, SIGNAL(messagesCopied(quint64, QMailMessageIdList)));
    connectIpc(adaptor, MESSAGE(messagesMoved(quint64, QMailMessageIdList)),
               parent, SIGNAL(messagesMoved(quint64, QMailMessageIdList)));
    connectIpc(adaptor, MESSAGE(messagesFlagged(quint64, QMailMessageIdList)),
               parent, SIGNAL(messagesFlagged(quint64, QMailMessageIdList)));
    connectIpc(adaptor, MESSAGE(messagesAdded(quint64, QMailMessageIdList)),
               parent, SIGNAL(messagesAdded(quint64, QMailMessageIdList)));
    connectIpc(adaptor, MESSAGE(messagesUpdated(quint64, QMailMessageIdList)),
               parent, SIGNAL(messagesUpdated(quint64, QMailMessageIdList)));
    connectIpc(adaptor, MESSAGE(folderCreated(quint64, QMailFolderId)),
               parent, SIGNAL(folderCreated(quint64, QMailFolderId)));
    connectIpc(adaptor, MESSAGE(folderRenamed(quint64, QMailFolderId)),
               parent, SIGNAL(folderRenamed(quint64, QMailFolderId)));
    connectIpc(adaptor, MESSAGE(folderDeleted(quint64, QMailFolderId)),
               parent, SIGNAL(folderDeleted(quint64, QMailFolderId)));
    connectIpc(adaptor, MESSAGE(folderMoved(quint64, QMailFolderId)),
               parent, SIGNAL(folderMoved(quint64, QMailFolderId)));
    connectIpc(adaptor, MESSAGE(storageActionCompleted(quint64)),
               parent, SIGNAL(storageActionCompleted(quint64)));
    connectIpc(adaptor, MESSAGE(retrievalCompleted(quint64)),
               parent, SIGNAL(retrievalCompleted(quint64)));
    connectIpc(adaptor, MESSAGE(messagesTransmitted(quint64, QMailMessageIdList)),
               parent, SIGNAL(messagesTransmitted(quint64, QMailMessageIdList)));
    connectIpc(adaptor, MESSAGE(messagesFailedTransmission(quint64, QMailMessageIdList, QMailServiceAction::Status::ErrorCode)),
               parent, SIGNAL(messagesFailedTransmission(quint64, QMailMessageIdList, QMailServiceAction::Status::ErrorCode)));
    connectIpc(adaptor, MESSAGE(transmissionCompleted(quint64)),
               parent, SIGNAL(transmissionCompleted(quint64)));
    connectIpc(adaptor, MESSAGE(matchingMessageIds(quint64, QMailMessageIdList)),
               parent, SIGNAL(matchingMessageIds(quint64, QMailMessageIdList)));
    connectIpc(adaptor, MESSAGE(remainingMessagesCount(quint64, uint)),
               parent, SIGNAL(remainingMessagesCount(quint64, uint)));
    connectIpc(adaptor, MESSAGE(messagesCount(quint64, uint)),
               parent, SIGNAL(messagesCount(quint64, uint)));
    connectIpc(adaptor, MESSAGE(searchCompleted(quint64)),
               parent, SIGNAL(searchCompleted(quint64)));
    connectIpc(adaptor, MESSAGE(actionsListed(QMailActionDataList)),
               parent, SIGNAL(actionsListed(QMailActionDataList)));
    connectIpc(adaptor, MESSAGE(protocolResponse(quint64, QString, QVariant)),
               parent, SIGNAL(protocolResponse(quint64, QString, QVariant)));
    connectIpc(adaptor, MESSAGE(protocolRequestCompleted(quint64)),
               parent, SIGNAL(protocolRequestCompleted(quint64)));
    QObject::connect(adaptor, SIGNAL(connectionDown()),
                     parent, SIGNAL(connectionDown()));
    QObject::connect(adaptor, SIGNAL(reconnectionTimeout()),
                     parent, SIGNAL(reconnectionTimeout()));
}

QMailMessageServerPrivate::~QMailMessageServerPrivate()
{
}


/*!
    \class QMailMessageServer

    \preliminary
    \brief The QMailMessageServer class provides signals and slots which implement a convenient
    interface for communicating with the MessageServer process via IPC.

    \ingroup messaginglibrary

    QMF client messaging applications can send and receive messages of various types by
    communicating with the MessageServer.  The MessageServer
    is a separate process, communicating with clients via inter-process messages.  
    QMailMessageServer acts as a proxy object for the server process, providing an
    interface for communicating with the MessageServer by the use of signals and slots 
    in the client process.  It provides Qt signals corresponding to messages received from 
    the MessageServer application, and Qt slots which send messages to the MessageServer 
    when invoked.

    For most messaging client applications, the QMailServiceAction objects offer a simpler
    interface for requesting actions from the messageserver, and assessing their results.

    \section1 Sending Messages

    To send messages, the client should construct instances of the QMailMessage class
    formulated to contain the desired content.  These messages should be stored to the
    mail store, within the Outbox folder configured for the parent account.

    An instance of QMailTransmitAction should be used to request transmission of the 
    outgoing messages.

    \section1 Retrieving Messages

    There are a variety of mechanisms for retrieving messages, at various levels of
    granularity.  In all cases, retrieved messages are added directly to the mail 
    store by the message server, from where clients can retrieve their meta data or
    content.

    An instance of QMailRetrievalAction should be used to request retrieval of 
    folders and messages.

    \sa QMailServiceAction, QMailStore
*/

/*!
    \fn void QMailMessageServer::activityChanged(quint64 action, QMailServiceAction::Activity activity);

    Emitted whenever the MessageServer experiences a change in the activity status of the request
    identified by \a action.  The request's new status is described by \a activity.
*/

/*!
    \fn void QMailMessageServer::connectivityChanged(quint64 action, QMailServiceAction::Connectivity connectivity);

    Emitted whenever the MessageServer has a change in connectivity while servicing the request 
    identified by \a action.  The new server connectivity status is described by \a connectivity.
*/

/*!
    \fn void QMailMessageServer::statusChanged(quint64 action, const QMailServiceAction::Status status);

    Emitted whenever the MessageServer experiences a status change that may be of interest to the client,
    while servicing the request identified by \a action.  The new server status is described by \a status.
*/

/*!
    \fn void QMailMessageServer::progressChanged(quint64 action, uint progress, uint total);

    Emitted when the progress of the request identified by \a action changes; 
    \a total indicates the extent of the operation to be performed, \a progress indicates the current degree of completion.
*/

/*!
    \fn void QMailMessageServer::newCountChanged(const QMailMessageCountMap& counts);

    Emitted when the count of 'new' messages changes; the new count is described by \a counts.
    
    \deprecated

    \sa acknowledgeNewMessages()
*/

/*!
    \fn void QMailMessageServer::retrievalCompleted(quint64 action);

    Emitted when the retrieval operation identified by \a action is completed.
*/

/*!
    \fn void QMailMessageServer::messagesTransmitted(quint64 action, const QMailMessageIdList& list);

    Emitted when the messages identified by \a list have been transmitted to the external server,
    in response to the request identified by \a action.

    \sa transmitMessages()
*/

/*!
    \fn void QMailMessageServer::messagesFailedTransmission(quint64 action, const QMailMessageIdList& list, QMailServiceAction::Status::ErrorCode error);

    Emitted when a failed attempt has been made to transmit messages identified by \a list to the external server,
    in response to the request identified by \a action.
    
    The error is described by \a error.

    \sa transmitMessages()
*/

/*!
    \fn void QMailMessageServer::transmissionCompleted(quint64 action);

    Emitted when the transmit operation identified by \a action is completed.

    \sa transmitMessages()
*/

/*!
    \fn void QMailMessageServer::messagesDeleted(quint64 action, const QMailMessageIdList& list);

    Emitted when the messages identified by \a list have been deleted from the mail store,
    in response to the request identified by \a action.

    \sa deleteMessages(), onlineDeleteMessages()
*/

/*!
    \fn void QMailMessageServer::messagesCopied(quint64 action, const QMailMessageIdList& list);

    Emitted when the messages identified by \a list have been copied to the destination 
    folder on the external service, in response to the request identified by \a action.

    \sa onlineCopyMessages()
*/

/*!
    \fn void QMailMessageServer::messagesMoved(quint64 action, const QMailMessageIdList& list);

    Emitted when the messages identified by \a list have been moved to the destination 
    folder on the external service, in response to the request identified by \a action.

    \sa moveToFolder(), moveToStandardFolder(), onlineMoveMessages()
*/

/*!
    \fn void QMailMessageServer::messagesFlagged(quint64 action, const QMailMessageIdList& list);

    Emitted when the messages identified by \a list have been flagged with the specified
    set of status flags, in response to the request identified by \a action.

    \sa flagMessages(), moveToStandardFolder(), onlineFlagMessagesAndMoveToStandardFolder()
*/

/*!
    \fn void QMailMessageServer::folderCreated(quint64 action, const QMailFolderId& folderId);

    Emitted when the folder identified by \a folderId has been created, in response to the request
    identified by \a action.

    \sa onlineCreateFolder()
*/

/*!
    \fn void QMailMessageServer::folderRenamed(quint64 action, const QMailFolderId& folderId);

    Emitted when the folder identified by \a folderId has been renamed, in response to the request
    identified by \a action.

    \sa onlineRenameFolder()
*/

/*!
    \fn void QMailMessageServer::folderDeleted(quint64 action, const QMailFolderId& folderId);

    Emitted when the folder identified by \a folderId has been deleted, in response to the request
    identified by \a action.

    \sa onlineDeleteFolder()
*/

/*!
    \fn void QMailMessageServer::folderMoved(quint64 action, const QMailFolderId& folderId);

    Emitted when the folder identified by \a folderId has been moved, in response to the request
    identified by \a action.

    \sa onlineMoveFolder()
*/

/*!
    \fn void QMailMessageServer::storageActionCompleted(quint64 action);

    Emitted when the storage operation identified by \a action is completed.
*/

/*!
    \fn void QMailMessageServer::searchCompleted(quint64 action);

    Emitted when the search operation identified by \a action is completed.

    \sa searchMessages()
*/

/*!
    \fn void QMailMessageServer::matchingMessageIds(quint64 action, const QMailMessageIdList& ids);

    Emitted by the search operation identified by \a action; 
    \a ids contains the list of message identifiers located by the search.

    \sa searchMessages()
*/

/*!
    \fn void QMailMessageServer::remainingMessagesCount(quint64 action, uint count);

    Emitted by search operation identified by \a action; 
    Returns the \a count of matching messages remaining on the remote server, that is the count
    of messages that will not be retrieved from the remote server to the device.

    Only applicable for remote searches.

    \sa searchMessages()
*/

/*!
    \fn void QMailMessageServer::messagesCount(quint64 action, uint count);

    Emitted by search operation identified by \a action; 
    Returns the \a count of matching messages on the remote server.

    Only applicable for remote searches.

    \sa countMessages()
*/

/*!
    \fn void QMailMessageServer::protocolResponse(quint64 action, const QString &response, const QVariant &data);

    Emitted when the protocol request identified by \a action generates the response
    \a response, with the associated \a data.

    \sa protocolRequest()
*/

/*!
    \fn void QMailMessageServer::protocolRequestCompleted(quint64 action);

    Emitted when the protocol request identified by \a action is completed.

    \sa protocolRequest()
*/

/*!
    \fn void QMailMessageServer::actionsListed(const QMailActionDataList &list);

    Emitted when a list of running actions has been retrieved from the server. 
    The list of running actions is described by \a list.
*/

/*!
    \fn void QMailMessageServer::actionStarted(QMailActionData data)

    Emitted when the action described by \a data has been started on the 
    messageserver.
*/

/*!
    Constructs a QMailMessageServer object with parent \a parent, and initiates communication with the MessageServer application.
*/
QMailMessageServer::QMailMessageServer(QObject* parent)
    : QObject(parent),
      d(new QMailMessageServerPrivate(this))
{
}

/*!
    Destroys the QMailMessageServer object.
*/
QMailMessageServer::~QMailMessageServer()
{
}

/*!
    Requests that the MessageServer application transmit any messages belonging to the
    account identified by \a accountId that are currently in the Outbox folder.
    The request has the identifier \a action.

    This function requires the device to be online, it may initiate communication 
    with external servers.
    
    \sa transmissionCompleted()
*/
void QMailMessageServer::transmitMessages(quint64 action, const QMailAccountId &accountId)
{
    emit d->transmitMessages(action, accountId);
}

/*!
    Requests that the MessageServer application transmit the message
    identified by \a messageId that are currently in the Outbox folder.
    The request has the identifier \a action.

    \sa transmissionCompleted()
*/
void QMailMessageServer::transmitMessage(quint64 action, const QMailMessageId &messageId)
{
    emit d->transmitMessage(action, messageId);
}

/*!
    Requests that the message server retrieve the list of folders available for the account \a accountId.
    If \a folderId is valid, the folders within that folder should be retrieved.  If \a descending is true,
    the search should also recursively retrieve the folders available within the previously retrieved folders.
    The request has the identifier \a action.

    The request has the identifier \a action.

    This function requires the device to be online, it may initiate communication 
    with external servers.

    \sa retrievalCompleted()
*/
void QMailMessageServer::retrieveFolderList(quint64 action, const QMailAccountId &accountId, const QMailFolderId &folderId, bool descending)
{
    emit d->retrieveFolderList(action, accountId, folderId, descending);
}

/*!
    Requests that the message server retrieve the list of messages available for the account \a accountId.
    If \a folderId is valid, then only messages within that folder should be retrieved; otherwise 
    messages within all folders in the account should be retrieved. If a folder messages are being 
    retrieved from contains at least \a minimum messages then the messageserver should ensure that at 
    least \a minimum messages are available from the mail store for that folder; otherwise if the
    folder contains less than \a minimum messages the messageserver should ensure all the messages for 
    that folder are available from the mail store.
    
    If \a sort is not empty, the external service will 
    discover the listed messages in the ordering indicated by the sort criterion, if possible.

    The request has the identifier \a action.

    This function requires the device to be online, it may initiate communication 
    with external servers.

    \sa retrievalCompleted()
*/
void QMailMessageServer::retrieveMessageList(quint64 action, const QMailAccountId &accountId, const QMailFolderId &folderId, uint minimum, const QMailMessageSortKey &sort)
{
    emit d->retrieveMessageList(action, accountId, folderId, minimum, sort);
}

/*!
    Requests that the messageserver retrieve the list of messages available for the account \a accountId.
    If \a folderIds is not empty, then only messages within those folders should be retrieved; otherwise 
    no messages should be retrieved. If a folder messages are being 
    retrieved from contains at least \a minimum messages then the messageserver should ensure that at 
    least \a minimum messages are available from the mail store for that folder; otherwise if the
    folder contains less than \a minimum messages the messageserver should ensure all the messages for 
    that folder are available from the mail store.
    
    If \a sort is not empty, the external service will 
    discover the listed messages in the ordering indicated by the sort criterion, if possible.

    The request has the identifier \a action.

    This function requires the device to be online, it may initiate communication 
    with external servers.

    \sa retrievalCompleted()
*/
void QMailMessageServer::retrieveMessageLists(quint64 action, const QMailAccountId &accountId, const QMailFolderIdList &folderIds, uint minimum, const QMailMessageSortKey &sort)
{
    emit d->retrieveMessageLists(action, accountId, folderIds, minimum, sort);
}

/*!
    Requests that the message server retrieve new messages for the account \a accountId in the
    folders specified by \a folderIds.
    
    If a folder inspected has been previously inspected then new mails in that folder will
    be retrieved, otherwise the most recent message in that folder, if any, will be retrieved.
    
    This function is intended for use by protocol plugins to retrieve new messages when
    a push notification event is received from the remote server.
    
    Detection of deleted messages, and flag updates for messages in the mail store will
    not necessarily be performed.

    The request has the identifier \a action.

    This function requires the device to be online, it may initiate communication 
    with external servers.

    \sa retrievalCompleted()
*/
void QMailMessageServer::retrieveNewMessages(quint64 action, const QMailAccountId &accountId, const QMailFolderIdList &folderIds)
{
    emit d->retrieveNewMessages(action, accountId, folderIds);
}

/*!
    Requests that the message server create the standard folders for the
    account \a accountId. If all standard folders are already set in the storage
    the service action will return success immediately, in case some standard folders are
    not set, a matching attempt against a predefined list of translations will be made,
    if the folders can't be matched, messageserver will try to create them in the server side
    and match them if the creation is successful. In case folder creation is not allowed for
    the account \a accountId the service action will still complete successfully, clients
    must use local standard folders only in this case.

    This function requires the device to be online, it may initiate communication 
    with external servers.

    \sa retrieveFolderList
*/
void QMailMessageServer::createStandardFolders(quint64 action, const QMailAccountId &accountId)
{
    emit d->createStandardFolders(action, accountId);
}

/*!
    Requests that the message server retrieve data regarding the messages identified by \a messageIds.  

    If \a spec is \l QMailRetrievalAction::Flags, then the message server should detect if 
    the read or important status of messages identified by \a messageIds has changed on the server 
    or if the messages have been removed on the server.
    The \l QMailMessage::ReadElsewhere, \l QMailMessage::ImportantElsewhere and \l QMailMessage::Removed 
    status flags of messages will be updated to reflect the status of the message on the server.

    If \a spec is \l QMailRetrievalAction::MetaData, then the message server should 
    retrieve the meta data of the each message listed in \a messageIds.
    
    If \a spec is \l QMailRetrievalAction::Content, then the message server should 
    retrieve the entirety of each message listed in \a messageIds.

    The request has the identifier \a action.

    This function requires the device to be online, it may initiate communication 
    with external servers.

    \sa retrievalCompleted()
*/
void QMailMessageServer::retrieveMessages(quint64 action, const QMailMessageIdList &messageIds, QMailRetrievalAction::RetrievalSpecification spec)
{
    emit d->retrieveMessages(action, messageIds, spec);
}

/*!
    Requests that the message server retrieve the message part that is indicated by the 
    location \a partLocation.

    The request has the identifier \a action.

    This function requires the device to be online, it may initiate communication 
    with external servers.

    \sa retrievalCompleted()
*/
void QMailMessageServer::retrieveMessagePart(quint64 action, const QMailMessagePart::Location &partLocation)
{
    emit d->retrieveMessagePart(action, partLocation);
}

/*!
    Requests that the message server retrieve a subset of the message \a messageId, such that
    at least \a minimum bytes are available from the mail store.
    The request has the identifier \a action.

    This function requires the device to be online, it may initiate communication 
    with external servers.

    \sa retrievalCompleted()
*/
void QMailMessageServer::retrieveMessageRange(quint64 action, const QMailMessageId &messageId, uint minimum)
{
    emit d->retrieveMessageRange(action, messageId, minimum);
}

/*!
    Requests that the message server retrieve a subset of the message part that is indicated by 
    the location \a partLocation.  The messageserver should ensure that at least \a minimum 
    bytes are available from the mail store.
    The request has the identifier \a action.

    This function requires the device to be online, it may initiate communication 
    with external servers.

    \sa retrievalCompleted()
*/
void QMailMessageServer::retrieveMessagePartRange(quint64 action, const QMailMessagePart::Location &partLocation, uint minimum)
{
    emit d->retrieveMessagePartRange(action, partLocation, minimum);
}

/*!
    Requests that the message server retrieve the meta data for all messages available 
    for the account \a accountId.
    The request has the identifier \a action.

    This function requires the device to be online, it may initiate communication 
    with external servers.

    \sa retrievalCompleted()
*/
void QMailMessageServer::retrieveAll(quint64 action, const QMailAccountId &accountId)
{
    emit d->retrieveAll(action, accountId);
}

/*!
    Requests that the message server update the external server with changes that have 
    been effected on the local device for account \a accountId.
    Local changes to \l QMailMessage::Read, and \l QMailMessage::Important message status 
    flags should be exported to the external server, and messages that have been removed
    using the \l QMailStore::CreateRemovalRecord option should be removed from the 
    external server.
    The request has the identifier \a action.

    This function requires the device to be online, it may initiate communication 
    with external servers.

    \sa retrievalCompleted()
*/
void QMailMessageServer::exportUpdates(quint64 action, const QMailAccountId &accountId)
{
    emit d->exportUpdates(action, accountId);
}

/*!
    Requests that the message server synchronize the messages and folders in the account 
    identified by \a accountId.

    Newly discovered messages should have their meta data retrieved,
    local changes to \l QMailMessage::Read, and \l QMailMessage::Important message status 
    flags should be exported to the external server, and messages that have been removed
    locally using the \l QMailStore::CreateRemovalRecord option should be removed from the 
    external server.

    The request has the identifier \a action.

    This function requires the device to be online, it may initiate communication 
    with external servers.

    \sa retrievalCompleted()
*/
void QMailMessageServer::synchronize(quint64 action, const QMailAccountId &accountId)
{
    emit d->synchronize(action, accountId);
}

/*!
    Requests that the MessageServer create a copy of each message listed in \a mailList 
    in the folder identified by \a destinationId.
    
    The request has the identifier \a action.

    This function requires the device to be online, it may initiate communication 
    with external servers.
*/
void QMailMessageServer::onlineCopyMessages(quint64 action, const QMailMessageIdList& mailList, const QMailFolderId &destinationId)
{
    emit d->onlineCopyMessages(action, mailList, destinationId);
}

/*!
    Requests that the MessageServer move each message listed in \a mailList from its 
    current location to the folder identified by \a destinationId.

    The request has the identifier \a action.

    This function requires the device to be online, it may initiate communication 
    with external servers.
*/
void QMailMessageServer::onlineMoveMessages(quint64 action, const QMailMessageIdList& mailList, const QMailFolderId &destinationId)
{
    emit d->onlineMoveMessages(action, mailList, destinationId);
}

/*!
    Requests that the MessageServer flag each message listed in \a mailList by setting
    the status flags set in \a setMask, and unsetting the status flags set in \a unsetMask.
    The request has the identifier \a action.

    The protocol must ensure that the local message records are appropriately modified, 
    although the external changes may be buffered and effected at the next invocation 
    of exportUpdates().

    The request has the identifier \a action.

    This function requires the device to be online, it may initiate communication 
    with external servers.
*/
void QMailMessageServer::onlineFlagMessagesAndMoveToStandardFolder(quint64 action, const QMailMessageIdList& mailList, quint64 setMask, quint64 unsetMask)
{
    emit d->onlineFlagMessagesAndMoveToStandardFolder(action, mailList, setMask, unsetMask);
}

/*!
    Requests that the MessageServer add the messages in 
    \a filename to the message store.

    The request has the identifier \a action.

    \deprecated
*/
void QMailMessageServer::addMessages(quint64 action, const QString& filename)
{
    emit d->addMessages(action, filename);
}

/*!
    Requests that the MessageServer update the list of \a messages
    in the message store, and ensure the durability of the content of \a messages.

    The request has the identifier \a action.
*/
void QMailMessageServer::addMessages(quint64 action, const QMailMessageMetaDataList& messages)
{
    emit d->addMessages(action, messages);
}

/*!
    Requests that the MessageServer update the messages in 
    \a filename to the message store.

    The request has the identifier \a action.

    \deprecated
*/
void QMailMessageServer::updateMessages(quint64 action, const QString& filename)
{
    emit d->updateMessages(action, filename);
}

/*!
    Requests that the MessageServer add the list of \a messages
    to the message store, and ensure the durability of the content of \a messages.

    The request has the identifier \a action.
*/
void QMailMessageServer::updateMessages(quint64 action, const QMailMessageMetaDataList& messages)
{
    emit d->updateMessages(action, messages);
}



/*!
    Requests that the MessageServer create a new folder named \a name, created in the
    account identified by \a accountId.

    If \a parentId is a valid folder identifier the new folder will be a child of the parent;
    otherwise the folder will be have no parent and will be created at the highest level.

    The request has the identifier \a action.

    This function requires the device to be online, it may initiate communication 
    with external servers.

    \sa onlineDeleteFolder()
*/
void QMailMessageServer::onlineCreateFolder(quint64 action, const QString &name, const QMailAccountId &accountId, const QMailFolderId &parentId)
{
    emit d->onlineCreateFolder(action, name, accountId, parentId);
}

/*!
    Requests that the MessageServer rename the folder identified by \a folderId to \a name.
    The request has the identifier \a action.

    The request has the identifier \a action.

    This function requires the device to be online, it may initiate communication 
    with external servers.

    \sa onlineCreateFolder()
*/
void QMailMessageServer::onlineRenameFolder(quint64 action, const QMailFolderId &folderId, const QString &name)
{
    emit d->onlineRenameFolder(action, folderId, name);
}

/*!
    Requests that the MessageServer delete the folder identified by \a folderId.
    Any existing folders or messages contained by the folder will also be deleted.

    The request has the identifier \a action.

    This function requires the device to be online, it may initiate communication 
    with external servers.

    \sa onlineCreateFolder(), onlineRenameFolder(), onlineMoveFolder()
*/
void QMailMessageServer::onlineDeleteFolder(quint64 action, const QMailFolderId &folderId)
{
    emit d->onlineDeleteFolder(action, folderId);
}

/*!
    Requests that the MessageServer move the folder identified by \a folderId.
    If \a parentId is a valid folder identifier the new folder will be a child of the parent;
    otherwise the folder will be have no parent and will be created at the highest level.

    The request has the identifier \a action.

    This function requires the device to be online, it may initiate communication
    with external servers.

    \sa onlineCreateFolder(), onlineRenameFolder()
*/
void QMailMessageServer::onlineMoveFolder(quint64 action, const QMailFolderId &folderId, const QMailFolderId &newParentId)
{
    emit d->onlineMoveFolder(action, folderId, newParentId);
}

/*!
    Requests that the MessageServer cancel any pending transfer operations for the request identified by \a action.

    \sa transmitMessages(), retrieveMessages()
*/
void QMailMessageServer::cancelTransfer(quint64 action)
{
    emit d->cancelTransfer(action);
}

/*!
    Requests that the MessageServer reset the counts of 'new' messages to zero, for
    each message type listed in \a types.
    
    \deprecated

    \sa newCountChanged()
*/
void QMailMessageServer::acknowledgeNewMessages(const QMailMessageTypeList& types)
{
    emit d->acknowledgeNewMessages(types);
}

/*!
    Requests that the MessageServer delete the messages in \a mailList from the external
    server, if necessary for the relevant message type.  
    
    If \a option is 
    \l{QMailStore::CreateRemovalRecord}{CreateRemovalRecord} then a QMailMessageRemovalRecord
    will be created in the mail store for each deleted message. In this case
    the function requires the device to be online, it may initiate communication 
    with external servers.
    
    The request has the identifier \a action.

    \sa QMailStore::removeMessage()
*/
void QMailMessageServer::onlineDeleteMessages(quint64 action, const QMailMessageIdList& mailList, QMailStore::MessageRemovalOption option)
{
    emit d->onlineDeleteMessages(action, mailList, option);
}

/*!
    Requests that the MessageServer delete the messages in \a mailList, messages
    will be removed locally from the device, and if necessary information needed 
    to delete messages from an external server is recorded.

    Deleting messages using this slot does not initiate communication with any external
    server; Deletion from the external server will occur when 
    QMailRetrievalAction::exportUpdates is called successfully.
    
    The request has the identifier \a action.

    \sa QMailStore::removeMessage()
*/
void QMailMessageServer::deleteMessages(quint64 action, const QMailMessageIdList& mailList)
{
    emit d->deleteMessages(action, mailList);
}

/*!
    Asynchronous version of QMailDisconnected::rollBackUpdates()
    
    Rolls back all disconnected move and copy operations that have been applied to the 
    message store since the most recent synchronization of the message with the account 
    specified by \a mailAccountId.
    
    The request has the identifier \a action.
    
    \sa QMailDisconnected::updatesOutstanding()
*/
void QMailMessageServer::rollBackUpdates(quint64 action, const QMailAccountId &mailAccountId)
{
    emit d->rollBackUpdates(action, mailAccountId);
}

/*!
    Asynchronous version of QMailDisconnected::moveToStandardFolder()

    Disconnected moves the list of messages identified by \a ids into the standard folder \a standardFolder, setting standard 
    folder flags as appropriate.
    
    The move operation will be propagated to the server by a successful call to QMailRetrievalAction::exportUpdates().
            
    The request has the identifier \a action.

    \sa QMailDisconnected::moveToStandardFolder()
*/
void QMailMessageServer::moveToStandardFolder(quint64 action, const QMailMessageIdList& ids, quint64 standardFolder)
{
    emit d->moveToStandardFolder(action, ids, standardFolder);
}

/*!
    Asynchronous version of QMailDisconnected::moveToFolder()

    Disconnected moves the list of messages identified by \a ids into the folder identified by \a folderId, setting standard 
    folder flags as appropriate.

    Moving to another account is not supported.

    The move operation will be propagated to the server by a successful call to QMailRetrievalAction::exportUpdates().
    
    The request has the identifier \a action.
    
    \sa QMailDisconnected::moveToFolder()
*/
void QMailMessageServer::moveToFolder(quint64 action, const QMailMessageIdList& ids, const QMailFolderId& folderId)
{
    emit d->moveToFolder(action, ids, folderId);
}

/*!
    Asynchronous version of QMailDisconnected::flagMessages()

    Disconnected flags the list of messages identified by \a ids, setting the flags specified by the bit mask \a setMask 
    to on and setting the flags set by the bit mask \a unsetMask to off.
    
    For example this function may be used to mark messages as important.

    The flagging operation will be propagated to the server by a successful call to QMailRetrievalAction::exportUpdates().
            
    The request has the identifier \a action.
    
    \sa QMailDisconnected::flagMessages()
*/
void QMailMessageServer::flagMessages(quint64 action, const QMailMessageIdList& ids, quint64 setMask, quint64 unsetMask)
{
    emit d->flagMessages(action, ids, setMask, unsetMask);
}

/*!
    Asynchronous version of QMailDisconnected::restoreToPreviousFolder()

    Updates all QMailMessages identified by the key \a key to move the messages back to the
    previous folder they were contained by.
        
    The request has the identifier \a action.
    
    \sa QMailDisconnected::restoreToPreviousFolder(), QMailMessageServer::moveToFolder(), QMailMessageServer::moveToStandardFolder()
*/
void QMailMessageServer::restoreToPreviousFolder(quint64 action, const QMailMessageKey& key)
{
    emit d->restoreToPreviousFolder(action, key);
}

/*!
    Requests that the MessageServer search for messages that meet the criteria encoded
    in \a filter.  If \a bodyText is non-empty, messages containing the specified text 
    in their content will also be matched.  If \a spec is 
    \l{QMailSearchAction::Remote}{Remote} then the MessageServer will extend the search
    to consider messages held at external servers that are not present on the local device.
    If \a sort is not empty, the external service will return matching messages in 
    the ordering indicated by the sort criterion if possible.

    The identifiers of all matching messages are returned via matchingMessageIds() signals.

    The request has the identifier \a action.

    If a remote search is specified then this function requires the device to be online, 
    it may initiate communication with external servers.

    \sa matchingMessageIds(), messagesCount(), remainingMessagesCount()
*/
void QMailMessageServer::searchMessages(quint64 action, const QMailMessageKey& filter, const QString& bodyText, QMailSearchAction::SearchSpecification spec, const QMailMessageSortKey &sort)
{
    emit d->searchMessages(action, filter, bodyText, spec, sort);
}

/*!
    Requests that the MessageServer search for messages that meet the criteria encoded
    in \a filter.  If \a bodyText is non-empty, messages containing the specified text 
    in their content will also be matched.  If \a spec is 
    \l{QMailSearchAction::Remote}{Remote} then the MessageServer will extend the search
    to consider messages held at external servers that are not present on the local device.

    A maximum of \a limit messages will be retrieved from the remote server.

    If \a sort is not empty, the external service will return matching messages in 
    the ordering indicated by the sort criterion if possible.

    The identifiers of all matching messages are returned via matchingMessageIds() signals.

    The request has the identifier \a action.

    If a remote search is specified then this function requires the device to be online, 
    it may initiate communication with external servers.

    \sa matchingMessageIds(), messagesCount(), remainingMessagesCount()
*/
void QMailMessageServer::searchMessages(quint64 action, const QMailMessageKey& filter, const QString& bodyText, QMailSearchAction::SearchSpecification spec, quint64 limit, const QMailMessageSortKey &sort)
{
    emit d->searchMessages(action, filter, bodyText, spec, limit, sort);
}

/*!
    Requests that the MessageServer counts the number of messages that match the criteria 
    specified by \a filter by on the device and remote servers.  If \a bodyText is non-empty, 
    messages containing the specified text in their content will also be matched.

    The count of all matching messages is returned via a messagesCount() signal.

    The request has the identifier \a action.

    This function requires the device to be online, it may initiate communication 
    with external servers.

    \sa messagesCount()
*/
void QMailMessageServer::countMessages(quint64 action, const QMailMessageKey& filter, const QString& bodyText)
{
    emit d->countMessages(action, filter, bodyText);
}

/*!
    Requests that the MessageServer cancel any pending search operations for the request identified by \a action.

    This method is obsolete, use cancel transfer instead.
*/
void QMailMessageServer::cancelSearch(quint64 action)
{
    emit d->cancelTransfer(action);
}

/*!
    Requests that the MessageServer shutdown and terminate
*/
void QMailMessageServer::shutdown()
{
    emit d->shutdown();
}

/*!
    Requests that the MessageServer emits a list of currently executing actions
*/
void QMailMessageServer::listActions()
{
    emit d->listActions();
}

/*!
    Requests that the MessageServer forward the protocol-specific request \a request
    to the QMailMessageSource configured for the account identified by \a accountId.
    The request, identified by \a action, may have associated \a data, in a protocol-specific form.
*/
void QMailMessageServer::protocolRequest(quint64 action, const QMailAccountId &accountId, const QString &request, const QVariant &data)
{
    emit d->protocolRequest(action, accountId, request, data);
}

Q_IMPLEMENT_USER_METATYPE_TYPEDEF(QMailMessageCountMap, QMailMessageCountMap)

/*!
    \fn bool QMailMessageServer::connectionDown()

    Signal that is emitted when the connection to the messageserver has been destroyed.

    \sa reconnectionTimeout()
*/

/*!
    \fn bool QMailMessageServer::reconnectionTimeout()

    Signal that is emitted when the connection to the messageserver has been lost.

    \sa connectionDown()
*/

/*!
    \fn void QMailMessageServer::messagesAdded(quint64 action, const QMailMessageIdList& ids);

    Signal that is emitted when messages have been asynchronously added to the message store.
    
    \a action is the identifier of the request that caused the messages to be added, and \a ids
    is a list of identifiers of messages that have been added.

    \sa QMailStorageAction::addMessages()
*/

/*!
    \fn void QMailMessageServer::messagesUpdated(quint64 action, const QMailMessageIdList& ids);

    Signal that is emitted when messages have been asynchronously updated in the message store.

    \a action is the identifier of the request that caused the messages to be updated, and \a ids
    is a list of identifiers of messages that have been updated.

    \sa QMailStorageAction::updateMessages()
*/

#include "qmailmessageserver.moc"