LeechCraft
0.6.70-13605-g8cd066ad6a
Modular cross-platform feature rich live environment.
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
* Boost Software License - Version 1.0 - August 17th, 2003
6
*
7
* Permission is hereby granted, free of charge, to any person or organization
8
* obtaining a copy of the software and accompanying documentation covered by
9
* this license (the "Software") to use, reproduce, display, distribute,
10
* execute, and transmit the Software, and to prepare derivative works of the
11
* Software, and to permit third-parties to whom the Software is furnished to
12
* do so, all subject to the following:
13
*
14
* The copyright notices in the Software and this entire statement, including
15
* the above license grant, this restriction and the following disclaimer,
16
* must be included in all copies of the Software, in whole or in part, and
17
* all derivative works of the Software, unless such copies or derivative
18
* works are solely in the form of machine-executable object code generated by
19
* a source language processor.
20
*
21
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
* FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
24
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
25
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
26
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27
* DEALINGS IN THE SOFTWARE.
28
**********************************************************************/
29
30
#include "
structuresops.h
"
31
32
QDataStream&
operator<<
(QDataStream& out,
const
LC::Entity
& e)
33
{
34
quint16 version = 2;
35
out << version
36
<< e.
Entity_
37
<< e.
Location_
38
<< e.
Mime_
39
<< static_cast<quint32> (e.
Parameters_
)
40
<< e.
Additional_
;
41
return
out;
42
}
43
44
QDataStream&
operator>>
(QDataStream& in,
LC::Entity
& e)
45
{
46
quint16 version = 0;
47
in >> version;
48
if
(version == 2)
49
{
50
quint32 parameters;
51
in >> e.
Entity_
52
>> e.
Location_
53
>> e.
Mime_
54
>> parameters
55
>> e.
Additional_
;
56
57
if
(parameters &
LC::NoAutostart
)
58
e.
Parameters_
|=
LC::NoAutostart
;
59
if
(parameters &
LC::DoNotSaveInHistory
)
60
e.
Parameters_
|=
LC::DoNotSaveInHistory
;
61
if
(parameters &
LC::IsDownloaded
)
62
e.
Parameters_
|=
LC::IsDownloaded
;
63
if
(parameters &
LC::FromUserInitiated
)
64
e.
Parameters_
|=
LC::FromUserInitiated
;
65
if
(parameters &
LC::DoNotNotifyUser
)
66
e.
Parameters_
|=
LC::DoNotNotifyUser
;
67
if
(parameters &
LC::Internal
)
68
e.
Parameters_
|=
LC::Internal
;
69
if
(parameters &
LC::NotPersistent
)
70
e.
Parameters_
|=
LC::NotPersistent
;
71
if
(parameters &
LC::DoNotAnnounceEntity
)
72
e.
Parameters_
|=
LC::DoNotAnnounceEntity
;
73
if
(parameters &
LC::OnlyHandle
)
74
e.
Parameters_
|=
LC::OnlyHandle
;
75
if
(parameters &
LC::OnlyDownload
)
76
e.
Parameters_
|=
LC::OnlyDownload
;
77
if
(parameters &
LC::AutoAccept
)
78
e.
Parameters_
|=
LC::AutoAccept
;
79
if
(parameters &
LC::FromCommandLine
)
80
e.
Parameters_
|=
LC::FromCommandLine
;
81
}
82
else
if
(version == 1)
83
{
84
QByteArray buf;
85
quint32 parameters;
86
in >> buf
87
>> e.
Location_
88
>> e.
Mime_
89
>> parameters
90
>> e.
Additional_
;
91
92
e.
Entity_
= buf;
93
94
if
(parameters &
LC::NoAutostart
)
95
e.
Parameters_
|=
LC::NoAutostart
;
96
if
(parameters &
LC::DoNotSaveInHistory
)
97
e.
Parameters_
|=
LC::DoNotSaveInHistory
;
98
if
(parameters &
LC::IsDownloaded
)
99
e.
Parameters_
|=
LC::IsDownloaded
;
100
if
(parameters &
LC::FromUserInitiated
)
101
e.
Parameters_
|=
LC::FromUserInitiated
;
102
if
(parameters &
LC::DoNotNotifyUser
)
103
e.
Parameters_
|=
LC::DoNotNotifyUser
;
104
if
(parameters &
LC::Internal
)
105
e.
Parameters_
|=
LC::Internal
;
106
if
(parameters &
LC::NotPersistent
)
107
e.
Parameters_
|=
LC::NotPersistent
;
108
if
(parameters &
LC::DoNotAnnounceEntity
)
109
e.
Parameters_
|=
LC::DoNotAnnounceEntity
;
110
if
(parameters &
LC::OnlyHandle
)
111
e.
Parameters_
|=
LC::OnlyHandle
;
112
if
(parameters &
LC::OnlyDownload
)
113
e.
Parameters_
|=
LC::OnlyDownload
;
114
if
(parameters &
LC::AutoAccept
)
115
e.
Parameters_
|=
LC::AutoAccept
;
116
if
(parameters &
LC::FromCommandLine
)
117
e.
Parameters_
|=
LC::FromCommandLine
;
118
}
119
else
120
{
121
qWarning () << Q_FUNC_INFO
122
<<
"unknown version"
123
<<
"version"
;
124
}
125
return
in;
126
}
127
128
namespace
LC
129
{
130
bool
operator<
(
const
LC::Entity
& e1,
const
LC::Entity
& e2)
131
{
132
return
e1.
Mime_
< e2.
Mime_
&&
133
e1.
Location_
< e2.
Location_
&&
134
e1.
Parameters_
< e2.
Parameters_
;
135
}
136
137
bool
operator==
(
const
LC::Entity
& e1,
const
LC::Entity
& e2)
138
{
139
return
e1.
Mime_
== e2.
Mime_
&&
140
e1.
Entity_
== e2.
Entity_
&&
141
e1.
Location_
== e2.
Location_
&&
142
e1.
Parameters_
== e2.
Parameters_
&&
143
e1.
Additional_
== e2.
Additional_
;
144
}
145
}
LC::DoNotNotifyUser
Definition:
structures.h:71
operator<<
QDataStream & operator<<(QDataStream &out, const LC::Entity &e)
Definition:
structuresops.cpp:32
LC::DoNotSaveInHistory
Definition:
structures.h:58
LC::Entity
A message used for inter-plugin communication.
Definition:
structures.h:118
LC::Entity::Parameters_
TaskParameters Parameters_
Parameters of this task.
Definition:
structures.h:175
LC::NotPersistent
Definition:
structures.h:81
LC::Entity::Additional_
QMap< QString, QVariant > Additional_
Additional parameters.
Definition:
structures.h:187
LC::FromUserInitiated
Definition:
structures.h:67
operator>>
QDataStream & operator>>(QDataStream &in, LC::Entity &e)
Definition:
structuresops.cpp:44
LC::AutoAccept
Definition:
structures.h:101
LC::DoNotAnnounceEntity
Definition:
structures.h:86
LC::Entity::Mime_
QString Mime_
MIME type of the entity.
Definition:
structures.h:171
LC::NoAutostart
Definition:
structures.h:54
LC::FromCommandLine
Definition:
structures.h:106
LC::Entity::Entity_
QVariant Entity_
The entity that this object represents.
Definition:
structures.h:135
structuresops.h
LC
Definition:
constants.h:34
LC::OnlyHandle
Definition:
structures.h:91
LC::Entity::Location_
QString Location_
Source or destination.
Definition:
structures.h:145
LC::IsDownloaded
Definition:
structures.h:63
LC::operator==
bool operator==(const ANBoolFieldValue &left, const ANBoolFieldValue &right)
Compares two fields with boolean values.
Definition:
ianemitter.h:177
LC::operator<
bool operator<(const LC::Entity &e1, const LC::Entity &e2)
Definition:
structuresops.cpp:130
LC::OnlyDownload
Definition:
structures.h:96
LC::Internal
Definition:
structures.h:76
src
util
structuresops.cpp
Generated by
1.8.16