LeechCraft  0.6.70-15082-g543737046d
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  * 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 
12 QDataStream& 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 
24 QDataStream& 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 
108 namespace 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 }
LC::DoNotNotifyUser
@ DoNotNotifyUser
Definition: structures.h:48
operator<<
QDataStream & operator<<(QDataStream &out, const LC::Entity &e)
Definition: structuresops.cpp:12
LC::DoNotSaveInHistory
@ DoNotSaveInHistory
Definition: structures.h:35
LC::Entity
A message used for inter-plugin communication.
Definition: structures.h:95
LC::Entity::Parameters_
TaskParameters Parameters_
Parameters of this task.
Definition: structures.h:152
LC::NotPersistent
@ NotPersistent
Definition: structures.h:58
LC::Entity::Additional_
QMap< QString, QVariant > Additional_
Additional parameters.
Definition: structures.h:164
LC::FromUserInitiated
@ FromUserInitiated
Definition: structures.h:44
operator>>
QDataStream & operator>>(QDataStream &in, LC::Entity &e)
Definition: structuresops.cpp:24
LC::AutoAccept
@ AutoAccept
Definition: structures.h:78
LC::DoNotAnnounceEntity
@ DoNotAnnounceEntity
Definition: structures.h:63
LC::Entity::Mime_
QString Mime_
MIME type of the entity.
Definition: structures.h:148
LC::NoAutostart
@ NoAutostart
Definition: structures.h:31
LC::FromCommandLine
@ FromCommandLine
Definition: structures.h:83
LC::Entity::Entity_
QVariant Entity_
The entity that this object represents.
Definition: structures.h:112
structuresops.h
LC
Definition: constants.h:14
LC::operator==
bool operator==(const LC::Entity &e1, const LC::Entity &e2)
Definition: structuresops.cpp:117
LC::OnlyHandle
@ OnlyHandle
Definition: structures.h:68
LC::Entity::Location_
QString Location_
Source or destination.
Definition: structures.h:122
LC::IsDownloaded
@ IsDownloaded
Definition: structures.h:40
LC::operator<
bool operator<(const LC::Entity &e1, const LC::Entity &e2)
Definition: structuresops.cpp:110
LC::OnlyDownload
@ OnlyDownload
Definition: structures.h:73
LC::Internal
@ Internal
Definition: structures.h:53