LeechCraft  %{LEECHCRAFT_VERSION}
Modular cross-platform feature rich live environment.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
structuresops.cpp
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2013 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 LeechCraft::Entity& e)
33 {
34  quint16 version = 2;
35  out << version
36  << e.Entity_
37  << e.Location_
38  << e.Mime_
39  << (int) e.Parameters_
40  << e.Additional_;
41  return out;
42 }
43 
44 
45 QDataStream& operator>> (QDataStream& in, LeechCraft::Entity& e)
46 {
47  quint16 version = 0;
48  in >> version;
49  if (version == 2)
50  {
51  int parameters;
52  in >> e.Entity_
53  >> e.Location_
54  >> e.Mime_
55  >> parameters
56  >> e.Additional_;
57 
58  if (parameters & LeechCraft::NoAutostart)
60  if (parameters & LeechCraft::DoNotSaveInHistory)
62  if (parameters & LeechCraft::IsDownloaded)
64  if (parameters & LeechCraft::FromUserInitiated)
66  if (parameters & LeechCraft::DoNotNotifyUser)
68  if (parameters & LeechCraft::Internal)
70  if (parameters & LeechCraft::NotPersistent)
72  if (parameters & LeechCraft::DoNotAnnounceEntity)
74  if (parameters & LeechCraft::OnlyHandle)
76  if (parameters & LeechCraft::OnlyDownload)
78  if (parameters & LeechCraft::AutoAccept)
80  if (parameters & LeechCraft::ShouldQuerySource)
82  }
83  else if (version == 1)
84  {
85  QByteArray buf;
86  int parameters;
87  in >> buf
88  >> e.Location_
89  >> e.Mime_
90  >> parameters
91  >> e.Additional_;
92 
93  e.Entity_ = buf;
94 
95  if (parameters & LeechCraft::NoAutostart)
97  if (parameters & LeechCraft::DoNotSaveInHistory)
99  if (parameters & LeechCraft::IsDownloaded)
101  if (parameters & LeechCraft::FromUserInitiated)
103  if (parameters & LeechCraft::DoNotNotifyUser)
105  if (parameters & LeechCraft::Internal)
107  if (parameters & LeechCraft::NotPersistent)
109  if (parameters & LeechCraft::DoNotAnnounceEntity)
111  if (parameters & LeechCraft::OnlyHandle)
113  if (parameters & LeechCraft::OnlyDownload)
115  if (parameters & LeechCraft::AutoAccept)
117  if (parameters & LeechCraft::ShouldQuerySource)
119  }
120  else
121  {
122  qWarning () << Q_FUNC_INFO
123  << "unknown version"
124  << "version";
125  }
126  return in;
127 }
128 
129 namespace LeechCraft
130 {
132  {
133  return e1.Mime_ < e2.Mime_ &&
134  e1.Location_ < e2.Location_ &&
135  e1.Parameters_ < e2.Parameters_;
136  }
137 
139  {
140  return e1.Mime_ == e2.Mime_ &&
141  e1.Entity_ == e2.Entity_ &&
142  e1.Location_ == e2.Location_ &&
143  e1.Parameters_ == e2.Parameters_ &&
144  e1.Additional_ == e2.Additional_;
145  }
146 }
QDebug operator<<(QDebug dbg, const LeechCraft::Util::TreeItem &item)
Definition: treeitem.cpp:116
TaskParameters Parameters_
Parameters of this task.
Definition: structures.h:216
bool operator<(const LeechCraft::Entity &e1, const LeechCraft::Entity &e2)
bool operator==(const LeechCraft::Entity &e1, const LeechCraft::Entity &e2)
QDataStream & operator>>(QDataStream &in, LeechCraft::Entity &e)
QMap< QString, QVariant > Additional_
Additional parameters.
Definition: structures.h:228
QString Mime_
MIME type of the entity.
Definition: structures.h:212
QVariant Entity_
The entity that this object represents.
Definition: structures.h:176
Describes parameters of an entity.
Definition: structures.h:157
QString Location_
Source or destination.
Definition: structures.h:186