LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
structuresops.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#include "structuresops.h"
10#include <QtDebug>
11
12QDataStream& operator<< (QDataStream& out, const LC::Entity& e)
13{
14 quint16 version = 2;
15 out << version
16 << e.Entity_
17 << e.Location_
18 << e.Mime_
19 << static_cast<quint32> (e.Parameters_)
20 << e.Additional_;
21 return out;
22}
23
24QDataStream& operator>> (QDataStream& in, LC::Entity& e)
25{
26 quint16 version = 0;
27 in >> version;
28 if (version == 2)
29 {
30 quint32 parameters = 0;
31 in >> e.Entity_
32 >> e.Location_
33 >> e.Mime_
34 >> parameters
35 >> e.Additional_;
36
37 if (parameters & LC::NoAutostart)
39 if (parameters & LC::DoNotSaveInHistory)
41 if (parameters & LC::IsDownloaded)
43 if (parameters & LC::FromUserInitiated)
45 if (parameters & LC::DoNotNotifyUser)
47 if (parameters & LC::Internal)
49 if (parameters & LC::NotPersistent)
51 if (parameters & LC::DoNotAnnounceEntity)
53 if (parameters & LC::OnlyHandle)
55 if (parameters & LC::OnlyDownload)
57 if (parameters & LC::AutoAccept)
59 if (parameters & LC::FromCommandLine)
61 }
62 else if (version == 1)
63 {
64 QByteArray buf;
65 quint32 parameters = 0;
66 in >> buf
67 >> e.Location_
68 >> e.Mime_
69 >> parameters
70 >> e.Additional_;
71
72 e.Entity_ = buf;
73
74 if (parameters & LC::NoAutostart)
76 if (parameters & LC::DoNotSaveInHistory)
78 if (parameters & LC::IsDownloaded)
80 if (parameters & LC::FromUserInitiated)
82 if (parameters & LC::DoNotNotifyUser)
84 if (parameters & LC::Internal)
86 if (parameters & LC::NotPersistent)
88 if (parameters & LC::DoNotAnnounceEntity)
90 if (parameters & LC::OnlyHandle)
92 if (parameters & LC::OnlyDownload)
94 if (parameters & LC::AutoAccept)
96 if (parameters & LC::FromCommandLine)
98 }
99 else
100 {
101 qWarning () << Q_FUNC_INFO
102 << "unknown version"
103 << "version";
104 }
105 return in;
106}
107
108namespace LC
109{
110 bool operator< (const LC::Entity& e1, const LC::Entity& e2)
111 {
112 return e1.Mime_ < e2.Mime_ &&
113 e1.Location_ < e2.Location_ &&
114 e1.Parameters_ < e2.Parameters_;
115 }
116
117 bool operator== (const LC::Entity& e1, const LC::Entity& e2)
118 {
119 return e1.Mime_ == e2.Mime_ &&
120 e1.Entity_ == e2.Entity_ &&
121 e1.Location_ == e2.Location_ &&
122 e1.Parameters_ == e2.Parameters_ &&
123 e1.Additional_ == e2.Additional_;
124 }
125}
Definition constants.h:15
bool operator==(const LC::Entity &e1, const LC::Entity &e2)
bool operator<(const LC::Entity &e1, const LC::Entity &e2)
@ DoNotSaveInHistory
Definition structures.h:35
@ FromUserInitiated
Definition structures.h:44
@ Internal
Definition structures.h:53
@ AutoAccept
Definition structures.h:78
@ OnlyHandle
Definition structures.h:68
@ FromCommandLine
Definition structures.h:83
@ DoNotNotifyUser
Definition structures.h:48
@ IsDownloaded
Definition structures.h:40
@ NotPersistent
Definition structures.h:58
@ DoNotAnnounceEntity
Definition structures.h:63
@ OnlyDownload
Definition structures.h:73
@ NoAutostart
Definition structures.h:31
A message used for inter-plugin communication.
Definition structures.h:96
QString Mime_
MIME type of the entity.
Definition structures.h:148
QString Location_
Source or destination.
Definition structures.h:122
QVariant Entity_
The entity that this object represents.
Definition structures.h:112
TaskParameters Parameters_
Parameters of this task.
Definition structures.h:152
QMap< QString, QVariant > Additional_
Additional parameters.
Definition structures.h:164
QDataStream & operator>>(QDataStream &in, LC::Entity &e)
QDataStream & operator<<(QDataStream &out, const LC::Entity &e)