LeechCraft  0.6.70-13729-g7046a9d2a7
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)
59  if (parameters & LC::DoNotSaveInHistory)
61  if (parameters & LC::IsDownloaded)
63  if (parameters & LC::FromUserInitiated)
65  if (parameters & LC::DoNotNotifyUser)
67  if (parameters & LC::Internal)
69  if (parameters & LC::NotPersistent)
71  if (parameters & LC::DoNotAnnounceEntity)
73  if (parameters & LC::OnlyHandle)
75  if (parameters & LC::OnlyDownload)
77  if (parameters & LC::AutoAccept)
79  if (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)
96  if (parameters & LC::DoNotSaveInHistory)
98  if (parameters & LC::IsDownloaded)
100  if (parameters & LC::FromUserInitiated)
102  if (parameters & LC::DoNotNotifyUser)
104  if (parameters & LC::Internal)
106  if (parameters & LC::NotPersistent)
108  if (parameters & LC::DoNotAnnounceEntity)
110  if (parameters & LC::OnlyHandle)
112  if (parameters & LC::OnlyDownload)
114  if (parameters & LC::AutoAccept)
116  if (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 }
QString Mime_
MIME type of the entity.
Definition: structures.h:172
TaskParameters Parameters_
Parameters of this task.
Definition: structures.h:176
QVariant Entity_
The entity that this object represents.
Definition: structures.h:136
QMap< QString, QVariant > Additional_
Additional parameters.
Definition: structures.h:188
bool operator<(const LC::Entity &e1, const LC::Entity &e2)
A message used for inter-plugin communication.
Definition: structures.h:119
bool operator==(const ANBoolFieldValue &left, const ANBoolFieldValue &right)
Compares two fields with boolean values.
Definition: ianemitter.h:152
QDataStream & operator>>(QDataStream &in, LC::Entity &e)
QString Location_
Source or destination.
Definition: structures.h:146
Definition: constants.h:35
QDataStream & operator<<(QDataStream &out, const LC::Entity &e)