summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Ulrich <christian@rechenwerk.net>2016-02-19 22:10:37 +0100
committerChristian Ulrich <christian@rechenwerk.net>2016-02-19 22:10:37 +0100
commit0567a594dd93158b404fd8b8bd37a58eddf023fc (patch)
treeb65420217cd2d11b684de19e9f0ec3a5b6d33445
downloadredthread-0567a594dd93158b404fd8b8bd37a58eddf023fc.tar.gz
redthread-0567a594dd93158b404fd8b8bd37a58eddf023fc.zip
initial commit
-rw-r--r--trunk/CMakeLists.txt29
-rw-r--r--trunk/COPYING674
-rw-r--r--trunk/README13
-rw-r--r--trunk/cmake/Modules/FindGnunet.cmake93
-rw-r--r--trunk/cmake/Modules/FindSIGC++.cmake43
-rw-r--r--trunk/cmake/Modules/FindSigC++.cmake92
-rw-r--r--trunk/config.h9
-rw-r--r--trunk/config.h.in9
-rw-r--r--trunk/doc/redthread.doxy6
-rw-r--r--trunk/include/AbstractConversationListModel.hpp22
-rw-r--r--trunk/include/AbstractConversationModel.hpp22
-rw-r--r--trunk/include/AbstractFriendListModel.hpp31
-rw-r--r--trunk/include/AbstractIdentityListModel.hpp26
-rw-r--r--trunk/include/AbstractSecushareController.hpp131
-rw-r--r--trunk/include/AbstractSecushareView.hpp124
-rw-r--r--trunk/include/AbstractUserConfigModel.hpp24
-rw-r--r--trunk/include/AbstractUserInfoListModel.hpp19
-rw-r--r--trunk/include/AbstractUserInfoModel.hpp35
-rw-r--r--trunk/include/Identity.hpp49
-rw-r--r--trunk/include/NotifyPipe.hpp23
-rw-r--r--trunk/include/Place.hpp36
-rw-r--r--trunk/include/QtUserConfigModel.hpp28
-rw-r--r--trunk/include/RedThreadQt.hpp39
-rw-r--r--trunk/include/SecushareQtController.hpp41
-rw-r--r--trunk/include/SecushareQtView.hpp56
-rw-r--r--trunk/include/Signal.hpp26
-rw-r--r--trunk/src/AbstractSecushareController.cpp242
-rw-r--r--trunk/src/AbstractSecushareView.cpp13
-rw-r--r--trunk/src/AbstractUserConfigModel.cpp8
-rw-r--r--trunk/src/CMakeLists.txt61
-rw-r--r--trunk/src/Identity.cpp27
-rw-r--r--trunk/src/NotifyPipe.cpp36
-rw-r--r--trunk/src/Place.cpp9
-rw-r--r--trunk/src/QtUserConfigModel.cpp44
-rw-r--r--trunk/src/RedThreadQt.cpp40
-rw-r--r--trunk/src/SecushareQtController.cpp44
-rw-r--r--trunk/src/SecushareQtView.cpp77
-rw-r--r--trunk/src/main.cpp21
-rw-r--r--trunk/test/CMakeLists.txt5
-rw-r--r--trunk/ui/application.qml30
40 files changed, 2357 insertions, 0 deletions
diff --git a/trunk/CMakeLists.txt b/trunk/CMakeLists.txt
new file mode 100644
index 0000000..719ecac
--- /dev/null
+++ b/trunk/CMakeLists.txt
@@ -0,0 +1,29 @@
1cmake_minimum_required(VERSION 2.8.12)
2
3project(redthread)
4set(redthread_VERSION_MAJOR 0)
5set(redthread_VERSION_MINOR 1)
6
7#set(CONFIG_FILE "~/config.yml" CACHE STRING "config file path")
8#set(STORAGE_DIR "~/" CACHE STRING "storage file directory")
9
10# configuration header file
11configure_file(
12 ${PROJECT_SOURCE_DIR}/config.h.in
13 ${PROJECT_SOURCE_DIR}/config.h
14)
15
16set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
17set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
18set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
19
20set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
21
22add_subdirectory(src)
23add_subdirectory(test)
24
25# Turn on verbose Makefiles for debugging
26set(CMAKE_VERBOSE_MAKEFILE on CACHE BOOL "" FORCE)
27
28message("System: ${CMAKE_SYSTEM_NAME}")
29message("Compiler: ${CMAKE_CXX_COMPILER_ID}")
diff --git a/trunk/COPYING b/trunk/COPYING
new file mode 100644
index 0000000..94a9ed0
--- /dev/null
+++ b/trunk/COPYING
@@ -0,0 +1,674 @@
1 GNU GENERAL PUBLIC LICENSE
2 Version 3, 29 June 2007
3
4 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5 Everyone is permitted to copy and distribute verbatim copies
6 of this license document, but changing it is not allowed.
7
8 Preamble
9
10 The GNU General Public License is a free, copyleft license for
11software and other kinds of works.
12
13 The licenses for most software and other practical works are designed
14to take away your freedom to share and change the works. By contrast,
15the GNU General Public License is intended to guarantee your freedom to
16share and change all versions of a program--to make sure it remains free
17software for all its users. We, the Free Software Foundation, use the
18GNU General Public License for most of our software; it applies also to
19any other work released this way by its authors. You can apply it to
20your programs, too.
21
22 When we speak of free software, we are referring to freedom, not
23price. Our General Public Licenses are designed to make sure that you
24have the freedom to distribute copies of free software (and charge for
25them if you wish), that you receive source code or can get it if you
26want it, that you can change the software or use pieces of it in new
27free programs, and that you know you can do these things.
28
29 To protect your rights, we need to prevent others from denying you
30these rights or asking you to surrender the rights. Therefore, you have
31certain responsibilities if you distribute copies of the software, or if
32you modify it: responsibilities to respect the freedom of others.
33
34 For example, if you distribute copies of such a program, whether
35gratis or for a fee, you must pass on to the recipients the same
36freedoms that you received. You must make sure that they, too, receive
37or can get the source code. And you must show them these terms so they
38know their rights.
39
40 Developers that use the GNU GPL protect your rights with two steps:
41(1) assert copyright on the software, and (2) offer you this License
42giving you legal permission to copy, distribute and/or modify it.
43
44 For the developers' and authors' protection, the GPL clearly explains
45that there is no warranty for this free software. For both users' and
46authors' sake, the GPL requires that modified versions be marked as
47changed, so that their problems will not be attributed erroneously to
48authors of previous versions.
49
50 Some devices are designed to deny users access to install or run
51modified versions of the software inside them, although the manufacturer
52can do so. This is fundamentally incompatible with the aim of
53protecting users' freedom to change the software. The systematic
54pattern of such abuse occurs in the area of products for individuals to
55use, which is precisely where it is most unacceptable. Therefore, we
56have designed this version of the GPL to prohibit the practice for those
57products. If such problems arise substantially in other domains, we
58stand ready to extend this provision to those domains in future versions
59of the GPL, as needed to protect the freedom of users.
60
61 Finally, every program is threatened constantly by software patents.
62States should not allow patents to restrict development and use of
63software on general-purpose computers, but in those that do, we wish to
64avoid the special danger that patents applied to a free program could
65make it effectively proprietary. To prevent this, the GPL assures that
66patents cannot be used to render the program non-free.
67
68 The precise terms and conditions for copying, distribution and
69modification follow.
70
71 TERMS AND CONDITIONS
72
73 0. Definitions.
74
75 "This License" refers to version 3 of the GNU General Public License.
76
77 "Copyright" also means copyright-like laws that apply to other kinds of
78works, such as semiconductor masks.
79
80 "The Program" refers to any copyrightable work licensed under this
81License. Each licensee is addressed as "you". "Licensees" and
82"recipients" may be individuals or organizations.
83
84 To "modify" a work means to copy from or adapt all or part of the work
85in a fashion requiring copyright permission, other than the making of an
86exact copy. The resulting work is called a "modified version" of the
87earlier work or a work "based on" the earlier work.
88
89 A "covered work" means either the unmodified Program or a work based
90on the Program.
91
92 To "propagate" a work means to do anything with it that, without
93permission, would make you directly or secondarily liable for
94infringement under applicable copyright law, except executing it on a
95computer or modifying a private copy. Propagation includes copying,
96distribution (with or without modification), making available to the
97public, and in some countries other activities as well.
98
99 To "convey" a work means any kind of propagation that enables other
100parties to make or receive copies. Mere interaction with a user through
101a computer network, with no transfer of a copy, is not conveying.
102
103 An interactive user interface displays "Appropriate Legal Notices"
104to the extent that it includes a convenient and prominently visible
105feature that (1) displays an appropriate copyright notice, and (2)
106tells the user that there is no warranty for the work (except to the
107extent that warranties are provided), that licensees may convey the
108work under this License, and how to view a copy of this License. If
109the interface presents a list of user commands or options, such as a
110menu, a prominent item in the list meets this criterion.
111
112 1. Source Code.
113
114 The "source code" for a work means the preferred form of the work
115for making modifications to it. "Object code" means any non-source
116form of a work.
117
118 A "Standard Interface" means an interface that either is an official
119standard defined by a recognized standards body, or, in the case of
120interfaces specified for a particular programming language, one that
121is widely used among developers working in that language.
122
123 The "System Libraries" of an executable work include anything, other
124than the work as a whole, that (a) is included in the normal form of
125packaging a Major Component, but which is not part of that Major
126Component, and (b) serves only to enable use of the work with that
127Major Component, or to implement a Standard Interface for which an
128implementation is available to the public in source code form. A
129"Major Component", in this context, means a major essential component
130(kernel, window system, and so on) of the specific operating system
131(if any) on which the executable work runs, or a compiler used to
132produce the work, or an object code interpreter used to run it.
133
134 The "Corresponding Source" for a work in object code form means all
135the source code needed to generate, install, and (for an executable
136work) run the object code and to modify the work, including scripts to
137control those activities. However, it does not include the work's
138System Libraries, or general-purpose tools or generally available free
139programs which are used unmodified in performing those activities but
140which are not part of the work. For example, Corresponding Source
141includes interface definition files associated with source files for
142the work, and the source code for shared libraries and dynamically
143linked subprograms that the work is specifically designed to require,
144such as by intimate data communication or control flow between those
145subprograms and other parts of the work.
146
147 The Corresponding Source need not include anything that users
148can regenerate automatically from other parts of the Corresponding
149Source.
150
151 The Corresponding Source for a work in source code form is that
152same work.
153
154 2. Basic Permissions.
155
156 All rights granted under this License are granted for the term of
157copyright on the Program, and are irrevocable provided the stated
158conditions are met. This License explicitly affirms your unlimited
159permission to run the unmodified Program. The output from running a
160covered work is covered by this License only if the output, given its
161content, constitutes a covered work. This License acknowledges your
162rights of fair use or other equivalent, as provided by copyright law.
163
164 You may make, run and propagate covered works that you do not
165convey, without conditions so long as your license otherwise remains
166in force. You may convey covered works to others for the sole purpose
167of having them make modifications exclusively for you, or provide you
168with facilities for running those works, provided that you comply with
169the terms of this License in conveying all material for which you do
170not control copyright. Those thus making or running the covered works
171for you must do so exclusively on your behalf, under your direction
172and control, on terms that prohibit them from making any copies of
173your copyrighted material outside their relationship with you.
174
175 Conveying under any other circumstances is permitted solely under
176the conditions stated below. Sublicensing is not allowed; section 10
177makes it unnecessary.
178
179 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
181 No covered work shall be deemed part of an effective technological
182measure under any applicable law fulfilling obligations under article
18311 of the WIPO copyright treaty adopted on 20 December 1996, or
184similar laws prohibiting or restricting circumvention of such
185measures.
186
187 When you convey a covered work, you waive any legal power to forbid
188circumvention of technological measures to the extent such circumvention
189is effected by exercising rights under this License with respect to
190the covered work, and you disclaim any intention to limit operation or
191modification of the work as a means of enforcing, against the work's
192users, your or third parties' legal rights to forbid circumvention of
193technological measures.
194
195 4. Conveying Verbatim Copies.
196
197 You may convey verbatim copies of the Program's source code as you
198receive it, in any medium, provided that you conspicuously and
199appropriately publish on each copy an appropriate copyright notice;
200keep intact all notices stating that this License and any
201non-permissive terms added in accord with section 7 apply to the code;
202keep intact all notices of the absence of any warranty; and give all
203recipients a copy of this License along with the Program.
204
205 You may charge any price or no price for each copy that you convey,
206and you may offer support or warranty protection for a fee.
207
208 5. Conveying Modified Source Versions.
209
210 You may convey a work based on the Program, or the modifications to
211produce it from the Program, in the form of source code under the
212terms of section 4, provided that you also meet all of these conditions:
213
214 a) The work must carry prominent notices stating that you modified
215 it, and giving a relevant date.
216
217 b) The work must carry prominent notices stating that it is
218 released under this License and any conditions added under section
219 7. This requirement modifies the requirement in section 4 to
220 "keep intact all notices".
221
222 c) You must license the entire work, as a whole, under this
223 License to anyone who comes into possession of a copy. This
224 License will therefore apply, along with any applicable section 7
225 additional terms, to the whole of the work, and all its parts,
226 regardless of how they are packaged. This License gives no
227 permission to license the work in any other way, but it does not
228 invalidate such permission if you have separately received it.
229
230 d) If the work has interactive user interfaces, each must display
231 Appropriate Legal Notices; however, if the Program has interactive
232 interfaces that do not display Appropriate Legal Notices, your
233 work need not make them do so.
234
235 A compilation of a covered work with other separate and independent
236works, which are not by their nature extensions of the covered work,
237and which are not combined with it such as to form a larger program,
238in or on a volume of a storage or distribution medium, is called an
239"aggregate" if the compilation and its resulting copyright are not
240used to limit the access or legal rights of the compilation's users
241beyond what the individual works permit. Inclusion of a covered work
242in an aggregate does not cause this License to apply to the other
243parts of the aggregate.
244
245 6. Conveying Non-Source Forms.
246
247 You may convey a covered work in object code form under the terms
248of sections 4 and 5, provided that you also convey the
249machine-readable Corresponding Source under the terms of this License,
250in one of these ways:
251
252 a) Convey the object code in, or embodied in, a physical product
253 (including a physical distribution medium), accompanied by the
254 Corresponding Source fixed on a durable physical medium
255 customarily used for software interchange.
256
257 b) Convey the object code in, or embodied in, a physical product
258 (including a physical distribution medium), accompanied by a
259 written offer, valid for at least three years and valid for as
260 long as you offer spare parts or customer support for that product
261 model, to give anyone who possesses the object code either (1) a
262 copy of the Corresponding Source for all the software in the
263 product that is covered by this License, on a durable physical
264 medium customarily used for software interchange, for a price no
265 more than your reasonable cost of physically performing this
266 conveying of source, or (2) access to copy the
267 Corresponding Source from a network server at no charge.
268
269 c) Convey individual copies of the object code with a copy of the
270 written offer to provide the Corresponding Source. This
271 alternative is allowed only occasionally and noncommercially, and
272 only if you received the object code with such an offer, in accord
273 with subsection 6b.
274
275 d) Convey the object code by offering access from a designated
276 place (gratis or for a charge), and offer equivalent access to the
277 Corresponding Source in the same way through the same place at no
278 further charge. You need not require recipients to copy the
279 Corresponding Source along with the object code. If the place to
280 copy the object code is a network server, the Corresponding Source
281 may be on a different server (operated by you or a third party)
282 that supports equivalent copying facilities, provided you maintain
283 clear directions next to the object code saying where to find the
284 Corresponding Source. Regardless of what server hosts the
285 Corresponding Source, you remain obligated to ensure that it is
286 available for as long as needed to satisfy these requirements.
287
288 e) Convey the object code using peer-to-peer transmission, provided
289 you inform other peers where the object code and Corresponding
290 Source of the work are being offered to the general public at no
291 charge under subsection 6d.
292
293 A separable portion of the object code, whose source code is excluded
294from the Corresponding Source as a System Library, need not be
295included in conveying the object code work.
296
297 A "User Product" is either (1) a "consumer product", which means any
298tangible personal property which is normally used for personal, family,
299or household purposes, or (2) anything designed or sold for incorporation
300into a dwelling. In determining whether a product is a consumer product,
301doubtful cases shall be resolved in favor of coverage. For a particular
302product received by a particular user, "normally used" refers to a
303typical or common use of that class of product, regardless of the status
304of the particular user or of the way in which the particular user
305actually uses, or expects or is expected to use, the product. A product
306is a consumer product regardless of whether the product has substantial
307commercial, industrial or non-consumer uses, unless such uses represent
308the only significant mode of use of the product.
309
310 "Installation Information" for a User Product means any methods,
311procedures, authorization keys, or other information required to install
312and execute modified versions of a covered work in that User Product from
313a modified version of its Corresponding Source. The information must
314suffice to ensure that the continued functioning of the modified object
315code is in no case prevented or interfered with solely because
316modification has been made.
317
318 If you convey an object code work under this section in, or with, or
319specifically for use in, a User Product, and the conveying occurs as
320part of a transaction in which the right of possession and use of the
321User Product is transferred to the recipient in perpetuity or for a
322fixed term (regardless of how the transaction is characterized), the
323Corresponding Source conveyed under this section must be accompanied
324by the Installation Information. But this requirement does not apply
325if neither you nor any third party retains the ability to install
326modified object code on the User Product (for example, the work has
327been installed in ROM).
328
329 The requirement to provide Installation Information does not include a
330requirement to continue to provide support service, warranty, or updates
331for a work that has been modified or installed by the recipient, or for
332the User Product in which it has been modified or installed. Access to a
333network may be denied when the modification itself materially and
334adversely affects the operation of the network or violates the rules and
335protocols for communication across the network.
336
337 Corresponding Source conveyed, and Installation Information provided,
338in accord with this section must be in a format that is publicly
339documented (and with an implementation available to the public in
340source code form), and must require no special password or key for
341unpacking, reading or copying.
342
343 7. Additional Terms.
344
345 "Additional permissions" are terms that supplement the terms of this
346License by making exceptions from one or more of its conditions.
347Additional permissions that are applicable to the entire Program shall
348be treated as though they were included in this License, to the extent
349that they are valid under applicable law. If additional permissions
350apply only to part of the Program, that part may be used separately
351under those permissions, but the entire Program remains governed by
352this License without regard to the additional permissions.
353
354 When you convey a copy of a covered work, you may at your option
355remove any additional permissions from that copy, or from any part of
356it. (Additional permissions may be written to require their own
357removal in certain cases when you modify the work.) You may place
358additional permissions on material, added by you to a covered work,
359for which you have or can give appropriate copyright permission.
360
361 Notwithstanding any other provision of this License, for material you
362add to a covered work, you may (if authorized by the copyright holders of
363that material) supplement the terms of this License with terms:
364
365 a) Disclaiming warranty or limiting liability differently from the
366 terms of sections 15 and 16 of this License; or
367
368 b) Requiring preservation of specified reasonable legal notices or
369 author attributions in that material or in the Appropriate Legal
370 Notices displayed by works containing it; or
371
372 c) Prohibiting misrepresentation of the origin of that material, or
373 requiring that modified versions of such material be marked in
374 reasonable ways as different from the original version; or
375
376 d) Limiting the use for publicity purposes of names of licensors or
377 authors of the material; or
378
379 e) Declining to grant rights under trademark law for use of some
380 trade names, trademarks, or service marks; or
381
382 f) Requiring indemnification of licensors and authors of that
383 material by anyone who conveys the material (or modified versions of
384 it) with contractual assumptions of liability to the recipient, for
385 any liability that these contractual assumptions directly impose on
386 those licensors and authors.
387
388 All other non-permissive additional terms are considered "further
389restrictions" within the meaning of section 10. If the Program as you
390received it, or any part of it, contains a notice stating that it is
391governed by this License along with a term that is a further
392restriction, you may remove that term. If a license document contains
393a further restriction but permits relicensing or conveying under this
394License, you may add to a covered work material governed by the terms
395of that license document, provided that the further restriction does
396not survive such relicensing or conveying.
397
398 If you add terms to a covered work in accord with this section, you
399must place, in the relevant source files, a statement of the
400additional terms that apply to those files, or a notice indicating
401where to find the applicable terms.
402
403 Additional terms, permissive or non-permissive, may be stated in the
404form of a separately written license, or stated as exceptions;
405the above requirements apply either way.
406
407 8. Termination.
408
409 You may not propagate or modify a covered work except as expressly
410provided under this License. Any attempt otherwise to propagate or
411modify it is void, and will automatically terminate your rights under
412this License (including any patent licenses granted under the third
413paragraph of section 11).
414
415 However, if you cease all violation of this License, then your
416license from a particular copyright holder is reinstated (a)
417provisionally, unless and until the copyright holder explicitly and
418finally terminates your license, and (b) permanently, if the copyright
419holder fails to notify you of the violation by some reasonable means
420prior to 60 days after the cessation.
421
422 Moreover, your license from a particular copyright holder is
423reinstated permanently if the copyright holder notifies you of the
424violation by some reasonable means, this is the first time you have
425received notice of violation of this License (for any work) from that
426copyright holder, and you cure the violation prior to 30 days after
427your receipt of the notice.
428
429 Termination of your rights under this section does not terminate the
430licenses of parties who have received copies or rights from you under
431this License. If your rights have been terminated and not permanently
432reinstated, you do not qualify to receive new licenses for the same
433material under section 10.
434
435 9. Acceptance Not Required for Having Copies.
436
437 You are not required to accept this License in order to receive or
438run a copy of the Program. Ancillary propagation of a covered work
439occurring solely as a consequence of using peer-to-peer transmission
440to receive a copy likewise does not require acceptance. However,
441nothing other than this License grants you permission to propagate or
442modify any covered work. These actions infringe copyright if you do
443not accept this License. Therefore, by modifying or propagating a
444covered work, you indicate your acceptance of this License to do so.
445
446 10. Automatic Licensing of Downstream Recipients.
447
448 Each time you convey a covered work, the recipient automatically
449receives a license from the original licensors, to run, modify and
450propagate that work, subject to this License. You are not responsible
451for enforcing compliance by third parties with this License.
452
453 An "entity transaction" is a transaction transferring control of an
454organization, or substantially all assets of one, or subdividing an
455organization, or merging organizations. If propagation of a covered
456work results from an entity transaction, each party to that
457transaction who receives a copy of the work also receives whatever
458licenses to the work the party's predecessor in interest had or could
459give under the previous paragraph, plus a right to possession of the
460Corresponding Source of the work from the predecessor in interest, if
461the predecessor has it or can get it with reasonable efforts.
462
463 You may not impose any further restrictions on the exercise of the
464rights granted or affirmed under this License. For example, you may
465not impose a license fee, royalty, or other charge for exercise of
466rights granted under this License, and you may not initiate litigation
467(including a cross-claim or counterclaim in a lawsuit) alleging that
468any patent claim is infringed by making, using, selling, offering for
469sale, or importing the Program or any portion of it.
470
471 11. Patents.
472
473 A "contributor" is a copyright holder who authorizes use under this
474License of the Program or a work on which the Program is based. The
475work thus licensed is called the contributor's "contributor version".
476
477 A contributor's "essential patent claims" are all patent claims
478owned or controlled by the contributor, whether already acquired or
479hereafter acquired, that would be infringed by some manner, permitted
480by this License, of making, using, or selling its contributor version,
481but do not include claims that would be infringed only as a
482consequence of further modification of the contributor version. For
483purposes of this definition, "control" includes the right to grant
484patent sublicenses in a manner consistent with the requirements of
485this License.
486
487 Each contributor grants you a non-exclusive, worldwide, royalty-free
488patent license under the contributor's essential patent claims, to
489make, use, sell, offer for sale, import and otherwise run, modify and
490propagate the contents of its contributor version.
491
492 In the following three paragraphs, a "patent license" is any express
493agreement or commitment, however denominated, not to enforce a patent
494(such as an express permission to practice a patent or covenant not to
495sue for patent infringement). To "grant" such a patent license to a
496party means to make such an agreement or commitment not to enforce a
497patent against the party.
498
499 If you convey a covered work, knowingly relying on a patent license,
500and the Corresponding Source of the work is not available for anyone
501to copy, free of charge and under the terms of this License, through a
502publicly available network server or other readily accessible means,
503then you must either (1) cause the Corresponding Source to be so
504available, or (2) arrange to deprive yourself of the benefit of the
505patent license for this particular work, or (3) arrange, in a manner
506consistent with the requirements of this License, to extend the patent
507license to downstream recipients. "Knowingly relying" means you have
508actual knowledge that, but for the patent license, your conveying the
509covered work in a country, or your recipient's use of the covered work
510in a country, would infringe one or more identifiable patents in that
511country that you have reason to believe are valid.
512
513 If, pursuant to or in connection with a single transaction or
514arrangement, you convey, or propagate by procuring conveyance of, a
515covered work, and grant a patent license to some of the parties
516receiving the covered work authorizing them to use, propagate, modify
517or convey a specific copy of the covered work, then the patent license
518you grant is automatically extended to all recipients of the covered
519work and works based on it.
520
521 A patent license is "discriminatory" if it does not include within
522the scope of its coverage, prohibits the exercise of, or is
523conditioned on the non-exercise of one or more of the rights that are
524specifically granted under this License. You may not convey a covered
525work if you are a party to an arrangement with a third party that is
526in the business of distributing software, under which you make payment
527to the third party based on the extent of your activity of conveying
528the work, and under which the third party grants, to any of the
529parties who would receive the covered work from you, a discriminatory
530patent license (a) in connection with copies of the covered work
531conveyed by you (or copies made from those copies), or (b) primarily
532for and in connection with specific products or compilations that
533contain the covered work, unless you entered into that arrangement,
534or that patent license was granted, prior to 28 March 2007.
535
536 Nothing in this License shall be construed as excluding or limiting
537any implied license or other defenses to infringement that may
538otherwise be available to you under applicable patent law.
539
540 12. No Surrender of Others' Freedom.
541
542 If conditions are imposed on you (whether by court order, agreement or
543otherwise) that contradict the conditions of this License, they do not
544excuse you from the conditions of this License. If you cannot convey a
545covered work so as to satisfy simultaneously your obligations under this
546License and any other pertinent obligations, then as a consequence you may
547not convey it at all. For example, if you agree to terms that obligate you
548to collect a royalty for further conveying from those to whom you convey
549the Program, the only way you could satisfy both those terms and this
550License would be to refrain entirely from conveying the Program.
551
552 13. Use with the GNU Affero General Public License.
553
554 Notwithstanding any other provision of this License, you have
555permission to link or combine any covered work with a work licensed
556under version 3 of the GNU Affero General Public License into a single
557combined work, and to convey the resulting work. The terms of this
558License will continue to apply to the part which is the covered work,
559but the special requirements of the GNU Affero General Public License,
560section 13, concerning interaction through a network will apply to the
561combination as such.
562
563 14. Revised Versions of this License.
564
565 The Free Software Foundation may publish revised and/or new versions of
566the GNU General Public License from time to time. Such new versions will
567be similar in spirit to the present version, but may differ in detail to
568address new problems or concerns.
569
570 Each version is given a distinguishing version number. If the
571Program specifies that a certain numbered version of the GNU General
572Public License "or any later version" applies to it, you have the
573option of following the terms and conditions either of that numbered
574version or of any later version published by the Free Software
575Foundation. If the Program does not specify a version number of the
576GNU General Public License, you may choose any version ever published
577by the Free Software Foundation.
578
579 If the Program specifies that a proxy can decide which future
580versions of the GNU General Public License can be used, that proxy's
581public statement of acceptance of a version permanently authorizes you
582to choose that version for the Program.
583
584 Later license versions may give you additional or different
585permissions. However, no additional obligations are imposed on any
586author or copyright holder as a result of your choosing to follow a
587later version.
588
589 15. Disclaimer of Warranty.
590
591 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
600 16. Limitation of Liability.
601
602 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610SUCH DAMAGES.
611
612 17. Interpretation of Sections 15 and 16.
613
614 If the disclaimer of warranty and limitation of liability provided
615above cannot be given local legal effect according to their terms,
616reviewing courts shall apply local law that most closely approximates
617an absolute waiver of all civil liability in connection with the
618Program, unless a warranty or assumption of liability accompanies a
619copy of the Program in return for a fee.
620
621 END OF TERMS AND CONDITIONS
622
623 How to Apply These Terms to Your New Programs
624
625 If you develop a new program, and you want it to be of the greatest
626possible use to the public, the best way to achieve this is to make it
627free software which everyone can redistribute and change under these terms.
628
629 To do so, attach the following notices to the program. It is safest
630to attach them to the start of each source file to most effectively
631state the exclusion of warranty; and each file should have at least
632the "copyright" line and a pointer to where the full notice is found.
633
634 <one line to give the program's name and a brief idea of what it does.>
635 Copyright (C) <year> <name of author>
636
637 This program is free software: you can redistribute it and/or modify
638 it under the terms of the GNU General Public License as published by
639 the Free Software Foundation, either version 3 of the License, or
640 (at your option) any later version.
641
642 This program is distributed in the hope that it will be useful,
643 but WITHOUT ANY WARRANTY; without even the implied warranty of
644 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 GNU General Public License for more details.
646
647 You should have received a copy of the GNU General Public License
648 along with this program. If not, see <http://www.gnu.org/licenses/>.
649
650Also add information on how to contact you by electronic and paper mail.
651
652 If the program does terminal interaction, make it output a short
653notice like this when it starts in an interactive mode:
654
655 <program> Copyright (C) <year> <name of author>
656 This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 This is free software, and you are welcome to redistribute it
658 under certain conditions; type `show c' for details.
659
660The hypothetical commands `show w' and `show c' should show the appropriate
661parts of the General Public License. Of course, your program's commands
662might be different; for a GUI interface, you would use an "about box".
663
664 You should also get your employer (if you work as a programmer) or school,
665if any, to sign a "copyright disclaimer" for the program, if necessary.
666For more information on this, and how to apply and follow the GNU GPL, see
667<http://www.gnu.org/licenses/>.
668
669 The GNU General Public License does not permit incorporating your program
670into proprietary programs. If your program is a subroutine library, you
671may consider it more useful to permit linking proprietary applications with
672the library. If this is what you want to do, use the GNU Lesser General
673Public License instead of this License. But first, please read
674<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/trunk/README b/trunk/README
new file mode 100644
index 0000000..c9a1220
--- /dev/null
+++ b/trunk/README
@@ -0,0 +1,13 @@
1Prerequisites
2*************
3cmake >= 2.8.11
4Qt 5.x
5ncurses
6
7Compilation
8***********
9mkdir build
10cd build
11cmake ..
12make
13
diff --git a/trunk/cmake/Modules/FindGnunet.cmake b/trunk/cmake/Modules/FindGnunet.cmake
new file mode 100644
index 0000000..87cff9f
--- /dev/null
+++ b/trunk/cmake/Modules/FindGnunet.cmake
@@ -0,0 +1,93 @@
1# FindGnunet.cmake
2#
3# author: lurchi
4# date: 2016-01-31
5# version: 0.1
6#
7# Result variables:
8# - GNUNET_FOUND:
9# true if gnunet is found
10# - GNUNET_INCLUDE_DIRS:
11# the needed gnunet include directories
12# - GNUNET_LIBRARIES:
13# the needed gnunet libraries
14#
15# set GNUNET_SOCIAL_NEEDED before find_package(Gnunet) call if the social API is needed
16
17include(CheckLibraryExists)
18include(FindPackageHandleStandardArgs)
19
20set(GNUNET_LIBRARIES_OK true)
21set(GNUNET_SOCIAL_LIBRARIES_OK true)
22set(GNUNET_INCLUDE_DIRS_OK true)
23set(GNUNET_SOCIAL_INCLUDE_DIRS_OK true)
24
25# gnunet libraries
26find_library(GNUNET_CORE_LIB NAMES gnunetcore)
27find_library(GNUNET_UTIL_LIB NAMES gnunetutil)
28find_library(GNUNET_IDENTITY_LIB NAMES gnunetidentity)
29find_library(GNUNET_ARM_LIB NAMES gnunetarm)
30find_library(GNUNET_FRIENDS_LIB NAMES gnunetfriends)
31
32file(GLOB GNUNET_LIBRARIES ${GNUNET_CORE_LIB}
33 ${GNUNET_UTIL_LIB}
34 ${GNUNET_IDENTITY_LIB}
35 ${GNUNET_ARM_LIB}
36 ${GNUNET_FRIENDS_LIB})
37
38if(NOT (GNUNET_CORE_LIB AND
39 GNUNET_UTIL_LIB AND
40 GNUNET_IDENTITY_LIB AND
41 GNUNET_ARM_LIB AND
42 GNUNET_FRIENDS_LIB))
43 set(GNUNET_LIBRARIES_OK false)
44endif()
45
46# gnunet include dirs
47find_path(GNUNET_PLATFORM_H NAMES gnunet/platform.h)
48find_path(GNUNET_UTIL_LIB_H NAMES gnunet/gnunet_util_lib.h)
49
50file(GLOB GNUNET_INCLUDE_DIRS ${GNUNET_PLATFORM_H}
51 ${GNUNET_UTIL_LIB_H})
52
53if(NOT (GNUNET_PLATFORM_H AND
54 GNUNET_UTIL_LIB_H))
55 set(GNUNET_INCLUDE_DIRS_OK false)
56endif()
57
58# gnunet social API
59if(GNUNET_SOCIAL_NEEDED)
60 # gnunet social API libraries
61 find_library(GNUNET_PSYC_UTIL NAMES gnunetpsycutil)
62 find_library(GNUNET_SOCIAL NAMES gnunetsocial)
63
64 file(GLOB GNUNET_SOCIAL_LIBRARIES ${GNUNET_PSYC_UTIL}
65 ${GNUNET_SOCIAL})
66 set(GNUNET_LIBRARIES ${GNUNET_LIBRARIES} ${GNUNET_SOCIAL_LIBRARIES})
67
68 if(NOT (GNUNET_PSYC_UTIL AND GNUNET_SOCIAL))
69 set(GNUNET_SOCIAL_LIBRARIES_OK false)
70 endif()
71
72 # gnunet social include dirs
73 find_path(GNUNET_SOCIAL_SERVICE_H NAMES gnunet/gnunet_social_service.h)
74
75 file(GLOB GNUNET_SOCIAL_INCLUDE_DIRS ${GNUNET_SOCIAL_SERVICE_H})
76 set(GNUNET_INCLUDE_DIRS ${GNUNET_INCLUDE_DIRS} ${GNUNET_SOCIAL_INCLUDE_DIRS})
77
78 if(NOT (GNUNET_SOCIAL_SERVICE_H))
79 set(GNUNET_SOCIAL_INCLUDE_DIRS false)
80 endif()
81endif()
82
83list(REMOVE_DUPLICATES GNUNET_INCLUDE_DIRS)
84
85FIND_PACKAGE_HANDLE_STANDARD_ARGS(GNUNET DEFAULT_MSG GNUNET_LIBRARIES_OK
86 GNUNET_SOCIAL_LIBRARIES_OK
87 GNUNET_INCLUDE_DIRS_OK
88 GNUNET_SOCIAL_INCLUDE_DIRS_OK)
89
90mark_as_advanced(
91 GNUNET_INCLUDE_DIRS
92 GNUNET_LIBRARIES
93)
diff --git a/trunk/cmake/Modules/FindSIGC++.cmake b/trunk/cmake/Modules/FindSIGC++.cmake
new file mode 100644
index 0000000..236ee3d
--- /dev/null
+++ b/trunk/cmake/Modules/FindSIGC++.cmake
@@ -0,0 +1,43 @@
1# - Try to find SigC++-2.0
2# Once done this will define
3#
4# SIGC++_FOUND - system has SigC++
5# SIGC++_INCLUDE_DIR - the SigC++ include directory
6# SIGC++_LIBRARY - SigC++ library
7
8if(SIGC++_INCLUDE_DIR AND SIGC++_LIBRARIES)
9 # Already in cache, be silent
10 set(SIGC++_FIND_QUIETLY TRUE)
11endif(SIGC++_INCLUDE_DIR AND SIGC++_LIBRARIES)
12
13if (NOT WIN32)
14 include(FindPkgConfig)
15 pkgconfig(sigc++-2.0 _LibSIGC++IncDir _LibSIGC++LinkDir _LibSIGC++LinkFlags _LibSIGC++Cflags)
16endif(NOT WIN32)
17
18find_path(SIGC++_INCLUDE_DIR sigc++/sigc++.h
19 PATH_SUFFIXES sigc++-2.0
20 PATHS ${_LibSIGC++IncDir} )
21
22find_library(SIGC++_LIBRARY
23 NAMES sigc-2.0
24 PATHS ${_LibSIGC++LinkDir} )
25
26get_filename_component(sigc++LibDir "${SIGC++_LIBRARY}" PATH)
27
28# search the sigc++config.h include dir under the same root where the library is found
29
30find_path(SIGC++_CONFIG_INCLUDE_DIR sigc++config.h
31 PATH_SUFFIXES sigc++-2.0/include
32 PATHS ${_LibSIGC++IncDir} "${sigc++LibDir}" ${CMAKE_SYSTEM_LIBRARY_PATH})
33
34# not sure if this include dir is optional or required
35# for now it is optional
36if(SIGC++_CONFIG_INCLUDE_DIR)
37 set(SIGC++_INCLUDE_DIR ${SIGC++_INCLUDE_DIR} "${SIGC++_CONFIG_INCLUDE_DIR}")
38endif(SIGC++_CONFIG_INCLUDE_DIR)
39
40include(FindPackageHandleStandardArgs)
41find_package_handle_standard_args(SIGC++ DEFAULT_MSG SIGC++_LIBRARY SIGC++_INCLUDE_DIR)
42
43mark_as_advanced(SIGC++_INCLUDE_DIR SIGC++_LIBRARY)
diff --git a/trunk/cmake/Modules/FindSigC++.cmake b/trunk/cmake/Modules/FindSigC++.cmake
new file mode 100644
index 0000000..1a3daa6
--- /dev/null
+++ b/trunk/cmake/Modules/FindSigC++.cmake
@@ -0,0 +1,92 @@
1# - Try to find SIGC++
2# Once done this will define
3#
4# SIGC++_ROOT_DIR - Set this variable to the root installation of SIGC++
5# SIGC++_FOUND - system has SIGC++
6# SIGC++_INCLUDE_DIRS - the SIGC++ include directory
7# SIGC++_LIBRARIES - Link these to use SIGC++
8#
9# Copyright (c) 2008 Joshua L. Blocher <verbalshadow at gmail dot com>
10# Copyright (c) 2012 Dmitry Baryshnikov <polimax at mail dot ru>
11# Copyright (c) 2013 Michael Pavlyshko <pavlushko at tut dot by>
12#
13# Distributed under the OSI-approved BSD License
14#
15
16if (NOT WIN32)
17 find_package(PkgConfig)
18 if (PKG_CONFIG_FOUND)
19 pkg_check_modules(_SIGC++ sigc++-2.0)
20 endif (PKG_CONFIG_FOUND)
21endif (NOT WIN32)
22
23SET(_SIGC++_ROOT_HINTS
24 $ENV{SIGC++}
25 ${CMAKE_FIND_ROOT_PATH}
26 ${SIGC++_ROOT_DIR}
27)
28
29SET(_SIGC++_ROOT_PATHS
30 $ENV{SIGC++}/src
31 /usr
32 /usr/local
33)
34
35SET(_SIGC++_ROOT_HINTS_AND_PATHS
36 HINTS ${_SIGC++_ROOT_HINTS}
37 PATHS ${_SIGC++_ROOT_PATHS}
38)
39
40FIND_PATH(SIGC++_INCLUDE_DIR
41 NAMES
42 "sigc++/sigc++.h"
43 HINTS
44 ${_SIGC++_INCLUDEDIR}
45 ${_SIGC++_ROOT_HINTS_AND_PATHS}
46 PATH_SUFFIXES
47 include
48 "include/sigc++-2.0"
49)
50
51find_path(SIGC++_CONFIG_INCLUDE_DIR
52 NAMES
53 sigc++config.h
54 HINTS
55 ${_SIGC++_LIBDIR}
56 ${_SIGC++_INCLUDEDIR}
57 ${_SIGC++_ROOT_HINTS_AND_PATHS}
58 PATH_SUFFIXES
59 include
60 lib
61 "sigc++-2.0/include"
62 "lib/sigc++-2.0"
63 "lib/sigc++-2.0/include"
64)
65
66FIND_LIBRARY(SIGC++_LIBRARY
67 NAMES
68 sigc-2.0
69 HINTS
70 ${_SIGC++_LIBDIR}
71 ${_SIGC++_ROOT_HINTS_AND_PATHS}
72 PATH_SUFFIXES
73 "lib"
74 "local/lib"
75)
76
77SET(SIGC++_LIBRARIES
78 ${SIGC++_LIBRARY}
79)
80
81SET(SIGC++_INCLUDE_DIRS
82 ${SIGC++_INCLUDE_DIR}
83 ${SIGC++_CONFIG_INCLUDE_DIR}
84)
85
86include(FindPackageHandleStandardArgs)
87find_package_handle_standard_args(SIGC++ "Could NOT find SIGC++, try to set the path to SIGC++ root folder in the system variable SIGC++"
88 SIGC++_LIBRARIES
89 SIGC++_INCLUDE_DIRS
90)
91
92MARK_AS_ADVANCED(SIGC++_CONFIG_INCLUDE_DIR SIGC++_INCLUDE_DIR SIGC++_INCLUDE_DIRS SIGC++_LIBRARY SIGC++_LIBRARIES) \ No newline at end of file
diff --git a/trunk/config.h b/trunk/config.h
new file mode 100644
index 0000000..3a9b8a5
--- /dev/null
+++ b/trunk/config.h
@@ -0,0 +1,9 @@
1#ifndef CMAKE_CONFIG__H
2#define CMAKE_CONFIG__H
3
4/* #undef CONFIG_FILE */
5/* #undef STORAGE_DIR */
6
7#define QML_DIR "/home/christian/projects/secushare/redthread/trunk/ui"
8
9#endif
diff --git a/trunk/config.h.in b/trunk/config.h.in
new file mode 100644
index 0000000..a3a4c78
--- /dev/null
+++ b/trunk/config.h.in
@@ -0,0 +1,9 @@
1#ifndef CMAKE_CONFIG__H
2#define CMAKE_CONFIG__H
3
4#cmakedefine CONFIG_FILE "@CONFIG_FILE@"
5#cmakedefine STORAGE_DIR "@STORAGE_DIR@"
6
7#define QML_DIR "@CMAKE_SOURCE_DIR@/ui"
8
9#endif
diff --git a/trunk/doc/redthread.doxy b/trunk/doc/redthread.doxy
new file mode 100644
index 0000000..c65150d
--- /dev/null
+++ b/trunk/doc/redthread.doxy
@@ -0,0 +1,6 @@
1PROJECT_NAME = redthread
2OUTPUT_DIRECTORY = .
3OUTPUT_LANGUAGE = en
4INPUT = ../src ../include
5FILE_PATTERNS = *.cpp *.hpp
6TAGFILES = ../COPYING ../AUTHORS
diff --git a/trunk/include/AbstractConversationListModel.hpp b/trunk/include/AbstractConversationListModel.hpp
new file mode 100644
index 0000000..67929fb
--- /dev/null
+++ b/trunk/include/AbstractConversationListModel.hpp
@@ -0,0 +1,22 @@
1#ifndef REDTHREAD_ABSTRACT_CONVERSATION_LIST_MODEL__H
2#define REDTHREAD_ABSTRACT_CONVERSATION_LIST_MODEL__H
3
4#include "Place.hpp"
5
6namespace redthread
7{
8 class AbstractConversationListModel
9 {
10 public:
11 ///////
12 AbstractConversationListModel() { }
13 virtual ~AbstractConversationListModel() { }
14
15 virtual void addConversation(const Place& place) = 0;
16
17 private:
18 ////////
19 };
20}
21
22#endif
diff --git a/trunk/include/AbstractConversationModel.hpp b/trunk/include/AbstractConversationModel.hpp
new file mode 100644
index 0000000..aaaf802
--- /dev/null
+++ b/trunk/include/AbstractConversationModel.hpp
@@ -0,0 +1,22 @@
1#ifndef REDTHREAD_ABSTRACT_CONVERSATION_MODEL__H
2#define REDTHREAD_ABSTRACT_CONVERSATION_MODEL__H
3
4#include "Place.hpp"
5
6namespace redthread
7{
8 class AbstractConversationModel
9 {
10 public:
11 ///////
12 AbstractConversationModel();
13 virtual ~AbstractConversationModel() { }
14
15 virtual Place getRootPlace() const = 0;
16
17 private:
18 ////////
19 };
20}
21
22#endif
diff --git a/trunk/include/AbstractFriendListModel.hpp b/trunk/include/AbstractFriendListModel.hpp
new file mode 100644
index 0000000..f5e8db8
--- /dev/null
+++ b/trunk/include/AbstractFriendListModel.hpp
@@ -0,0 +1,31 @@
1#ifndef REDTHREAD_ABSTRACT_FRIEND_LIST_MODEL__H
2#define REDTHREAD_ABSTRACT_FRIEND_LIST_MODEL__H
3
4#include "Identity.hpp"
5
6namespace redthread
7{
8 class AbstractFriendListModel
9 {
10 public:
11 ///////
12 using IdentityId = Identity::IdentityId;
13
14 AbstractFriendListModel() { }
15 virtual ~AbstractFriendListModel() { }
16
17 /**
18 * add a friend to the circle of a specific ego
19 */
20 virtual void addFriend(const Identity& identity,
21 const Identity& ego) = 0;
22
23 virtual Identity getFriend(const IdentityId& friendId,
24 const IdentityId& ego) = 0;
25
26 private:
27 ////////
28 };
29}
30
31#endif
diff --git a/trunk/include/AbstractIdentityListModel.hpp b/trunk/include/AbstractIdentityListModel.hpp
new file mode 100644
index 0000000..94162a4
--- /dev/null
+++ b/trunk/include/AbstractIdentityListModel.hpp
@@ -0,0 +1,26 @@
1#ifndef REDTHREAD_ABSTRACT_IDENTITY_LIST_MODEL__H
2#define REDTHREAD_ABSTRACT_IDENTITY_LIST_MODEL__H
3
4#include "Identity.hpp"
5
6namespace redthread
7{
8 class AbstractIdentityListModel
9 {
10 public:
11 ///////
12 using IdentityId = Identity::IdentityId;
13
14 AbstractIdentityListModel() { }
15 virtual ~AbstractIdentityListModel() { }
16
17 virtual void addIdentity(const Identity& identitiy) = 0;
18
19 virtual Identity getIdentity(const IdentityId& id) = 0;
20
21 private:
22 ////////
23 };
24}
25
26#endif
diff --git a/trunk/include/AbstractSecushareController.hpp b/trunk/include/AbstractSecushareController.hpp
new file mode 100644
index 0000000..a6b08c4
--- /dev/null
+++ b/trunk/include/AbstractSecushareController.hpp
@@ -0,0 +1,131 @@
1/**
2 * @file AbstractSecushareController.hpp
3 * @brief Abstract controller class
4 *
5 * @author lurchi
6 * @date 2016-02-05
7 *
8 * @copyright
9 * This file is part of redthread which may be redistributed and/or modified
10 * under the terms of the GNU General Public License, either version 3 or any
11 * later version. See COPYING and <http://www.gnu.org/licenses/>.
12*
13 * @todo remove appName, appVersion, configPath as arguments and get them from config.h / somewhere else
14
15 */
16
17#ifndef REDTHREAD_ABSTRACT_SECUSHARE_CONTROLLER__H
18#define REDTHREAD_ABSTRACT_SECUSHARE_CONTROLLER__H
19
20#include "AbstractSecushareView.hpp"
21#include "NotifyPipe.hpp"
22#include <string>
23#include <queue>
24#include <mutex>
25
26extern "C"
27{
28 #include <gnunet/platform.h>
29 #include <gnunet/gnunet_util_lib.h>
30 #include <gnunet/gnunet_psyc_util_lib.h>
31 #include <gnunet/gnunet_social_service.h>
32}
33
34namespace redthread
35{
36 class AbstractSecushareController
37 {
38 public:
39 ///////
40 using PlaceId = Place::PlaceId;
41 using IdentityId = Identity::IdentityId;
42
43 int run();
44
45 protected:
46 //////////
47 AbstractSecushareController(
48 std::shared_ptr<AbstractSecushareView> view,
49 const std::string& appName,
50 const std::string& appVersion,
51 const std::string& configPath
52 );
53
54 virtual ~AbstractSecushareController() { }
55
56 // slots
57 void shutdown();
58 void addEgo(const std::string& name);
59 void addFriend(const std::string& nymPubKey, const std::string& name);
60 void sendMessage(const PlaceId& placeId, const std::string& message);
61
62 private:
63 ////////
64 std::shared_ptr<AbstractSecushareView> mView;
65 std::string mAppName;
66 std::string mAppVersion;
67 std::string mConfigFilePath;
68 bool mRunning;
69
70 /**
71 * gnunet task queue
72 *
73 * must be locked because it will be accessed by gnunet thread and view thread
74 */
75 std::queue<std::function<void()>> mGnunetTasks;
76 std::mutex mGnunetTasksMutex;
77 Util::NotifyPipe mGnunetTaskPipe;
78
79 const struct GNUNET_CONFIGURATION_Handle *mConfigHandle;
80 struct GNUNET_SOCIAL_App* mAppHandle;
81 struct GNUNET_IDENTITY_Handle* mIdentityHandle;
82 struct GNUNET_SCHEDULER_Task* mExternalEventFdHandle;
83
84 void addExternalEventFD();
85 void addToGnunetTaskQueue(std::function<void()> task);
86
87 static void processGnunetTasksCb(
88 void* closure,
89 const struct GNUNET_SCHEDULER_TaskContext* tc
90 );
91
92 static void runCb(
93 void* closure,
94 char* const* args,
95 const char* configFilePath,
96 const struct GNUNET_CONFIGURATION_Handle* configHandle
97 );
98
99 static void egoAvailableCb(
100 void* closure,
101 struct GNUNET_SOCIAL_Ego* ego,
102 const struct GNUNET_CRYPTO_EcdsaPublicKey* egoPubKey,
103 const char* name
104 );
105
106 static void placeAvailableAsHostCb(
107 void* closure,
108 struct GNUNET_SOCIAL_HostConnection* connection,
109 struct GNUNET_SOCIAL_Ego* ego,
110 const struct GNUNET_CRYPTO_EddsaPublicKey* hostPubKey,
111 enum GNUNET_SOCIAL_PlaceState placeState
112 );
113
114 static void placeAvailableAsGuestCb(
115 void* closure,
116 struct GNUNET_SOCIAL_GuestConnection* connection,
117 struct GNUNET_SOCIAL_Ego* ego,
118 const struct GNUNET_CRYPTO_EddsaPublicKey* guestPubKey,
119 enum GNUNET_SOCIAL_PlaceState placeState
120 );
121
122 static void egoCreatedCb(void *closure,
123 struct GNUNET_IDENTITY_Ego* ego,
124 void** ctx,
125 const char* name);
126
127 static void operationFinishedCb(void* closure, const char* errorMessage);
128 };
129}
130
131#endif
diff --git a/trunk/include/AbstractSecushareView.hpp b/trunk/include/AbstractSecushareView.hpp
new file mode 100644
index 0000000..e500678
--- /dev/null
+++ b/trunk/include/AbstractSecushareView.hpp
@@ -0,0 +1,124 @@
1// AbstractSecushareView.hpp
2//
3// author: lurchi
4// date: 2016-02-05
5
6#ifndef REDTHREAD_ABSTRACT_SECUSHARE_VIEW__H
7#define REDTHREAD_ABSTRACT_SECUSHARE_VIEW__H
8
9#include "AbstractUserConfigModel.hpp"
10#include "AbstractIdentityListModel.hpp"
11#include "AbstractUserInfoListModel.hpp"
12#include "AbstractUserInfoModel.hpp"
13#include "AbstractConversationListModel.hpp"
14#include "AbstractConversationModel.hpp"
15#include "AbstractFriendListModel.hpp"
16#include <string>
17#include <memory>
18
19namespace redthread
20{
21 class AbstractSecushareView
22 {
23 public:
24 ///////
25 using IdentityId = Identity::IdentityId;
26 using PlaceId = Place::PlaceId;
27
28 virtual int run() = 0;
29
30 /**
31 * Models
32 *
33 * The lifetime of the models is managed by the View (class inheriting from
34 * AbstractSecushareView). Other classes such as the Controller will modify but
35 * never remove models. When the view knows a model is not needed anymore
36 * it can call the removeItem method of the *ListModel classes. It must never
37 * call delete on the models directly.
38 *
39 * The model classes' getters and setters are thread-safe.
40 */
41
42 /**
43 * @brief the user-defined configuration
44 *
45 * should be initialized by control before run is called
46 */
47 virtual std::shared_ptr<AbstractUserConfigModel> getUserConfigModel() const
48 {return nullptr;}
49
50 /**
51 * @brief our egos
52 *
53 * used for different social circles
54 */
55 virtual std::shared_ptr<AbstractIdentityListModel> getEgoListModel() const
56 {return nullptr;}
57
58 /**
59 * @brief the history of our UserInfo (of all our egos)
60 */
61 virtual std::shared_ptr<AbstractUserInfoListModel>
62 getUserInfoListModel() const
63 {return nullptr;}
64
65 /**
66 * @brief a specific ego's latest UserInfo
67 */
68 virtual std::shared_ptr<AbstractUserInfoModel>
69 getLatestUserInfoModel(IdentityId egoId) const
70 {return nullptr;}
71
72 /**
73 * @brief currently relevant conversations (hosted by us or by friends)
74 */
75 virtual std::shared_ptr<AbstractConversationListModel>
76 getConversationListModel() const
77 {return nullptr;}
78
79 /**
80 * @brief a specific place's conversation
81 */
82 virtual std::shared_ptr<AbstractConversationModel>
83 getConversationModel(const PlaceId& rootPlace) const
84 {return nullptr;}
85
86 /**
87 * @brief our friends (of all our egos)
88 */
89 virtual std::shared_ptr<AbstractFriendListModel>
90 getFriendListModel() const
91 {return nullptr;}
92
93 /**
94 * @brief the history of a specific friend's UserInfo
95 */
96 virtual std::shared_ptr<AbstractUserInfoListModel>
97 getFriendUserInfoListModel(const IdentityId& nymId) const
98 {return nullptr;}
99
100 /**
101 * @brief a specific friend's latest UserInfo
102 */
103 virtual std::shared_ptr<AbstractUserInfoModel>
104 getFriendLatestUserInfoModel(const IdentityId& nymId) const
105 {return nullptr;}
106
107 /**
108 * @brief a specific friend's friends
109 */
110 virtual std::shared_ptr<AbstractIdentityListModel>
111 getFriendFriendListModel(const IdentityId& nymId) const
112 {return nullptr;}
113
114 protected:
115 //////////
116 AbstractSecushareView();
117 virtual ~AbstractSecushareView() { }
118
119 private:
120 ////////
121 };
122}
123
124#endif
diff --git a/trunk/include/AbstractUserConfigModel.hpp b/trunk/include/AbstractUserConfigModel.hpp
new file mode 100644
index 0000000..858efbe
--- /dev/null
+++ b/trunk/include/AbstractUserConfigModel.hpp
@@ -0,0 +1,24 @@
1#ifndef REDTHREAD_ABSTRACT_USER_CONFIG_MODEL__H
2#define REDTHREAD_ABSTRACT_USER_CONFIG_MODEL__H
3
4#include <atomic>
5
6namespace redthread
7{
8 class AbstractUserConfigModel
9 {
10 public:
11 ///////
12 AbstractUserConfigModel();
13 virtual ~AbstractUserConfigModel() { }
14
15 bool getShowNewIdentityDialog() const {return mShowNewIdentityDialog;}
16 void setShowNewIdentityDialog(bool value) {mShowNewIdentityDialog = value;}
17
18 private:
19 ////////
20 std::atomic<bool> mShowNewIdentityDialog;
21 };
22}
23
24#endif
diff --git a/trunk/include/AbstractUserInfoListModel.hpp b/trunk/include/AbstractUserInfoListModel.hpp
new file mode 100644
index 0000000..e155af7
--- /dev/null
+++ b/trunk/include/AbstractUserInfoListModel.hpp
@@ -0,0 +1,19 @@
1#ifndef REDTHREAD_ABSTRACT_USER_INFO_LIST_MODEL__H
2#define REDTHREAD_ABSTRACT_USER_INFO_LIST_MDOEL__H
3
4namespace redthread
5{
6 class AbstractUserInfoListModel
7 {
8 public:
9 ///////
10 AbstractUserInfoListModel() { }
11 virtual ~AbstractUserInfoListModel() { }
12
13
14 private:
15 ////////
16 };
17}
18
19#endif
diff --git a/trunk/include/AbstractUserInfoModel.hpp b/trunk/include/AbstractUserInfoModel.hpp
new file mode 100644
index 0000000..96ea1e1
--- /dev/null
+++ b/trunk/include/AbstractUserInfoModel.hpp
@@ -0,0 +1,35 @@
1#ifndef REDTHREAD_ABSTRACT_USER_INFO_MODEL__H
2#define REDTHREAD_ABSTRACT_USER_INFO_MODEL__H
3
4#include "Place.hpp"
5
6namespace redthread
7{
8 class AbstractUserInfoModel
9 {
10 public:
11 ///////
12 using PlaceId = Place::PlaceId;
13
14 AbstractUserInfoModel() { }
15 virtual ~AbstractUserInfoModel() { }
16
17 virtual void
18 setStatus(const std::string& pubKey, const std::string& status) = 0;
19
20 virtual void
21 setMood(const std::string& pubKey, const std::string& mood) = 0;
22
23 virtual void setDefaultPlace(const PlaceId& place) = 0;
24
25 virtual std::string getStatus() = 0;
26 virtual std::string getMood() = 0;
27
28 virtual PlaceId getDefaultPlace() const = 0;
29
30 private:
31 ////////
32 };
33}
34
35#endif
diff --git a/trunk/include/Identity.hpp b/trunk/include/Identity.hpp
new file mode 100644
index 0000000..4e7d059
--- /dev/null
+++ b/trunk/include/Identity.hpp
@@ -0,0 +1,49 @@
1// Identity.hpp
2//
3// author: lurchi
4// date: 2016-02-01
5
6#ifndef REDTHREAD_IDENTITY__H
7#define REDTHREAD_IDENTITY__H
8
9#include <string>
10#include <vector>
11
12namespace redthread
13{
14 class Identity
15 {
16 public:
17 ///////
18 using IdentityId = std::string;
19
20 Identity(const std::string& masterPubKey = "",
21 const std::vector<std::string>& subordinatePubKeys = {});
22
23 bool isValid() const {return not mMasterPubKey.empty();}
24
25 IdentityId getId() const {return mMasterPubKey;}
26
27 std::string getMasterPubKey() const {return mMasterPubKey;}
28
29 std::vector<std::string> getSubordinatePubKeys() const
30 {return mSubordinatePubKeys;}
31
32 std::string getName() const {return mName;}
33
34 void setMasterPubKey(const std::string& key) {mMasterPubKey = key;}
35
36 void setSubOrdinatePubKeys(const std::vector<std::string>& keys)
37 {mSubordinatePubKeys = keys;}
38
39 bool operator==(const Identity& other) const;
40
41 private:
42 ////////
43 std::string mMasterPubKey;
44 std::vector<std::string> mSubordinatePubKeys;
45 std::string mName;
46 };
47}
48
49#endif
diff --git a/trunk/include/NotifyPipe.hpp b/trunk/include/NotifyPipe.hpp
new file mode 100644
index 0000000..3605efc
--- /dev/null
+++ b/trunk/include/NotifyPipe.hpp
@@ -0,0 +1,23 @@
1#ifndef UTIL_NOTIFY_PIPE__H
2#define UTIL_NOTIFY_PIPE__H
3
4namespace Util
5{
6 class NotifyPipe
7 {
8 public:
9 ///////
10 NotifyPipe();
11 virtual ~NotifyPipe();
12
13 int receiverFd();
14 void notify();
15
16 private:
17 ////////
18 int m_receiveFd;
19 int m_sendFd;
20 };
21}
22
23#endif
diff --git a/trunk/include/Place.hpp b/trunk/include/Place.hpp
new file mode 100644
index 0000000..31b3ef9
--- /dev/null
+++ b/trunk/include/Place.hpp
@@ -0,0 +1,36 @@
1#ifndef REDTHREAD_PLACE__H
2#define REDTHREAD_PLACE__H
3
4#include "Identity.hpp"
5#include <string>
6
7namespace redthread
8{
9 class Place
10 {
11 public:
12 ///////
13 using PlaceId = std::string;
14 using IdentityId = Identity::IdentityId;
15
16 Place(const std::string& pubKey = "", const IdentityId& owner = {});
17
18 bool isValid() const {return not (mPubKey.empty() or mOwner.isValid());}
19
20 std::string getPubKey() const {return mPubKey;}
21 Identity getOwner() const {return mOwner;}
22
23 void setPubKey(const std::string& key) {mPubKey = key;}
24 void setOwner(const Identity& owner) {mOwner = owner;}
25
26 bool operator==(const Place& other) const
27 {return mPubKey == other.mPubKey and mOwner == other.mOwner;}
28
29 private:
30 ////////
31 std::string mPubKey;
32 Identity mOwner;
33 };
34}
35
36#endif
diff --git a/trunk/include/QtUserConfigModel.hpp b/trunk/include/QtUserConfigModel.hpp
new file mode 100644
index 0000000..c11083c
--- /dev/null
+++ b/trunk/include/QtUserConfigModel.hpp
@@ -0,0 +1,28 @@
1#ifndef REDTHREAD_QT_USER_CONFIG_MODEL__H
2#define REDTHREAD_QT_USER_CONFIG_MODEL__H
3
4#include "AbstractUserConfigModel.hpp"
5#include <QAbstractItemModel>
6
7namespace redthread
8{
9 class QtUserConfigModel : public QAbstractItemModel,
10 public AbstractUserConfigModel
11 {
12 Q_OBJECT
13
14 public:
15 ///////
16 QtUserConfigModel(QObject* parent = nullptr);
17 ~QtUserConfigModel() override;
18
19 int columnCount(const QModelIndex & parent = QModelIndex()) const override;
20 QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override;
21 QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const override;
22 QModelIndex parent(const QModelIndex & index) const override;
23 int rowCount(const QModelIndex & parent = QModelIndex()) const override;
24
25 };
26}
27
28#endif
diff --git a/trunk/include/RedThreadQt.hpp b/trunk/include/RedThreadQt.hpp
new file mode 100644
index 0000000..500f895
--- /dev/null
+++ b/trunk/include/RedThreadQt.hpp
@@ -0,0 +1,39 @@
1#ifndef REDTHREAD_REDTHREAD_QT__H
2#define REDTHREAD_REDTHREAD_QT__H
3
4#include "SecushareQtView.hpp"
5#include "SecushareQtController.hpp"
6#include <vector>
7#include <thread>
8#include <iostream>
9
10namespace redthread
11{
12 class RedThreadQt
13 {
14 public:
15 ///////
16 RedThreadQt(int argc, char** argv);
17 ~RedThreadQt();
18
19 /**
20 * @brief run the event loops
21 *
22 * SecushareQtControl's run method is called in a thread which starts
23 * gnunet's event loop. After that SecushareQtView's run method is
24 * called which starts Qt's event loop. It returns when the QApplication
25 * quits.
26 *
27 * @return 0 on normal exit, another value on error
28 */
29 int run();
30
31 private:
32 ////////
33 std::shared_ptr<SecushareQtView> mView;
34 SecushareQtController mController;
35 std::thread mControlThread;
36 };
37}
38
39#endif
diff --git a/trunk/include/SecushareQtController.hpp b/trunk/include/SecushareQtController.hpp
new file mode 100644
index 0000000..cecab89
--- /dev/null
+++ b/trunk/include/SecushareQtController.hpp
@@ -0,0 +1,41 @@
1// SecushareQtController.hpp
2//
3// author: lurchi
4// date: 2016-02-01
5
6#ifndef REDTHREAD_SECUSHARE_CONTROLLER__H
7#define REDTHREAD_SECUSHARE_CONTROLLER__H
8
9#include "AbstractSecushareController.hpp"
10#include "SecushareQtView.hpp"
11#include <QObject>
12
13namespace redthread
14{
15 class SecushareQtController : public QObject, public AbstractSecushareController
16 {
17 Q_OBJECT
18
19 public:
20 ///////
21 SecushareQtController(std::shared_ptr<SecushareQtView> view,
22 const std::string& appName,
23 const std::string& appVersion,
24 const std::string& configPath,
25 QObject* parent = nullptr);
26
27 ~SecushareQtController() override;
28
29 public slots:
30 /////////////
31 void shutdown();
32 void addEgo(const std::string& name);
33 void addFriend(const std::string& nymPubKey, const std::string& name);
34 void sendMessage(const PlaceId& placeId, const std::string& message);
35
36 private:
37 ////////
38 };
39}
40
41#endif
diff --git a/trunk/include/SecushareQtView.hpp b/trunk/include/SecushareQtView.hpp
new file mode 100644
index 0000000..d5c118d
--- /dev/null
+++ b/trunk/include/SecushareQtView.hpp
@@ -0,0 +1,56 @@
1// SecushareQtView.hpp
2//
3// author: lurchi
4// date: 2016-02-01
5
6#ifndef REDTHREAD_SECUSHARE_VIEW__H
7#define REDTHREAD_SECUSHARE_VIEW__H
8
9#include "AbstractSecushareView.hpp"
10#include "QtUserConfigModel.hpp"
11#include "NotifyPipe.hpp"
12#include <QApplication>
13#include <QSocketNotifier>
14#include <vector>
15#include <iostream>
16
17namespace redthread
18{
19 class SecushareQtView : public QObject, public AbstractSecushareView
20 {
21 Q_OBJECT
22
23 public:
24 ///////
25 SecushareQtView(int argc, char** argv);
26 ~SecushareQtView() override;
27
28 int run() override;
29
30 std::shared_ptr<AbstractUserConfigModel> getUserConfigModel() const override
31 {return mUserConfigModel;}
32
33 signals:
34 ////////
35 void shutdownRequest();
36 void addEgoRequest(const std::string& name);
37 void addFriendRequst(const IdentityId& nymId);
38 void sendMessageRequest(const PlaceId& placeId, const std::string& message);
39
40 private:
41 ////////
42 int mArgc;
43 char** mArgv;
44 std::shared_ptr<QtUserConfigModel> mUserConfigModel;
45
46 static Util::NotifyPipe shutdownPipe;
47 QSocketNotifier *sigNotifier;
48
49 void catchUnixSignals(
50 const std::vector<int>& quitSignals,
51 const std::vector<int>& ignoreSignals = {}
52 );
53 };
54}
55
56#endif
diff --git a/trunk/include/Signal.hpp b/trunk/include/Signal.hpp
new file mode 100644
index 0000000..63dc55f
--- /dev/null
+++ b/trunk/include/Signal.hpp
@@ -0,0 +1,26 @@
1#include <sigc++/sigc++.h>
2
3namespace redthread
4{
5 template
6 <
7 class T_return,
8 class T_arg1 = sigc::nil,
9 class T_arg2 = sigc::nil,
10 class T_arg3 = sigc::nil,
11 class T_arg4 = sigc::nil,
12 class T_arg5 = sigc::nil,
13 class T_arg6 = sigc::nil,
14 class T_arg7 = sigc::nil
15 >
16 using SignalT =
17 sigc::signal< T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7 >;
18}
19
20//#include <boost/signals2.hpp>
21//
22//namespace redthread
23//{
24// template <typename Signature>
25// using SignalT = boost::signals2::signal<Signature>;
26//}
diff --git a/trunk/src/AbstractSecushareController.cpp b/trunk/src/AbstractSecushareController.cpp
new file mode 100644
index 0000000..db720fb
--- /dev/null
+++ b/trunk/src/AbstractSecushareController.cpp
@@ -0,0 +1,242 @@
1/**
2 * @file AbstractSecushareController.cpp
3 * @brief Abstract controller class
4 *
5 * @author lurchi
6 * @date 2016-02-05
7 *
8 * @copyright
9 * This file is part of redthread which may be redistributed and/or modified
10 * under the terms of the GNU General Public License, either version 3 or any
11 * later version. See COPYING and <http://www.gnu.org/licenses/>.
12 */
13
14#include "AbstractSecushareController.hpp"
15#include <iostream>
16#include <vector>
17
18using namespace redthread;
19
20AbstractSecushareController::AbstractSecushareController(
21 std::shared_ptr<AbstractSecushareView> view,
22 const std::string& appName,
23 const std::string& appVersion,
24 const std::string& configPath
25)
26 : mView {view},
27 mAppName {appName},
28 mAppVersion {appVersion},
29 mConfigFilePath {configPath},
30 mRunning {false}
31{
32 auto config = mView->getUserConfigModel();
33
34 // TODO: read config from disk
35 config->setShowNewIdentityDialog(true);
36}
37
38int AbstractSecushareController::run()
39{
40 const std::vector<struct GNUNET_GETOPT_CommandLineOption> options
41 {
42 GNUNET_GETOPT_OPTION_END
43 };
44
45 std::string configFileOption {"-c"};
46
47 const std::vector<char*> argv
48 {
49 &mAppName[0],
50 &configFileOption[0],
51 &mConfigFilePath[0]
52 };
53
54 mRunning = true;
55
56 return
57 GNUNET_PROGRAM_run(argv.size(),
58 argv.data(),
59 mAppName.data(),
60 gettext_noop("binary description text"),
61 options.data(),
62 &AbstractSecushareController::runCb,
63 this);
64}
65
66void AbstractSecushareController::addExternalEventFD()
67{
68 auto fileHandle = GNUNET_DISK_get_handle_from_int_fd(mGnunetTaskPipe.receiverFd());
69
70 mExternalEventFdHandle =
71 GNUNET_SCHEDULER_add_read_file
72 (
73 GNUNET_TIME_UNIT_FOREVER_REL,
74 fileHandle,
75 &AbstractSecushareController::processGnunetTasksCb,
76 this
77 );
78
79}
80
81void AbstractSecushareController::addToGnunetTaskQueue(std::function<void()> task)
82{
83 {
84 std::lock_guard<std::mutex> lock {mGnunetTasksMutex};
85 mGnunetTasks.push(task);
86 }
87
88 mGnunetTaskPipe.notify();
89}
90
91void AbstractSecushareController::processGnunetTasksCb(
92 void* closure,
93 const struct GNUNET_SCHEDULER_TaskContext* context
94)
95{
96 //DEBUG
97 std::cout << "AbstractSecushareController::processGnunetTasksCb" << std::endl;
98
99 AbstractSecushareController* controller {static_cast<AbstractSecushareController*>(closure)};
100 auto& tasks = controller->mGnunetTasks;
101
102 {
103 std::lock_guard<std::mutex> lock {controller->mGnunetTasksMutex};
104
105 while(not tasks.empty())
106 {
107 tasks.front()();
108 tasks.pop();
109 }
110 }
111
112 if(controller->mRunning)
113 {
114 controller->addExternalEventFD();
115 }
116}
117
118void AbstractSecushareController::runCb(
119 void* closure,
120 char* const* args,
121 const char* configFilePath,
122 const struct GNUNET_CONFIGURATION_Handle* configHandle
123)
124{
125 AbstractSecushareController* controller {static_cast<AbstractSecushareController*>(closure)};
126
127 controller->mConfigHandle = configHandle;
128
129 controller->mAppHandle =
130 GNUNET_SOCIAL_app_connect(
131 configHandle,
132 controller->mAppName.c_str(),
133 &AbstractSecushareController::egoAvailableCb,
134 &AbstractSecushareController::placeAvailableAsHostCb,
135 &AbstractSecushareController::placeAvailableAsGuestCb,
136 closure
137 );
138
139 controller->mIdentityHandle =
140 GNUNET_IDENTITY_connect(controller->mConfigHandle,
141 &AbstractSecushareController::egoCreatedCb,
142 controller);
143
144 controller->addExternalEventFD();
145}
146
147void AbstractSecushareController::shutdown()
148{
149 addToGnunetTaskQueue(
150 [this]()
151 {
152 GNUNET_IDENTITY_disconnect(mIdentityHandle);
153 GNUNET_SOCIAL_app_disconnect(mAppHandle);
154 }
155 );
156
157 mRunning = false;
158}
159
160void AbstractSecushareController::addEgo(const std::string& name)
161{
162 addToGnunetTaskQueue(
163 [this, &name]()
164 {
165 GNUNET_IDENTITY_create(
166 mIdentityHandle,
167 name.data(),
168 &AbstractSecushareController::operationFinishedCb,
169 this
170 );
171 }
172 );
173}
174
175void AbstractSecushareController::addFriend(const std::string& nymPubKey, const std::string& name)
176{
177
178}
179
180void AbstractSecushareController::sendMessage(const PlaceId& placeId, const std::string& message)
181{
182
183}
184
185void AbstractSecushareController::egoAvailableCb(
186 void* closure,
187 struct GNUNET_SOCIAL_Ego* ego,
188 const struct GNUNET_CRYPTO_EcdsaPublicKey* egoPubKey,
189 const char* name
190)
191{
192 std::cout << "ego available: " << GNUNET_CRYPTO_ecdsa_public_key_to_string (egoPubKey) << std::endl;
193}
194
195void AbstractSecushareController::placeAvailableAsHostCb(
196 void* closure,
197 struct GNUNET_SOCIAL_HostConnection* connection,
198 struct GNUNET_SOCIAL_Ego* ego,
199 const struct GNUNET_CRYPTO_EddsaPublicKey* hostPubKey,
200 enum GNUNET_SOCIAL_PlaceState placeState
201)
202{
203 struct GNUNET_HashCode hostPubKeyHash;
204 GNUNET_CRYPTO_hash (hostPubKey, sizeof (*hostPubKey), &hostPubKeyHash);
205 std::cout << "place available as host: " << GNUNET_h2s(&hostPubKeyHash) << std::endl;
206}
207
208void AbstractSecushareController::placeAvailableAsGuestCb(
209 void* closure,
210 struct GNUNET_SOCIAL_GuestConnection* connection,
211 struct GNUNET_SOCIAL_Ego* ego,
212 const struct GNUNET_CRYPTO_EddsaPublicKey* guestPubKey,
213 enum GNUNET_SOCIAL_PlaceState placeState
214)
215{
216 struct GNUNET_HashCode guestPubKeyHash;
217 GNUNET_CRYPTO_hash (guestPubKey, sizeof (*guestPubKey), &guestPubKeyHash);
218 std::cout << "place available as guest: " << GNUNET_h2s(&guestPubKeyHash) << std::endl;
219}
220
221void AbstractSecushareController::egoCreatedCb(
222 void *closure,
223 struct GNUNET_IDENTITY_Ego* ego,
224 void** ctx,
225 const char* name
226)
227{
228 std::cout << "ego created" << name << std::endl;
229}
230
231void AbstractSecushareController::operationFinishedCb(void* closure, const char* errorMessage)
232{
233 // DEBUG:
234 if(errorMessage)
235 {
236 std::cout << "ERROR: " << errorMessage << std::endl;
237 }
238 else
239 {
240 std::cout << "no error" << std::endl;
241 }
242}
diff --git a/trunk/src/AbstractSecushareView.cpp b/trunk/src/AbstractSecushareView.cpp
new file mode 100644
index 0000000..2dfc460
--- /dev/null
+++ b/trunk/src/AbstractSecushareView.cpp
@@ -0,0 +1,13 @@
1// AbstractSecushareView.cpp
2//
3// author: lurchi
4// date: 2016-02-01
5
6#include "AbstractSecushareView.hpp"
7
8using namespace redthread;
9
10AbstractSecushareView::AbstractSecushareView()
11{
12
13}
diff --git a/trunk/src/AbstractUserConfigModel.cpp b/trunk/src/AbstractUserConfigModel.cpp
new file mode 100644
index 0000000..bba79ed
--- /dev/null
+++ b/trunk/src/AbstractUserConfigModel.cpp
@@ -0,0 +1,8 @@
1#include "AbstractUserConfigModel.hpp"
2
3using namespace redthread;
4
5AbstractUserConfigModel::AbstractUserConfigModel()
6{
7
8}
diff --git a/trunk/src/CMakeLists.txt b/trunk/src/CMakeLists.txt
new file mode 100644
index 0000000..cd186ca
--- /dev/null
+++ b/trunk/src/CMakeLists.txt
@@ -0,0 +1,61 @@
1# src/CMakeLists.txt
2
3include(CheckIncludeFileCXX)
4
5set(THIRD_PARTY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party")
6
7# gnunet
8set(GNUNET_SOCIAL_NEEDED true)
9find_package(Gnunet REQUIRED)
10set(LIBS ${LIBS} ${GNUNET_LIBRARIES})
11set(REDTHREAD_INCLUDE_DIRS ${REDTHREAD_INCLUDE_DIRS} ${GNUNET_INCLUDE_DIRS})
12
13# ncurses
14set(CURSES_NEED_NCURSES true)
15find_package(Curses 6 REQUIRED)
16set(LIBS ${LIBS} ${CURSES_LIBRARIES})
17set(REDTHREAD_INCLUDE_DIRS ${REDTHREAD_INCLUDE_DIRS} ${CURSES_INCLUDE_DIRS})
18
19# Qt
20set(CMAKE_AUTOMOC ON)
21find_package(Qt5Widgets REQUIRED)
22find_package(Qt5Quick REQUIRED)
23file(GLOB hpp_files "${PROJECT_SOURCE_DIR}/include/*.hpp")
24qt_wrap_cpp(redthread qt_wrappers ${hpp_files})
25set(source_files ${source_files} ${qt_wrappers})
26set(LIBS ${LIBS} Qt5::Widgets Qt5::Quick)
27
28# sigc++
29#find_package(SigC++ REQUIRED)
30#set(LIBS ${LIBS} ${SIGC++_LIBRARIES})
31#set(REDTHREAD_INCLUDE_DIRS ${REDTHREAD_INCLUDE_DIRS} ${SIGC++_INCLUDE_DIRS})
32
33# boost::signals2 (header only)
34#find_package(Boost REQUIRED)
35#set(REDTHREAD_INCLUDE_DIRS ${REDTHREAD_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
36
37#set(CMAKE_CXX_FLAGS "-O2 -Os -std=c++11 -Wall -Wextra -pedantic -lstdc++" CACHE STRING "" FORCE)
38set(CMAKE_CXX_FLAGS "-g -std=c++11 -Wall -Wextra")
39set(CMAKE_EXE_LINKER_FLAGS "")
40
41set(source_files ${source_files}
42 AbstractSecushareController.cpp
43 AbstractSecushareView.cpp
44 AbstractUserConfigModel.cpp
45 Identity.cpp
46 main.cpp
47 NotifyPipe.cpp
48 Place.cpp
49 QtUserConfigModel.cpp
50 RedThreadQt.cpp
51 SecushareQtController.cpp
52 SecushareQtView.cpp
53)
54
55add_executable(redthread ${source_files})
56target_include_directories(redthread PUBLIC
57 ${REDTHREAD_INCLUDE_DIRS}
58 ${PROJECT_SOURCE_DIR} # for config.h
59 ${PROJECT_SOURCE_DIR}/include)
60target_link_libraries(redthread ${LIBS})
61
diff --git a/trunk/src/Identity.cpp b/trunk/src/Identity.cpp
new file mode 100644
index 0000000..61e5344
--- /dev/null
+++ b/trunk/src/Identity.cpp
@@ -0,0 +1,27 @@
1#include "Identity.hpp"
2#include <algorithm>
3
4using namespace redthread;
5
6Identity::Identity(const std::string& masterPubKey,
7 const std::vector<std::string>& subordinatePubKeys)
8 : mMasterPubKey {masterPubKey}, mSubordinatePubKeys {subordinatePubKeys}
9{
10
11}
12
13bool Identity::operator==(const Identity& other) const
14{
15 return
16 (mMasterPubKey == other.mMasterPubKey) or
17 std::any_of(
18 other.mSubordinatePubKeys.cbegin(),
19 other.mSubordinatePubKeys.cend(),
20 [this](const std::string& k)
21 {
22 return
23 std::find(mSubordinatePubKeys.cbegin(), mSubordinatePubKeys.cend(), k)
24 != mSubordinatePubKeys.cend();
25 }
26 );
27}
diff --git a/trunk/src/NotifyPipe.cpp b/trunk/src/NotifyPipe.cpp
new file mode 100644
index 0000000..3127cf4
--- /dev/null
+++ b/trunk/src/NotifyPipe.cpp
@@ -0,0 +1,36 @@
1#include "NotifyPipe.hpp"
2
3#include <unistd.h>
4#include <assert.h>
5#include <fcntl.h>
6
7using namespace Util;
8
9NotifyPipe::NotifyPipe()
10{
11 int pipefd[2];
12 int ret = pipe(pipefd);
13 assert(ret == 0); // For real usage put proper check here
14 m_receiveFd = pipefd[0];
15 m_sendFd = pipefd[1];
16 fcntl(m_sendFd, F_SETFL, O_NONBLOCK);
17}
18
19
20NotifyPipe::~NotifyPipe()
21{
22 close(m_sendFd);
23 close(m_receiveFd);
24}
25
26
27int NotifyPipe::receiverFd()
28{
29 return m_receiveFd;
30}
31
32
33void NotifyPipe::notify()
34{
35 write(m_sendFd, "1", 1);
36}
diff --git a/trunk/src/Place.cpp b/trunk/src/Place.cpp
new file mode 100644
index 0000000..a2a36b0
--- /dev/null
+++ b/trunk/src/Place.cpp
@@ -0,0 +1,9 @@
1#include "Place.hpp"
2
3using namespace redthread;
4
5Place::Place(const std::string& pubKey, const IdentityId& owner)
6 : mPubKey {pubKey}, mOwner {owner}
7{
8
9}
diff --git a/trunk/src/QtUserConfigModel.cpp b/trunk/src/QtUserConfigModel.cpp
new file mode 100644
index 0000000..fb6b96c
--- /dev/null
+++ b/trunk/src/QtUserConfigModel.cpp
@@ -0,0 +1,44 @@
1#include "QtUserConfigModel.hpp"
2
3using namespace redthread;
4
5QtUserConfigModel::QtUserConfigModel(QObject* parent)
6 : QAbstractItemModel(parent), AbstractUserConfigModel()
7{
8
9}
10
11QtUserConfigModel::~QtUserConfigModel()
12{
13
14}
15
16int QtUserConfigModel::columnCount(const QModelIndex & parent) const
17{
18 // FIXME
19 return 0;
20}
21
22QVariant QtUserConfigModel::data(const QModelIndex & index, int role) const
23{
24 // FIXME
25 return {};
26}
27
28QModelIndex QtUserConfigModel::index(int row, int column, const QModelIndex & parent) const
29{
30 // FIXME
31 return {};
32}
33
34QModelIndex QtUserConfigModel::parent(const QModelIndex & index) const
35{
36 // FIXME
37 return {};
38}
39
40int QtUserConfigModel::rowCount(const QModelIndex & parent) const
41{
42 // FIXME
43 return 0;
44}
diff --git a/trunk/src/RedThreadQt.cpp b/trunk/src/RedThreadQt.cpp
new file mode 100644
index 0000000..63e0ca8
--- /dev/null
+++ b/trunk/src/RedThreadQt.cpp
@@ -0,0 +1,40 @@
1// RedThread.cpp
2//
3// author: lurchi
4// date: 2016-02-01
5
6#include "RedThreadQt.hpp"
7#include <QApplication>
8
9using namespace redthread;
10
11RedThreadQt::RedThreadQt(int argc, char** argv)
12 : mView {new SecushareQtView(argc, argv)},
13 mController {mView, "redthread", "0.1", "/home/christian/.config/gnunet.conf"}
14{
15 auto view = mView.get();
16 auto controller = &mController;
17
18 QApplication::connect(view, &SecushareQtView::shutdownRequest, controller, &SecushareQtController::shutdown);
19}
20
21RedThreadQt::~RedThreadQt()
22{
23 if(mControlThread.get_id() != std::thread::id {})
24 {
25 mControlThread.join();
26 }
27}
28
29int RedThreadQt::run()
30{
31 mControlThread = std::thread {&SecushareQtController::run, &mController};
32
33 /**
34 * FIXME:
35 * is there a race condition with GNUNET_SCHEDULER_run setting signal handlers?
36 */
37 int exitCode {mView->run()};
38
39 return exitCode;
40}
diff --git a/trunk/src/SecushareQtController.cpp b/trunk/src/SecushareQtController.cpp
new file mode 100644
index 0000000..512cc67
--- /dev/null
+++ b/trunk/src/SecushareQtController.cpp
@@ -0,0 +1,44 @@
1// SecushareQtController.cpp
2//
3// author: lurchi
4// date: 2016-02-01
5
6#include "SecushareQtController.hpp"
7
8using namespace redthread;
9
10SecushareQtController::SecushareQtController(std::shared_ptr<SecushareQtView> view,
11 const std::string& appName,
12 const std::string& appVersion,
13 const std::string& configPath,
14 QObject* parent)
15 : QObject(parent),
16 AbstractSecushareController(view, appName, appVersion, configPath)
17{
18
19}
20
21SecushareQtController::~SecushareQtController()
22{
23
24}
25
26void SecushareQtController::shutdown()
27{
28 AbstractSecushareController::shutdown();
29}
30
31void SecushareQtController::addEgo(const std::string& name)
32{
33 AbstractSecushareController::addEgo(name);
34}
35
36void SecushareQtController::addFriend(const std::string& nymPubKey, const std::string& name)
37{
38 AbstractSecushareController::addFriend(nymPubKey, name);
39}
40
41void SecushareQtController::sendMessage(const PlaceId& placeId, const std::string& message)
42{
43 AbstractSecushareController::sendMessage(placeId, message);
44}
diff --git a/trunk/src/SecushareQtView.cpp b/trunk/src/SecushareQtView.cpp
new file mode 100644
index 0000000..2253d58
--- /dev/null
+++ b/trunk/src/SecushareQtView.cpp
@@ -0,0 +1,77 @@
1// SecushareQtView.cpp
2//
3// author: lurchi
4// date: 2016-02-01
5
6#include "SecushareQtView.hpp"
7#include "config.h"
8#include <signal.h>
9#include <QQuickView>
10#include <QQuickItem>
11#include <QQmlEngine>
12
13using namespace redthread;
14
15Util::NotifyPipe SecushareQtView::shutdownPipe {};
16
17SecushareQtView::SecushareQtView(int argc, char** argv)
18 : QObject(),
19 AbstractSecushareView(),
20 mArgc {argc},
21 mArgv {argv},
22 mUserConfigModel {new QtUserConfigModel()}
23{
24 std::cout << "SecushareQtView ctor" << std::endl;
25}
26
27SecushareQtView::~SecushareQtView()
28{
29
30}
31
32void SecushareQtView::catchUnixSignals(
33 const std::vector<int>& quitSignals,
34 const std::vector<int>& ignoreSignals
35)
36{
37 sigNotifier = new QSocketNotifier(shutdownPipe.receiverFd(), QSocketNotifier::Read, nullptr);
38 QApplication::connect(sigNotifier, &QSocketNotifier::activated, &QApplication::quit);
39
40 auto handler = [](int sig) -> void
41 {
42 shutdownPipe.notify();
43 };
44
45 // all these signals will be ignored.
46 for(int sig : ignoreSignals)
47 {
48 signal(sig, SIG_IGN);
49 }
50
51 // each of these signals calls the handler (quits the QCoreApplication).
52 for(int sig : quitSignals)
53 {
54 signal(sig, handler);
55 }
56}
57
58int SecushareQtView::run()
59{
60 QApplication app(mArgc, mArgv);
61
62 QObject::connect(&app, &QApplication::aboutToQuit, this, &SecushareQtView::shutdownRequest);
63
64 catchUnixSignals({SIGQUIT, SIGINT, SIGTERM, SIGHUP});
65
66 QQuickView view (QUrl::fromLocalFile(QML_DIR "/application.qml"));
67 QObject* root = view.rootObject();
68 QQmlEngine *engine = QtQml::qmlEngine(root);
69 //QObject::connect(root, SIGNAL(shutdownButtonClicked()), this, SIGNAL(shutdownRequest()));
70 QObject::connect(engine, SIGNAL(quit()), this, SIGNAL(shutdownRequest()));
71 QObject::connect(engine, SIGNAL(quit()), &app, SLOT(quit()));
72
73 //view.setSource(QUrl::fromLocalFile(QML_DIR "/application.qml"));
74 view.show();
75
76 return app.exec();
77}
diff --git a/trunk/src/main.cpp b/trunk/src/main.cpp
new file mode 100644
index 0000000..d505293
--- /dev/null
+++ b/trunk/src/main.cpp
@@ -0,0 +1,21 @@
1// main.cpp
2//
3// author: lurchi
4// date: 2016-02-01
5
6#include "RedThreadQt.hpp"
7#include <iostream>
8
9int main(int argc, char** argv)
10{
11 using namespace redthread;
12
13 std::cout << "red thread" << std::endl;
14
15 RedThreadQt app {argc, argv};
16 int exitCode {app.run()};
17
18 std::cout << "exiting with code " << exitCode << std::endl;
19
20 return exitCode;
21}
diff --git a/trunk/test/CMakeLists.txt b/trunk/test/CMakeLists.txt
new file mode 100644
index 0000000..79fce8c
--- /dev/null
+++ b/trunk/test/CMakeLists.txt
@@ -0,0 +1,5 @@
1set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wextra -pedantic")
2set(CMAKE_EXE_LINKER_FLAGS "")
3
4include_directories(${CMAKE_SOURCE_DIR}/include)
5
diff --git a/trunk/ui/application.qml b/trunk/ui/application.qml
new file mode 100644
index 0000000..d1fdc1f
--- /dev/null
+++ b/trunk/ui/application.qml
@@ -0,0 +1,30 @@
1import QtQuick 2.4
2import QtQuick.Layouts 1.1
3import QtQuick.Controls 1.3
4
5Item {
6 width: 500; height: 500
7 Layout.alignment: Qt.AlignTop
8
9 signal shutdownButtonClicked()
10
11 ColumnLayout{
12 spacing: 0
13
14 Text {
15 id: textItem
16 color: "red"
17 text: "Secushare"
18 }
19
20 Button {
21 id: quitButton
22 text: "Quit"
23 onClicked:
24 {
25 shutdownButtonClicked()
26 Qt.quit()
27 }
28 }
29 }
30}