├── .gitignore
├── .gitmodules
├── LICENSE
├── README.md
├── dist
└── linux
│ └── pydio-ui
└── src
└── systray
├── .DS_Store
├── JSEventHandler.cpp
├── JSEventHandler.h
├── aboutdialog.cpp
├── aboutdialog.h
├── cmdhelper.cpp
├── cmdhelper.h
├── customtrayicon.cpp
├── customtrayicon.h
├── globals.h
├── httpmanager.cpp
├── httpmanager.h
├── images
├── PydioSync-Systray-Mac-Inactive.png
├── PydioSync-Systray-Mac-Transfer.png
├── PydioSync-Systray-Mac.png
├── PydioSync-Systray-Windows-Transfer.png
├── PydioSync-Systray-Windows.png
├── folder-32.png
└── world.png
├── job.cpp
├── job.h
├── jobaction.cpp
├── jobaction.h
├── jobmenu.cpp
├── jobmenu.h
├── languages
└── pydioUI_fr_FR.qm
├── localserver.cpp
├── localserver.h
├── main.cpp
├── portconfigurer.cpp
├── portconfigurer.h
├── pydioupdatepinger.cpp
├── pydioupdatepinger.h
├── smoketest.cpp
├── smoketest.h
├── systray.pro
├── systray.qrc
├── updatedialog.cpp
├── updatedialog.h
├── webkit-sources
├── about.html
└── reload_python.html
├── window.cpp
└── window.h
/.gitignore:
--------------------------------------------------------------------------------
1 | # In repository we don't need to have:
2 | # Compiled object files and libs
3 | *.slo
4 | *.lo
5 | *.o
6 | *.a
7 | *.la
8 | *.lai
9 | *.so
10 | *.dll
11 | *.dylib
12 | *.exe
13 |
14 | # Qt files
15 | moc_*.cpp
16 | ui_*.h
17 | *.pro.user
18 | *.pro.user.*
19 | *-build-*
20 | Makefile
21 |
22 | # Debug and Release directories (created under Windows, not Linux)
23 | bin/
24 | Debug/
25 | Release/
26 |
27 | # .log files (usually created by QtTest - thanks to VestniK)
28 | *.log
29 |
30 | # Windows-specific files
31 | Thumbs.db
32 | desktop.ini
33 |
34 | # Mac-specific things
35 | *.DS_Store
36 |
37 | # Editors temporary files
38 | *~
39 |
40 | # Foreign VCS files.
41 | .hg*
42 | .bzr*
43 | .svn*
44 |
45 | # Project directories
46 | externals/
47 |
48 | systray.pro.user
49 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pydio/pydio-sync-ui/5291c726cd22a5fb1d74aa939e5a8503231ac5b5/.gitmodules
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | The pydio-sync repository is providing a headless python script for running the synchro.
2 | It's based on the Qt (see http://qt-project.org) library.
3 |
4 | Since some changes have occurred with Qt 5, we recommend to install the latest version !
5 |
6 | ## Build instructions
7 |
8 | To run it, you must
9 | * Install Qt 5.2
10 | * Clone the project
11 | ```
12 | git clone git://github.com/pydio/pydio-sync-ui
13 | ```
14 | * Open the .pro file in Qt Creator and build the project or :
15 |
16 | ### On Mac OS
17 | ```
18 | export PATH=$PATH:/your/path/to/qmake
19 | ```
20 | * Generate a makefile from your project file
21 | ```
22 | cd /your/path/to/pydio-sync-ui/src/systray/
23 | qmake -o path/you/want/makefile/to/go systray.pro
24 | ```
25 | * Compile
26 | ```
27 | make
28 | ```
29 |
30 | #### Deployment
31 | ```
32 | cd ../../build
33 | macdeployqt pydio-ui.app -no-plugins
34 | open pydio-ui.app
35 | ```
36 |
37 | ### On Windows
38 | * Generate a makefile from your project file
39 | ```
40 | c:/qt/5.2.1/mingw48_32/bin/./qmake your/path/to/pydio-sync-ui/src/systray/systray.pro
41 | ```
42 | * Compile
43 | ```
44 | C:/Qt/Tools/mingw48_32/bin/./mingw32-make -f makefile
45 | ```
46 | * Add the following .dll files to the systray.exe folder :
47 | ```
48 | Qt5Core.dll
49 | Qt5Gui.dll
50 | Qt5Multimedia.dll
51 | Qt5MultimediaWidgets.dll
52 | Qt5Network.dll
53 | Qt5OpenGL.dll
54 | Qt5Positioning.dll
55 | Qt5PrintSupport.dll
56 | Qt5Qml.dll
57 | Qt5Quick.dll
58 | Qt5Sensors.dll
59 | Qt5Sql.dll
60 | Qt5WebKit.dll
61 | Qt5WebKitWidgets.dll
62 | Qt5Widgets.dll
63 | icudt51.dll
64 | icuin51.dll
65 | icuuc51.dll
66 | ```
67 | * Launch the UI
68 |
69 | Currently tested on Mac and Windows 7.
70 |
71 | ## Contributing
72 |
73 | Please sign the Contributor License Agreement before contributing.
74 |
--------------------------------------------------------------------------------
/dist/linux/pydio-ui:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pydio/pydio-sync-ui/5291c726cd22a5fb1d74aa939e5a8503231ac5b5/dist/linux/pydio-ui
--------------------------------------------------------------------------------
/src/systray/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pydio/pydio-sync-ui/5291c726cd22a5fb1d74aa939e5a8503231ac5b5/src/systray/.DS_Store
--------------------------------------------------------------------------------
/src/systray/JSEventHandler.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2007-2015 Charles du Jeu - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #include "JSEventHandler.h"
23 | #include "globals.h"
24 | #include
25 | #include
26 | #include
27 |
28 | JSEventHandler::JSEventHandler(QObject *parent) :
29 | QObject(parent)
30 | {
31 | }
32 |
33 | QString JSEventHandler::getPath()
34 | {
35 | QString pydioDir = QDir::homePath() + "/" + PYDIO_DATA_DIR;
36 | return QFileDialog::getExistingDirectory(0, tr("Select local path"), pydioDir, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
37 | }
38 |
39 | void JSEventHandler::openUrl(QString toOpen)
40 | {
41 | QDesktopServices::openUrl(QUrl::fromLocalFile(toOpen));
42 | }
43 |
44 | void JSEventHandler::openLogs(){
45 | QString logDir = CmdHelper::getAppDataDir();
46 | QDesktopServices::openUrl(QUrl::fromLocalFile(logDir));
47 | }
48 |
49 | void JSEventHandler::copyToClipBoard(QString value)
50 | {
51 | QClipboard *clipboard = QApplication::clipboard();
52 | clipboard->setText(value);
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/src/systray/JSEventHandler.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2007-2015 Charles du Jeu - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #ifndef JSEVENTHANDLER_H
23 | #define JSEVENTHANDLER_H
24 |
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 | class JSEventHandler : public QObject
31 | {
32 | Q_OBJECT
33 |
34 | public:
35 | explicit JSEventHandler(QObject *parent = 0);
36 |
37 | public slots:
38 | QString getPath();
39 | void openUrl(QString);
40 | void openLogs();
41 | void copyToClipBoard(QString value);
42 | };
43 |
44 |
45 | #endif // JSEVENTHANDLER_H
46 |
--------------------------------------------------------------------------------
/src/systray/aboutdialog.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2007-2015 Charles du Jeu - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #include "aboutdialog.h"
23 |
24 | AboutDialog::AboutDialog(QWidget *parent) :
25 | QDialog(parent)
26 | {
27 | aboutWebView = new QWebView(this);
28 | aboutWebView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
29 | this->resize(WIDTH, HEIGHT);
30 | }
31 |
32 | void AboutDialog::show(){
33 | aboutWebView->load(QUrl("qrc:/webkit-sources/about.html"));
34 | connect(aboutWebView, SIGNAL(linkClicked(QUrl)), this, SLOT(openLink(QUrl)));
35 | this->showNormal();
36 | aboutWebView->resize(this->width(), aboutWebView->height());
37 | this->adjustSize();
38 | }
39 |
40 | void AboutDialog::openLink(QUrl link){
41 | QDesktopServices::openUrl(link);
42 | }
43 |
--------------------------------------------------------------------------------
/src/systray/aboutdialog.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2007-2015 Charles du Jeu - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #ifndef ABOUTDIALOG_H
23 | #define ABOUTDIALOG_H
24 |
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 |
31 | class AboutDialog : public QDialog
32 | {
33 | Q_OBJECT
34 | public:
35 | explicit AboutDialog(QWidget *parent = 0);
36 | void show();
37 | QWebView *aboutWebView;
38 |
39 | signals:
40 |
41 | public slots:
42 | void openLink(QUrl);
43 |
44 | };
45 |
46 | #endif // ABOUTDIALOG_H
47 |
--------------------------------------------------------------------------------
/src/systray/cmdhelper.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2007-2015 Charles du Jeu - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #include "cmdhelper.h"
23 |
24 | CmdHelper::CmdHelper(QObject *parent, QString path) :
25 | QObject(parent)
26 | {
27 | this->pathToAgent = path;
28 | #ifdef Q_OS_WIN
29 | QString agentPath = QDir::currentPath() + AGENT_FILE_NAME_WIN;
30 | if(path != ""){
31 | agentPath = path;
32 | }
33 | qDebug()<<"Agent process will be launched at" + agentPath;
34 | this->pathToAgent = agentPath;
35 | #endif
36 | #ifdef Q_OS_LINUX
37 | QString agentPath = QFileInfo( QCoreApplication::applicationFilePath() ).dir().path() + AGENT_FILE_NAME_LINUX;
38 | if(path != ""){
39 | agentPath = path;
40 | }
41 | QFileInfo checkPath(agentPath);
42 | if(checkPath.exists() && checkPath.isFile()){
43 | qDebug()<<"Should try to start agent at " + agentPath;
44 | this->pathToAgent = agentPath;
45 | }else{
46 | qDebug()<<"Cannot find file " + agentPath + ", please start agent manually.";
47 | }
48 | #endif
49 | }
50 |
51 | void CmdHelper::launchAgentMac(bool stopBeforeLaunch){
52 | QProcess process;
53 | QString processName = "launchctl";
54 | QStringList arguments;
55 | if(stopBeforeLaunch){
56 | arguments = QStringList() << "remove"<< MAC_SERVICE_NAME_AGENT;
57 | process.start(processName, arguments);
58 | process.waitForStarted();
59 | process.waitForFinished();
60 | }
61 | arguments = QStringList()<<"load"<<"-w"<<"/Library/LaunchAgents/"+MAC_SERVICE_FILE_AGENT;
62 | process.start(processName, arguments);
63 | process.waitForStarted();
64 | process.waitForFinished();
65 | }
66 |
67 | void CmdHelper::launchAgentProcess(){
68 | if(this->pathToAgent != ""){
69 | QProcess::startDetached(pathToAgent, QStringList());
70 | QTimer::singleShot(1500, this, SIGNAL(winAgentLaunched()));
71 | }
72 | }
73 |
74 | void CmdHelper::stopAgentMac(){
75 | QProcess process;
76 | QString processName = "launchctl";
77 | QStringList arguments = QStringList() << "remove"<< MAC_SERVICE_NAME_AGENT;
78 | process.start(processName, arguments);
79 | process.waitForStarted();
80 | process.waitForFinished();
81 | arguments = QStringList() << "remove"<< MAC_SERVICE_NAME_UI;
82 | process.start(processName, arguments);
83 | process.waitForStarted();
84 | process.waitForFinished();
85 | }
86 |
--------------------------------------------------------------------------------
/src/systray/cmdhelper.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2007-2015 Charles du Jeu - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #ifndef CMDHELPER_H
23 | #define CMDHELPER_H
24 |
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 |
36 | class CmdHelper : public QObject
37 | {
38 | Q_OBJECT
39 | public:
40 | explicit CmdHelper(QObject *parent = 0, QString path = "");
41 | static QString getAppDataDir(){
42 | #ifdef Q_OS_WIN
43 | QProcessEnvironment a = QProcessEnvironment::systemEnvironment();
44 | return a.value("APPDATA") + '\\' + PYDIO_DATA_DIR;
45 | #endif
46 | return QFileInfo(QStandardPaths::writableLocation(QStandardPaths::DataLocation)).path() + "/" + PYDIO_DATA_DIR;
47 | }
48 |
49 | signals:
50 | void winAgentLaunched();
51 |
52 | public slots:
53 | void launchAgentMac(bool stopBeforeLaunch = false);
54 | void launchAgentProcess();
55 | void stopAgentMac();
56 |
57 | private:
58 | QString pathToAgent;
59 | };
60 |
61 | #endif // CMDHELPER_H
62 |
--------------------------------------------------------------------------------
/src/systray/customtrayicon.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2007-2015 Charles du Jeu - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #include "customtrayicon.h"
23 |
24 | CustomTrayIcon::CustomTrayIcon(QObject* parent) : QSystemTrayIcon(parent)
25 | {
26 |
27 | /*#ifdef Q_OS_MAC
28 | // Yes the files names are inverted...
29 | this->iconActive = QIcon(":/images/flat.sips.png");
30 | this->iconTransfer = QIcon(":/images/PydioSync-Systray-Windows-Transfer.png");
31 | this->iconInactive = QIcon(":/images/PydioSync-Systray-Mac-Inactive.png");
32 | #else*/
33 | this->iconActive = QIcon(":/images/PydioSync-Systray-Mac.png");
34 | this->iconTransfer = QIcon(":/images/PydioSync-Systray-Mac-Transfer.png");
35 | this->iconInactive = QIcon(":/images/PydioSync-Systray-Mac-Inactive.png");
36 | //#endif
37 |
38 | this->debugMode = true;
39 | this->pathToWinAgent = pathToWinAgent;
40 | this->syncAgentUp = false;
41 | this->setIconNormal();
42 | this->createMainMenu();
43 | this->jobMenus = new QHash();
44 | this->globalRunningStatus = false;
45 | this->singleJob = NULL;
46 | this->working = false;
47 | this->animationOn = false;
48 | this->normalIcon = false;
49 | this->agentConnectedToInternet = true;
50 |
51 | this->animationTimer = new QTimer(this);
52 | this->animationTimer->setInterval(1100);
53 | connect(animationTimer, SIGNAL(timeout()), this, SLOT(changeIcon()));
54 | separatorAction = new QAction(this);
55 | separatorAction->setSeparator(true);
56 | singleJobLocal = new QAction(tr("Open local folder"), this);
57 | singleJobLocal->setIcon(QIcon(":/images/folder-32.png"));
58 | connect(singleJobLocal, SIGNAL(triggered()), this, SLOT(openSingleJobLocal()));
59 | singleJobRemote = new QAction(tr("Open remote"), this);
60 | singleJobRemote->setIcon(QIcon(":/images/world.png"));
61 | connect(singleJobRemote, SIGNAL(triggered()), this, SLOT(openSingleJobRemote()));
62 | this->checkJobs();
63 | }
64 |
65 | void CustomTrayIcon::onNewJob(Job* job){
66 | debug("Should create job for" + job->getName());
67 | if(!this->syncAgentUp){
68 | this->connectionMade();
69 | }
70 | if(jobMenus->empty() && singleJob == NULL){
71 | this->contextMenu()->removeAction(noJobAction);
72 | this->insertSingleJob(job);
73 | }
74 | else if(jobMenus->size() == 0 && singleJob != NULL){
75 | debug("SHOULD DELETE SINGLEJOB AND CREATE MENUS");
76 | this->insertNewJobMenu(singleJob->getJob());
77 | this->removeSingleJob();
78 | this->insertNewJobMenu(job);
79 | }
80 | else{
81 | this->insertNewJobMenu(job);
82 | }
83 | this->checkJobs();
84 | }
85 |
86 | void CustomTrayIcon::insertNewJobMenu(Job* newJob){
87 | //debug("inserting new job");
88 | JobMenu *newJobMenu = new JobMenu(0, newJob);
89 | jobMenus->insert(newJob->getId(), newJobMenu);
90 | this->contextMenu()->insertMenu(settingsAction, newJobMenu);
91 | }
92 |
93 | void CustomTrayIcon::onJobUpdate(QString id){
94 | debug("SHOULD UPDATE : " + id);
95 | if(singleJob == NULL){
96 | jobMenus->operator [](id)->update();
97 | } else {
98 | singleJob->update();
99 | }
100 | this->checkJobs();
101 | }
102 |
103 | void CustomTrayIcon::jobsCleared(QString reason){
104 | if(!jobMenus->empty()){
105 | foreach(const QString &k, jobMenus->keys()){
106 | this->contextMenu()->removeAction(jobMenus->value(k)->menuAction());
107 | }
108 | jobMenus->clear();
109 | }
110 | else if(singleJob != NULL){
111 | this->removeSingleJob();
112 | }
113 | debug("JOBS ARE CLEARED, REASON : " + reason);
114 | }
115 |
116 | void CustomTrayIcon::onJobDeleted(QString id){
117 | debug("SHOULD DELETE JOB : " + id);
118 | if(singleJob)
119 | {
120 | this->removeSingleJob();
121 | }
122 | else if(jobMenus->size() == 2){
123 | this->contextMenu()->removeAction(jobMenus->value(id)->menuAction());
124 | jobMenus->remove(id);
125 | JobMenu *jobToConvert = jobMenus->begin().value();
126 | this->contextMenu()->removeAction(jobToConvert->menuAction());
127 | this->insertSingleJob(jobToConvert->getJob());
128 | jobMenus->clear();
129 | }
130 | else{
131 | this->contextMenu()->removeAction(jobMenus->value(id)->menuAction());
132 | jobMenus->remove(id);
133 | }
134 | this->checkJobs();
135 | }
136 |
137 | void CustomTrayIcon::insertSingleJob(Job *job){
138 | singleJob = new jobAction(this, job);
139 | singleJob->setDisabled(true);
140 | this->contextMenu()->removeAction(noJobAction);
141 | this->contextMenu()->insertAction(settingsAction, singleJob);
142 | this->contextMenu()->insertAction(settingsAction, singleJobLocal);
143 | this->contextMenu()->insertAction(settingsAction, singleJobRemote);
144 | this->contextMenu()->insertAction(settingsAction, separatorAction);
145 | }
146 |
147 | void CustomTrayIcon::removeSingleJob(){
148 | this->contextMenu()->removeAction(singleJob);
149 | this->contextMenu()->removeAction(singleJobLocal);
150 | this->contextMenu()->removeAction(singleJobRemote);
151 | this->contextMenu()->removeAction(separatorAction);
152 | singleJob = NULL;
153 | checkJobs();
154 | }
155 |
156 | void CustomTrayIcon::checkJobs(){
157 | if(!jobMenus->empty()){
158 | QList jMenus = jobMenus->values();
159 | globalRunningStatus = jMenus[0]->getJob()->getStatus();
160 | working = false;
161 | for(int i=0; igetJob();
163 | globalRunningStatus = globalRunningStatus || j->getStatus();
164 | working = working || j->isSyncing();
165 | }
166 | }
167 | else if(this->singleJob){
168 | globalRunningStatus = singleJob->getJob()->getStatus();
169 | working = singleJob->getJob()->isSyncing();
170 | }
171 | if(!this->singleJob && jobMenus->empty()){
172 | this->contextMenu()->insertAction(settingsAction,noJobAction);
173 | resumePauseSyncAction->setDisabled(true);
174 | }
175 | else{
176 | this->contextMenu()->removeAction(noJobAction);
177 | resumePauseSyncAction->setDisabled(false);
178 | }
179 | if(globalRunningStatus){
180 | resumePauseSyncAction->setText(tr("Pause sync"));
181 | resumePauseSyncAction->disconnect();
182 | connect(resumePauseSyncAction, SIGNAL(triggered()), this, SIGNAL(pauseSync()));
183 | }
184 | else{
185 | resumePauseSyncAction->setText(tr("Resume sync"));
186 | resumePauseSyncAction->disconnect();
187 | connect(resumePauseSyncAction, SIGNAL(triggered()), this, SIGNAL(resumeSync()));
188 | }
189 | if(working){
190 | this->workOccuring();
191 | }
192 | else{
193 | this->workDone();
194 | }
195 | }
196 |
197 | void CustomTrayIcon::connectionMade(){
198 | if(!this->syncAgentUp){
199 | debug("SINGLE JOB IS " + (singleJob ? singleJob->getJob()->getName() : "NULL"));
200 | debug("NUMBER OF JOBS : " + QString::number(this->jobMenus->size()));
201 | emit check_for_update();
202 | this->syncAgentUp = true;
203 | this->setIconNormal();
204 | this->normalIcon = true;
205 | this->jobsCleared("Connection Made");
206 | this->contextMenu()->removeAction(noAgentAction);
207 | this->contextMenu()->insertAction(settingsAction, noJobAction);
208 | settingsAction->setDisabled(false);
209 | //shareAction->setDisabled(false);
210 | this->contextMenu()->insertAction(aboutAction, resumePauseSyncAction);
211 | }
212 | }
213 |
214 | void CustomTrayIcon::connectionLost(){
215 | if(this->syncAgentUp){
216 | working = false;
217 | animationTimer->stop();
218 | animationOn = false;
219 | this->syncAgentUp = false;
220 | this->setIconInactive();
221 | this->normalIcon = false;
222 | this->jobsCleared("CONNECTION LOST");
223 | debug("Working status : Off / Animation : Off / Normal Icon : on");
224 | this->contextMenu()->removeAction(noJobAction);
225 | this->contextMenu()->insertAction(settingsAction, noAgentAction);
226 | settingsAction->setDisabled(true);
227 | //shareAction->setDisabled(true);
228 | this->contextMenu()->removeAction(resumePauseSyncAction);
229 | debug("SINGLE JOB IS " + (singleJob ? singleJob->getJob()->getName() : "NULL"));
230 | debug("NUMBER OF JOBS : " + QString::number(this->jobMenus->size()));
231 | }
232 | }
233 |
234 | void CustomTrayIcon::noInternetConnection(){
235 | if(agentConnectedToInternet){
236 | this->setIconInactive();
237 | this->contextMenu()->insertAction(settingsAction, noInternetAction);
238 | agentConnectedToInternet = false;
239 | }
240 | }
241 |
242 | void CustomTrayIcon::internetConnectionOk(){
243 | if(!agentConnectedToInternet){
244 | this->setIconNormal();
245 | this->contextMenu()->removeAction(noInternetAction);
246 | agentConnectedToInternet = true;
247 | }
248 | }
249 |
250 | void CustomTrayIcon::notificationReceived(QString jobId, QString type, QString message){
251 | QString jobTitle;
252 | if(singleJob == NULL && jobMenus->contains(jobId)){
253 | jobTitle = jobMenus->value(jobId)->getJob()->getName();
254 | } else {
255 | jobTitle = singleJob->getJob()->getName();
256 | }
257 | debug("NOTIFICATION RECEIVED: " + jobTitle + " - " + message);
258 | this->showMessage(jobTitle, message);
259 | }
260 |
261 | void CustomTrayIcon::createMainMenu(){
262 | this->createActions();
263 | mainMenu = new QMenu(0);
264 | mainMenu->addSeparator();
265 | mainMenu->addAction(settingsAction);
266 | mainMenu->insertAction(settingsAction, noAgentAction);
267 | //mainMenu->addAction(shareAction); // To be only enabled during debug
268 | mainMenu->addSeparator();
269 | mainMenu->addAction(aboutAction);
270 | mainMenu->addAction(quitAction);
271 | this->setContextMenu(mainMenu);
272 | }
273 |
274 | void CustomTrayIcon::createActions(){
275 | settingsAction = new QAction(tr("Settings"), this);
276 | connect(settingsAction, SIGNAL(triggered()), this->parent(), SLOT(show()));
277 | settingsAction->setDisabled(true);
278 |
279 | noJobAction = new QAction(tr("No active job"), this);
280 | noJobAction->setDisabled(true);
281 |
282 | /*
283 | #ifdef Q_OS_WIN
284 | noAgentAction = new QAction(tr("Launch agent"), this);
285 | connect(noAgentAction, SIGNAL(triggered()), this, SLOT(launchAgent()));
286 | #else
287 | */
288 | noAgentAction = new QAction(tr("No active agent"), this);
289 | noAgentAction->setDisabled(true);
290 |
291 | noInternetAction = new QAction(tr("Agent can't connect to the internet"), this);
292 | noInternetAction->setDisabled(true);
293 |
294 | resumePauseSyncAction = new QAction(tr("Pause sync"), this);
295 | connect(resumePauseSyncAction, SIGNAL(triggered()), this, SIGNAL(pauseSync()));
296 |
297 | aboutAction = new QAction(tr("About"), this);
298 | connect(aboutAction, SIGNAL(triggered()), this, SIGNAL(about()));
299 |
300 | // To be only enabled during debug
301 | //shareAction = new QAction(tr("Share"), this);
302 | //connect(shareAction, SIGNAL(triggered()), this, SIGNAL(share(QString, QString, QString)));
303 | //shareAction->setDisabled(true);
304 |
305 | quitAction = new QAction(tr("&Quit"), this);
306 | connect(quitAction, SIGNAL(triggered()), this, SIGNAL(quit()));
307 | }
308 |
309 | void CustomTrayIcon::openSingleJobLocal(){
310 | QDesktopServices::openUrl(this->singleJob->getJob()->getLocal());
311 | }
312 |
313 | void CustomTrayIcon::openSingleJobRemote(){
314 | QDesktopServices::openUrl(this->singleJob->getJob()->getRemote());
315 | }
316 |
317 | void CustomTrayIcon::launchAgent(){
318 | emit launchAgentSignal();
319 | }
320 |
321 | void CustomTrayIcon::workOccuring(){
322 | if(!animationOn){
323 | animationTimer->start();
324 | animationOn = true;
325 | }
326 | }
327 |
328 | void CustomTrayIcon::workDone(){
329 | if(animationOn){
330 | animationTimer->stop();
331 | animationOn = false;
332 | this->setIconNormal();
333 | normalIcon = true;
334 | }
335 | }
336 |
337 | void CustomTrayIcon::changeIcon(){
338 | if(normalIcon){
339 | this->setIconBusy();
340 | //this->animationTimer->setInterval(700);
341 | normalIcon = false;
342 | }else{
343 | this->setIconNormal();
344 | //this->animationTimer->setInterval(800);
345 | normalIcon = true;
346 | }
347 | }
348 |
349 | void CustomTrayIcon::setIconNormal(){
350 | qDebug() << "SETTING ICON normal";
351 | this->setIcon(this->iconActive);
352 | }
353 |
354 | void CustomTrayIcon::setIconBusy(){
355 | qDebug() << "SETTING ICON busy";
356 | this->setIcon(this->iconTransfer);
357 | }
358 |
359 | void CustomTrayIcon::setIconInactive(){
360 | qDebug() << "SETTING ICON inactive";
361 | this->setIcon(this->iconInactive);
362 | }
363 |
364 |
365 | bool CustomTrayIcon::agentUp(){
366 | return this->syncAgentUp;
367 | }
368 |
369 | void CustomTrayIcon::debug(QString s){
370 | if(this->debugMode)
371 | qDebug()<<" -- JOBSMANAGER -- : "<
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #ifndef CUSTOMTRAYICON_H
23 | #define CUSTOMTRAYICON_H
24 |
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 |
35 |
36 | class CustomTrayIcon : public QSystemTrayIcon
37 | {
38 | Q_OBJECT
39 | public:
40 | explicit CustomTrayIcon(QObject *parent = 0);
41 | bool agentUp();
42 | signals:
43 | void launchAgentSignal();
44 | void pauseSync();
45 | void resumeSync();
46 | void about();
47 | void quit();
48 | void connectionLostSignal();
49 | void check_for_update();
50 | void share(QString, QString, QString);
51 |
52 | public slots:
53 | void connectionMade();
54 | void connectionLost();
55 | void jobsCleared(QString reason="UNKNOWN REASON");
56 | void onNewJob(Job *newJob);
57 | void onJobDeleted(QString id);
58 | void onJobUpdate(QString id);
59 | void openSingleJobLocal();
60 | void openSingleJobRemote();
61 | void launchAgent();
62 | void changeIcon();
63 | void noInternetConnection();
64 | void internetConnectionOk();
65 | void notificationReceived(QString jobId, QString type, QString message);
66 |
67 | private:
68 | void createMainMenu();
69 | void createActions();
70 | void checkJobs();
71 | void insertNewJobMenu(Job*);
72 | void removeSingleJob();
73 | void insertSingleJob(Job *job);
74 | void debug(QString);
75 | void workOccuring();
76 | void workDone();
77 | void setIconNormal();
78 | void setIconBusy();
79 | void setIconInactive();
80 |
81 | QTimer *animationTimer;
82 | QMenu *mainMenu;
83 | QHash *jobMenus;
84 | QAction *noAgentAction;
85 | QAction *noJobAction;
86 | QAction *noInternetAction;
87 | QAction *settingsAction;
88 | QAction *quitAction;
89 | QAction *reconnectAction;
90 | QAction *resumePauseSyncAction;
91 | QAction *aboutAction;
92 | jobAction *singleJob;
93 | QAction *singleJobLocal;
94 | QAction *singleJobRemote;
95 | QAction *separatorAction;
96 | QIcon iconActive;
97 | QIcon iconInactive;
98 | QIcon iconTransfer;
99 | //QAction *shareAction;
100 |
101 | bool globalRunningStatus;
102 | bool syncAgentUp;
103 | bool agentConnectedToInternet;
104 | bool working;
105 | bool animationOn;
106 | bool normalIcon;
107 | bool debugMode;
108 | QString pathToWinAgent;
109 | };
110 |
111 | #endif // CUSTOMTRAYICON_H
112 |
--------------------------------------------------------------------------------
/src/systray/globals.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2007-2015 Charles du Jeu - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #ifndef GLOBALS_H
23 | #define GLOBALS_H
24 |
25 | const int WIDTH = 480;
26 | const int HEIGHT = 700;
27 | const int WIDTH_OFFSET_WIN = 15;
28 | const int HEIGHT_OFFSET_WIN = 80;
29 |
30 |
31 | const int POLL_TIME_AFTER_404 = 5000;
32 | const int POLL_INTERVAL = 2000;
33 | const static int MAX_CONNECTION_ATTEMPTS = 2;
34 |
35 |
36 | const QString AGENT_SERVER_URL = "http://127.0.0.1:";
37 | const static int DEFAULT_PORT = 5556;
38 | const QString AGENT_FILE_NAME_WIN = "/pydio-agent.exe";
39 | const QString AGENT_FILE_NAME_LINUX = "/../pydio-agent/pydio-agent";
40 | const QString MAC_SERVICE_FILE_AGENT = "io.pyd.sync.launcher.plist";
41 | const QString MAC_SERVICE_NAME_AGENT = "PydioSync";
42 | const QString MAC_SERVICE_NAME_UI = "PydioSyncUI";
43 | const QString ABOUT_PAGE_PATH = "/res/index.html#/about";
44 | const QString SHARE_PAGE_PATH = "/res/index.html#/share";
45 | const QString PORT_CONFIG_FILE_NAME = "ports_config";
46 | const QString PYDIO_DATA_DIR = "Pydio";
47 |
48 | const QString PYDIO_VERSION = "##VERSION##";
49 | const QString VERSION_DATE = "##VERSION_DATE##";
50 | const QString BUILD_CHANNEL = "##BUILD_CHANNEL##";
51 |
52 | const QString PYDIO_BUILD_ARCH = "##BUILD_ARCH##";
53 |
54 | const QString UPDATE_URL = "https://update.pydio.com/pub/";
55 | const QString UPDATE_PACKAGE_NAME = "pydio-sync";
56 | const bool CHECK_FOR_UPDATE = true;
57 |
58 | const QString LOCAL_SERVER_URL = "##LOCAL_SERVER_URL##";
59 | //"pydioLocalServer" for pydio-sync and "workspacesLocalServer" for workspaces-sync
60 |
61 | const QString MAC_EXT = "/Applications/PydioSync.app/Contents/Resources/pydioswiftsync.app";
62 |
63 | #endif // GLOBALS_H
64 |
--------------------------------------------------------------------------------
/src/systray/httpmanager.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2007-2015 Charles du Jeu - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #include "httpmanager.h"
23 | #include
24 | #include
25 |
26 | HTTPManager::HTTPManager(QObject *parent, QNetworkAccessManager *nmanager) :
27 | QObject(parent)
28 | {
29 | debugMode = true;
30 | manager = nmanager;
31 | connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(pollingFinished(QNetworkReply*)));
32 | connect(manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
33 | SLOT(provideAuthentication(QNetworkReply*,QAuthenticator*)));
34 | // HACK FOR AUTHENTICATION / MACOS / KEYCHAIN ON MACOS
35 | #ifdef Q_OS_MAC
36 | QNetworkProxy proxy = manager->proxy();
37 | proxy.setHostName(" ");
38 | manager->setProxy(proxy);
39 | #endif
40 |
41 | serverUrl = "";
42 | this->serverUsername = "";
43 | jobs = new QHash();
44 | failed_attempts = -1;
45 | launch = true;
46 | }
47 |
48 | void HTTPManager::setUrl(QString servUrl, QString username, QString password)
49 | {
50 | debug("Server set to " + servUrl);
51 | this->serverUrl = servUrl;
52 | this->serverUsername = username;
53 | this->serverPassword = password;
54 | debug("Username set to " + username);
55 | failed_attempts = -1;
56 | jobs->clear();
57 | }
58 |
59 | void HTTPManager::poll()
60 | {
61 | manager->setNetworkAccessible(QNetworkAccessManager::UnknownAccessibility);
62 | manager->clearAccessCache();
63 | manager->get(QNetworkRequest(QUrl(this->serverUrl + "/jobs-status")));
64 | }
65 |
66 | void HTTPManager::provideAuthentication(QNetworkReply *reply, QAuthenticator *authenticator)
67 | {
68 | //qDebug() << reply->error(); // this is just to see what we received
69 | if(failed_attempts > 3){
70 | debug("Skipping authentication with name " + this->serverUsername);
71 | return;
72 | }
73 | if(this->serverUsername != ""){
74 | debug("Providing authentication with name " + this->serverUsername);
75 | authenticator->setUser(this->serverUsername);
76 | authenticator->setPassword(this->serverPassword);
77 | failed_attempts ++;
78 | }
79 | }
80 |
81 | void HTTPManager::pollingFinished(QNetworkReply* reply)
82 | {
83 | if (reply->error() == QNetworkReply::NoError){
84 | //read the server response
85 | QString strReply = (QString)reply->readAll();
86 |
87 | // this non-case is for when we terminate the python agent
88 | if(strReply != "\"success\""){
89 | if(failed_attempts != 0){
90 | debug("-----------------------CONNECTION MADE-----------------------");
91 | emit agentReached();
92 | failed_attempts = 0;
93 | }
94 |
95 | // parse JSON response
96 |
97 | QJsonObject jsonResponse = QJsonDocument::fromJson(strReply.toUtf8()).object();
98 | QJsonValue value = jsonResponse.value("jobs");
99 | QJsonArray jsonJobs = value.toArray();
100 | bool agentInternetStatus = jsonResponse.value("is_connected_to_internet").toBool();
101 |
102 | if(!agentInternetStatus){
103 | emit noInternetConnection();
104 | }else{
105 | emit internetConnectionOk();
106 | }
107 | // process response
108 | if(!jsonResponse.isEmpty()){
109 | if(jsonJobs.count()==0){
110 | this->checkNoJobAtLaunch();
111 | if(!jobs->empty()){
112 | this->jobs->clear();
113 | }
114 | this->debug("JSON JOBS EMPTY");
115 | emit this->jobsCleared();
116 | }
117 | else{
118 | foreach(QString id, jobs->keys()){
119 | bool present = false;
120 | foreach(QJsonValue jsonJob, jsonJobs){
121 | QJsonObject job = jsonJob.toObject();
122 | QString jobId = job["id"].toString();
123 | if(jobId == id){
124 | present = true;
125 | }
126 | }
127 | if(present == false){
128 | this->jobs->remove(id);
129 | emit jobDeleted(id);
130 | }
131 | }
132 |
133 | foreach(QJsonValue jsonJob, jsonJobs){
134 | // parse job objects
135 | QJsonObject job = jsonJob.toObject();
136 | QString jobId = job["id"].toString();
137 | QString label = job["label"].toString();
138 | QString lastEventMessage = job["last_event"].toObject().operator []("message").toString();
139 | if(job.contains("notification")){
140 | QString notification = job["notification"].toObject().operator []("message").toString();
141 | this->jobNotifyMessage(jobId, "sync", notification);
142 | }
143 | QString local = job["directory"].toString();
144 | QString remote = job["server"].toString();
145 | bool running = job["running"].toBool();
146 | int total_tasks = job["state"].toObject().operator []("tasks").toObject().operator[]("total").toInt();
147 | double eta = -1;
148 | bool hasWork = false;
149 | // if job has pending tasks we update it
150 | if(total_tasks > 0){
151 | eta = job["state"].toObject().operator []("global").toObject().operator[]("eta").toDouble();
152 | hasWork = true;
153 | }
154 |
155 | // if jobs doesn't exist here, we create it
156 | if(!this->jobs->contains(jobId)){
157 | if(job["active"].toBool()){
158 | // create a new active job, add it and notify the main class
159 | Job *newJob = new Job(jobId, label, running, hasWork, eta, lastEventMessage, local, remote);
160 | connect(newJob, SIGNAL(updated(QString)), this, SIGNAL(jobUpdated(QString)));
161 | this->jobs->insert(jobId, newJob);
162 | emit this->newJob(newJob);
163 | }
164 | }
165 | // if job exists and is active, we update it, otherwise we delete it
166 | else{
167 | if(!job["active"].toBool()){
168 | this->jobs->remove(jobId);
169 | emit jobDeleted(jobId);
170 | }
171 | else{
172 | jobs->value(jobId)->update(label, running, hasWork, eta, lastEventMessage);
173 | }
174 | }
175 | }
176 | }
177 | }
178 | }
179 | }else{
180 | if(failed_attempts < MAX_CONNECTION_ATTEMPTS)
181 | debug("HTTP Poller Reply : " + reply->errorString());
182 | ++failed_attempts;
183 | if(failed_attempts >= MAX_CONNECTION_ATTEMPTS){
184 | debug("-----------------------MAX CONNECTION ATTEMPTS REACHED, CLEARING JOBS-----------------------");
185 | this->jobs->clear();
186 | emit connectionProblem();
187 | }
188 | }
189 | reply->deleteLater();
190 | emit requestFinished();
191 | }
192 |
193 | void HTTPManager::checkNoJobAtLaunch(){
194 | if(launch){
195 | launch = false;
196 | QTimer *t = new QTimer(this);
197 | connect(t, SIGNAL(timeout()), this, SIGNAL(noActiveJobsAtLaunch()));
198 | t->setInterval(2000);
199 | t->setSingleShot(true);
200 | t->start();
201 | }
202 | }
203 |
204 | void HTTPManager::headRequestFinished(QNetworkReply* reply){
205 | if(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 404){
206 | emit webUI404();
207 | }
208 | }
209 |
210 | void HTTPManager::testWebView(){
211 | QNetworkAccessManager *headManager = new QNetworkAccessManager();
212 | connect(headManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(headRequestFinished(QNetworkReply*)));
213 | headManager->head(QNetworkRequest(QUrl(this->serverUrl + "/res/index.html")));
214 | headManager->head(QNetworkRequest(QUrl(this->serverUrl + "/res/angularjs/angular.min.js")));
215 | }
216 |
217 | void HTTPManager::resumeSync(){
218 | manager->get(QNetworkRequest(QUrl(this->serverUrl + "/cmd/start-all")));
219 | }
220 |
221 | void HTTPManager::pauseSync(){
222 | manager->get(QNetworkRequest(QUrl(this->serverUrl + "/cmd/pause-all")));
223 | }
224 |
225 | void HTTPManager::terminateAgent(){
226 | manager->get(QNetworkRequest(QUrl(this->serverUrl + "/cmd/exit")));
227 | }
228 |
229 | void HTTPManager::debug(QString s){
230 | if(this->debugMode)
231 | qDebug()<<" -- HTTPMANAGER -- : "<
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #ifndef HTTPMANAGER_H
23 | #define HTTPMANAGER_H
24 |
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 |
38 |
39 | class HTTPManager : public QObject
40 | {
41 | Q_OBJECT
42 | public:
43 | HTTPManager(QObject *parent = 0, QNetworkAccessManager* QNetworkAccessManager=NULL);
44 | void setUrl(QString, QString, QString);
45 | void testWebView();
46 |
47 | signals:
48 | void requestFinished();
49 | void newJob(Job*);
50 | void jobUpdated(QString);
51 | void jobDeleted(QString);
52 | void connectionProblem();
53 | void agentReached();
54 | void noActiveJobsAtLaunch();
55 | void jobsCleared();
56 | void webUI404();
57 | void noInternetConnection();
58 | void internetConnectionOk();
59 | void jobNotifyMessage(QString,QString,QString);
60 |
61 | public slots:
62 | void poll();
63 | void pollingFinished(QNetworkReply*);
64 | void headRequestFinished(QNetworkReply*);
65 | void resumeSync();
66 | void pauseSync();
67 | void terminateAgent();
68 | void provideAuthentication(QNetworkReply *, QAuthenticator *);
69 |
70 | private:
71 | bool debugMode;
72 | QNetworkAccessManager *manager;
73 | QString serverUrl;
74 | QString serverUsername;
75 | QString serverPassword;
76 | QHash *jobs;
77 | int failed_attempts;
78 | bool launch;
79 | void checkNoJobAtLaunch();
80 | void debug(QString);
81 | };
82 |
83 | #endif // HTTPManager_H
84 |
--------------------------------------------------------------------------------
/src/systray/images/PydioSync-Systray-Mac-Inactive.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pydio/pydio-sync-ui/5291c726cd22a5fb1d74aa939e5a8503231ac5b5/src/systray/images/PydioSync-Systray-Mac-Inactive.png
--------------------------------------------------------------------------------
/src/systray/images/PydioSync-Systray-Mac-Transfer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pydio/pydio-sync-ui/5291c726cd22a5fb1d74aa939e5a8503231ac5b5/src/systray/images/PydioSync-Systray-Mac-Transfer.png
--------------------------------------------------------------------------------
/src/systray/images/PydioSync-Systray-Mac.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pydio/pydio-sync-ui/5291c726cd22a5fb1d74aa939e5a8503231ac5b5/src/systray/images/PydioSync-Systray-Mac.png
--------------------------------------------------------------------------------
/src/systray/images/PydioSync-Systray-Windows-Transfer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pydio/pydio-sync-ui/5291c726cd22a5fb1d74aa939e5a8503231ac5b5/src/systray/images/PydioSync-Systray-Windows-Transfer.png
--------------------------------------------------------------------------------
/src/systray/images/PydioSync-Systray-Windows.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pydio/pydio-sync-ui/5291c726cd22a5fb1d74aa939e5a8503231ac5b5/src/systray/images/PydioSync-Systray-Windows.png
--------------------------------------------------------------------------------
/src/systray/images/folder-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pydio/pydio-sync-ui/5291c726cd22a5fb1d74aa939e5a8503231ac5b5/src/systray/images/folder-32.png
--------------------------------------------------------------------------------
/src/systray/images/world.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pydio/pydio-sync-ui/5291c726cd22a5fb1d74aa939e5a8503231ac5b5/src/systray/images/world.png
--------------------------------------------------------------------------------
/src/systray/job.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2007-2015 Charles du Jeu - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #include "job.h"
23 | #include
24 |
25 | Job::Job(QObject *parent) :
26 | QObject(parent)
27 | {
28 | }
29 |
30 | Job::Job(QString id, QString name, bool running, bool hasWork, double eta, QString lastEventMessage, QString local, QString remote)
31 | {
32 | this->id = id;
33 | this->name = name;
34 | this->remainingTime = eta;
35 | this->status = running;
36 | this->lastEventMessage = lastEventMessage;
37 | this->remote = QUrl(remote);
38 | this->hasWork = hasWork;
39 | this->local = QUrl::fromLocalFile(local);
40 | }
41 |
42 | void Job::update(QString newName, bool newStatus, bool hasWork, double eta, QString lastEventMessage)
43 | {
44 | bool updated = false;
45 | if(this->name != newName){
46 | this->name = newName;
47 | updated = true;
48 | }
49 | if(this->status != newStatus){
50 | this->status = newStatus;
51 | updated = true;
52 | }
53 | if(this->remainingTime != eta){
54 | this->remainingTime = eta;
55 | updated = true;
56 | }
57 | if(this->hasWork != hasWork){
58 | this->hasWork = hasWork;
59 | emit this->updated(this->id);
60 | }
61 | if((this->lastEventMessage != lastEventMessage && (lastEventMessage != "Status: Paused"))){
62 | this->lastEventMessage = lastEventMessage;
63 | updated = true;
64 | }
65 | if(updated){
66 | emit this->updated(this->id);
67 | }
68 | }
69 |
70 | QString Job::getId()
71 | {
72 | return this->id;
73 | }
74 |
75 | bool Job::getStatus(){
76 | return this->status;
77 | }
78 |
79 | QString Job::getName(){
80 | return this->name;
81 | }
82 |
83 | QUrl Job::getLocal(){
84 | return this->local;
85 | }
86 |
87 | QUrl Job::getRemote(){
88 | return this->remote;
89 | }
90 |
91 | bool Job::isSyncing(){
92 | return (hasWork && status);
93 | }
94 |
95 | QString Job::getJobDescription()
96 | {
97 | QString desc;
98 | if(this->status){
99 | if(this->remainingTime <= 0){
100 | desc = "idle (" + this->lastEventMessage + ")";
101 | }
102 | else{
103 | desc = "syncing (" + this->remainingTimeToString() + " remaining)";
104 | }
105 | }
106 | else{
107 | desc = "Paused";
108 | }
109 | return desc;
110 | }
111 |
112 | QString Job::remainingTimeToString(){
113 | QTime time = QDateTime::fromTime_t(this->remainingTime).toUTC().time();
114 | if(time.hour() == 0){
115 | if(time.minute() == 0){
116 | return time.toString("ss's'");
117 | }
118 | return time.toString("mm'min':ss");
119 | }
120 | return time.toString("hh'h':mm:ss");
121 | }
122 |
--------------------------------------------------------------------------------
/src/systray/job.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2007-2015 Charles du Jeu - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #ifndef JOB_H
23 | #define JOB_H
24 |
25 | #include
26 | #include
27 | #include
28 |
29 | class Job : public QObject
30 | {
31 | Q_OBJECT
32 | public:
33 | explicit Job(QObject *parent = 0);
34 | Job(QString, QString, bool, bool, double, QString, QString, QString);
35 | void update(QString, bool, bool, double, QString);
36 | QString getJobDescription();
37 | QString getId();
38 | bool getStatus();
39 | QString getName();
40 | QUrl getLocal();
41 | QUrl getRemote();
42 | bool isSyncing();
43 |
44 | signals:
45 | void updated(QString id);
46 |
47 | private:
48 | QString name;
49 | bool hasWork;
50 | bool status;
51 | double remainingTime;
52 | QString id;
53 | QString lastEventMessage;
54 | QUrl local;
55 | QUrl remote;
56 |
57 | QString remainingTimeToString();
58 |
59 | };
60 |
61 | #endif // JOB_H
62 |
--------------------------------------------------------------------------------
/src/systray/jobaction.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2007-2015 Charles du Jeu - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #include "jobaction.h"
23 |
24 | jobAction::jobAction(QObject *parent, Job *job) :
25 | QAction(parent)
26 | {
27 | this->job = job;
28 | if (this->job != NULL)
29 | this->setText(job->getName() + " - " + job->getJobDescription());
30 | }
31 |
32 | void jobAction::setJob(Job* newJob){
33 | this->job = newJob;
34 | }
35 |
36 | Job* jobAction::getJob(){
37 | return this->job;
38 | }
39 |
40 | void jobAction::update(){
41 | if (this->job != NULL)
42 | this->setText(job->getName() + " - " + job->getJobDescription());
43 | }
44 |
--------------------------------------------------------------------------------
/src/systray/jobaction.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2007-2015 Charles du Jeu - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #ifndef JOBACTION_H
23 | #define JOBACTION_H
24 |
25 | #include
26 | #include
27 |
28 | class jobAction : public QAction
29 | {
30 | Q_OBJECT
31 | public:
32 | explicit jobAction(QObject *parent = 0, Job *job = 0);
33 | Job* getJob();
34 | void setJob(Job* newJob);
35 | void update();
36 |
37 | private:
38 | Job *job;
39 |
40 | };
41 |
42 | #endif // JOBACTION_H
43 |
--------------------------------------------------------------------------------
/src/systray/jobmenu.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2007-2015 Charles du Jeu - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #include "jobmenu.h"
23 |
24 | JobMenu::JobMenu(QWidget *parent, Job *job) :
25 | QMenu(parent)
26 | {
27 | this->job = job;
28 | if(this->job != NULL){
29 | this->setTitle(job->getName());
30 | }
31 | status = new QAction(job->getJobDescription(), this);
32 | status->setDisabled(true);
33 | openLocalAction = new QAction(tr("Open local folder"), this);
34 | openLocalAction->setIcon(QIcon(":/images/folder-32.png"));
35 | connect(openLocalAction, SIGNAL(triggered()), this, SLOT(openLocal()));
36 | openRemoteAction = new QAction(tr("Open remote"), this);
37 | openRemoteAction->setIcon(QIcon(":/images/world.png"));
38 | connect(openRemoteAction, SIGNAL(triggered()), this, SLOT(openRemote()));
39 |
40 | this->addAction(status);
41 | this->addAction(openLocalAction);
42 | this->addAction(openRemoteAction);
43 | }
44 |
45 | Job* JobMenu::getJob(){
46 | return this->job;
47 | }
48 |
49 | void JobMenu::update(){
50 | if (this->job != NULL){
51 | status->setText(this->job->getJobDescription());
52 | }
53 | }
54 |
55 | void JobMenu::openLocal(){
56 | QDesktopServices::openUrl(this->getJob()->getLocal());
57 | }
58 |
59 | void JobMenu::openRemote(){
60 | QDesktopServices::openUrl(this->getJob()->getRemote());
61 | }
62 |
--------------------------------------------------------------------------------
/src/systray/jobmenu.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2007-2015 Charles du Jeu - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #ifndef JOBMENU_H
23 | #define JOBMENU_H
24 |
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 |
31 | class JobMenu : public QMenu
32 | {
33 | Q_OBJECT
34 | public:
35 | explicit JobMenu(QWidget *parent = 0, Job *job = 0);
36 | Job* getJob();
37 | void update();
38 |
39 | private:
40 | QAction *status;
41 | QAction *openLocalAction;
42 | QAction *openRemoteAction;
43 | Job *job;
44 |
45 | public slots:
46 | void openLocal();
47 | void openRemote();
48 |
49 | };
50 |
51 | #endif // JOBMENU_H
52 |
--------------------------------------------------------------------------------
/src/systray/languages/pydioUI_fr_FR.qm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pydio/pydio-sync-ui/5291c726cd22a5fb1d74aa939e5a8503231ac5b5/src/systray/languages/pydioUI_fr_FR.qm
--------------------------------------------------------------------------------
/src/systray/localserver.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2015 Sagar Uday Kumar - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #include "localserver.h"
23 |
24 | #include
25 | #include
26 |
27 | #include
28 | #include
29 |
30 |
31 | LocalServer::LocalServer(QObject *parent) :
32 | QObject(parent)
33 | {
34 | localserver = new QLocalServer(this);
35 | QString namedpipe;
36 | #ifdef Q_OS_WIN
37 | namedpipe = LOCAL_SERVER_URL;
38 | #else
39 | namedpipe = "/tmp/" + LOCAL_SERVER_URL;
40 | #endif
41 | if (!localserver->listen(namedpipe)) {
42 | qDebug() << "Failed to open named pipe, deleting and trying again...";
43 | if (!QLocalServer::removeServer(namedpipe))
44 | qDebug() << "Failed to delete named pipe";
45 | if (!localserver->listen(namedpipe)) {
46 | qDebug() << "Trying to delete named pipe wasn't enough";
47 | } else {
48 | qDebug() << "FIFO ok";
49 | }
50 | }
51 | connect(localserver, SIGNAL(newConnection()), this, SLOT(GenerateLink()));
52 | return;
53 | }
54 |
55 | void LocalServer::GenerateLink()
56 | {
57 | QLocalSocket *clientConnection = localserver->nextPendingConnection();
58 | connect(clientConnection, SIGNAL(disconnected()),
59 | clientConnection, SLOT(deleteLater()));
60 |
61 | if (!clientConnection->waitForReadyRead()) {
62 | clientConnection->disconnectFromServer();
63 | return;
64 | }
65 |
66 | // read the data recieved from the server and convert it into Json
67 | QByteArray buffer;
68 | QDataStream in(&buffer, QIODevice::ReadOnly);
69 | buffer.append(clientConnection->readAll());
70 | QString temp(buffer);
71 | QJsonDocument jsonResponse = QJsonDocument::fromJson(temp.toUtf8());
72 | QJsonObject jsonObject = jsonResponse.object();
73 |
74 | QString ItemType = "file";
75 | if (jsonObject["FolderFlag"].toString() == "true")
76 | ItemType = "folder";
77 |
78 | // emit the share signal
79 | emit share(jsonObject["JobId"].toString(), ItemType, jsonObject["RelativePath"].toString());
80 |
81 | clientConnection->disconnectFromServer();
82 | }
83 |
--------------------------------------------------------------------------------
/src/systray/localserver.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2015 Sagar Uday Kumar - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #ifndef LOCALSERVER_H
23 | #define LOCALSERVER_H
24 |
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 | QT_BEGIN_NAMESPACE
31 | class QLocalServer;
32 | QT_END_NAMESPACE
33 |
34 | class LocalServer : public QObject
35 | {
36 | Q_OBJECT
37 | //static QString fileName;
38 |
39 | public:
40 | LocalServer(QObject *parent = 0);
41 | QString fileName;
42 |
43 | signals:
44 | void share(QString, QString, QString);
45 |
46 | private slots:
47 | void GenerateLink();
48 |
49 | private:
50 | QLocalServer *localserver;
51 | JSEventHandler *jseventhandler;
52 | };
53 |
54 | #endif // LOCALSERVER_H
55 |
--------------------------------------------------------------------------------
/src/systray/main.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2007-2015 Charles du Jeu - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 |
23 | #include
24 | #include
25 | #ifndef QT_NO_SYSTEMTRAYICON
26 |
27 | #include
28 | #include "window.h"
29 | int pydiosync(QApplication *app, QNetworkAccessManager *networkManager){
30 | if (!QSystemTrayIcon::isSystemTrayAvailable()) {
31 | QMessageBox::critical(0, QObject::tr("Systray"),
32 | QObject::tr("I couldn't detect any system tray "
33 | "on this system."));
34 | return 1;
35 | }
36 | QTranslator myappTranslator;
37 | myappTranslator.load(":/languages/pydioUI_" + QLocale::system().name());
38 | app->installTranslator(&myappTranslator);
39 | QApplication::setQuitOnLastWindowClosed(false);
40 |
41 | Window window(networkManager);
42 | return app->exec();
43 | }
44 |
45 | int main(int argc, char *argv[]) {
46 | Q_INIT_RESOURCE(systray);
47 | // On some versions of Qt initialising the network manager before the app reduces CPU peaks
48 | QApplication *app = new QApplication(argc, argv);
49 | QNetworkAccessManager *networkManager = new QNetworkAccessManager; // Unfortunately iniatilizing it before QApplication causes missing graphics libraries errors on most platforms.
50 | return pydiosync(app, networkManager);
51 | }
52 |
53 | #else
54 |
55 | #include
56 | #include
57 |
58 | int main(int argc, char *argv[])
59 | {
60 | QApplication app(argc, argv);
61 | QString text("QSystemTrayIcon is not supported on this platform");
62 |
63 | QLabel *label = new QLabel(text);
64 | label->setWordWrap(true);
65 |
66 | label->show();
67 | qDebug() << text;
68 |
69 | app.exec();
70 | }
71 | #endif
72 |
--------------------------------------------------------------------------------
/src/systray/portconfigurer.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2007-2015 Charles du Jeu - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #include "portconfigurer.h"
23 |
24 | PortConfigurer::PortConfigurer(QString pathToFile)
25 | {
26 | ipAddress = AGENT_SERVER_URL;
27 | configFile = new QFile(pathToFile);
28 | api_username = "";
29 | api_password = "";
30 | }
31 |
32 | void PortConfigurer::setPortsToDefault()
33 | {
34 | api_port = QString::number(DEFAULT_PORT);
35 | }
36 |
37 | QString PortConfigurer::port()
38 | {
39 | return this->api_port;
40 | }
41 |
42 | QString PortConfigurer::username()
43 | {
44 | return this->api_username;
45 | }
46 |
47 | QString PortConfigurer::password()
48 | {
49 | return this->api_password;
50 | }
51 |
52 | QString PortConfigurer::address()
53 | {
54 | return ipAddress + port();
55 | }
56 |
57 | void PortConfigurer::updatePorts()
58 | {
59 | if(!configFile->open(QIODevice::ReadOnly | QIODevice::Text)){
60 | setPortsToDefault();
61 | return;
62 | }
63 |
64 | QTextStream in(configFile);
65 | if(!in.readLine().startsWith("Pydio port config file")){
66 | setPortsToDefault();
67 | return;
68 | }
69 | while(!in.atEnd()){
70 | // line is pydio:PORT:USER:PASSWORD
71 | QStringList line = in.readLine().split(":", QString::SkipEmptyParts);
72 | api_port = line[1];
73 | if(line.size() == 4){
74 | api_username = line[2];
75 | api_password = line[3];
76 | }
77 | }
78 | configFile->close();
79 | }
80 |
--------------------------------------------------------------------------------
/src/systray/portconfigurer.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2007-2015 Charles du Jeu - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #ifndef PORTCONFIGURER_H
23 | #define PORTCONFIGURER_H
24 |
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 |
31 | class PortConfigurer
32 | {
33 | public:
34 | PortConfigurer(QString pathToFile);
35 | QString port();
36 | QString address();
37 | QString username();
38 | QString password();
39 | void updatePorts();
40 |
41 | private:
42 | void setPortsToDefault();
43 | QString ipAddress;
44 | QFile *configFile;
45 | QString api_port;
46 | QString api_username;
47 | QString api_password;
48 | };
49 |
50 | #endif // PORTCONFIGURER_H
51 |
--------------------------------------------------------------------------------
/src/systray/pydioupdatepinger.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2007-2015 Charles du Jeu - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #include "pydioupdatepinger.h"
23 | #include
24 |
25 | PydioUpdatePinger::PydioUpdatePinger(QObject *parent) :
26 | QObject(parent)
27 | {
28 | manager = new QNetworkAccessManager(parent);
29 | connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(requestFinished(QNetworkReply*)));
30 | connect(manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), this,
31 | SLOT(provideAuthentication(QNetworkReply*,QAuthenticator*)));
32 | this->serverUsername = "";
33 | failed_attempts = -1;
34 | }
35 |
36 | void PydioUpdatePinger::lookForUpdate(QString servUrl, QString username, QString password){
37 |
38 | if(BUILD_CHANNEL == "##BUILD_CHANNEL##") {
39 | // We are on develop mode, let's do nothing
40 | return;
41 | }
42 |
43 | QString url = UPDATE_URL+"?package="+UPDATE_PACKAGE_NAME+
44 | "&channel="+BUILD_CHANNEL+"&version="+PYDIO_VERSION+"&"
45 | "arch="+PYDIO_BUILD_ARCH+"&version_date="+VERSION_DATE;
46 |
47 | this->serverUrl = servUrl;
48 | this->serverUsername = username;
49 | this->serverPassword = password;
50 |
51 | manager->get(QNetworkRequest(QUrl(this->serverUrl + "/url/" + QUrl::toPercentEncoding(url))));
52 | }
53 |
54 | void PydioUpdatePinger::requestFinished(QNetworkReply* reply){
55 | if (reply->error() == QNetworkReply::NoError){
56 | //read the server response
57 | QString strReply = (QString)reply->readAll();
58 |
59 | // parse JSON response
60 | QJsonObject jsonResponse = QJsonDocument::fromJson(strReply.toUtf8()).object();
61 | QJsonValue jsonPackage = jsonResponse.value("package");
62 | if(jsonPackage.isUndefined()){
63 | qDebug()<<"NO NEW VERSION";
64 | }else{
65 | QString package = jsonPackage.toString();
66 | QString version = jsonResponse.value("version").toString();
67 | QString releaseNote = jsonResponse.value("release_note").toString();
68 | QString md5 = jsonResponse.value("md5").toString();
69 | //qDebug()<updateFound(package, version, releaseNote, md5);
71 | }
72 | }
73 | else{
74 | qDebug("ERROR WITH UPDATE REQUEST");
75 | }
76 | reply->deleteLater();
77 | }
78 |
79 | void PydioUpdatePinger::provideAuthentication(QNetworkReply *reply, QAuthenticator *authenticator)
80 | {
81 | if(failed_attempts > 3){
82 | debug("Skipping authentication with name " + this->serverUsername);
83 | return;
84 | }
85 | if(this->serverUsername != ""){
86 | debug("Providing authentication with name " + this->serverUsername);
87 | authenticator->setUser(this->serverUsername);
88 | authenticator->setPassword(this->serverPassword);
89 | failed_attempts ++;
90 | }
91 | }
92 |
93 | void PydioUpdatePinger::debug(QString s){
94 | if(this->debugMode)
95 | qDebug()<<" -- PydioUpdatePinger -- : "<
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #ifndef PYDIOUPDATEPINGER_H
23 | #define PYDIOUPDATEPINGER_H
24 |
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 |
38 | #include
39 |
40 | class PydioUpdatePinger : public QObject
41 | {
42 | Q_OBJECT
43 | public:
44 | explicit PydioUpdatePinger(QObject *parent = 0);
45 | void lookForUpdate(QString servUrl, QString username, QString password);
46 |
47 | private:
48 | bool debugMode;
49 | QNetworkAccessManager *manager;
50 | PortConfigurer *portConfigurer;
51 | QString serverUrl;
52 | QString serverUsername;
53 | QString serverPassword;
54 | int failed_attempts;
55 | void debug(QString);
56 |
57 | signals:
58 | void updateFound(QString, QString, QString, QString);
59 |
60 | public slots:
61 | void requestFinished(QNetworkReply*);
62 | void provideAuthentication(QNetworkReply *, QAuthenticator *);
63 | };
64 |
65 | #endif // PYDIOUPDATEPINGER_H
66 |
--------------------------------------------------------------------------------
/src/systray/smoketest.cpp:
--------------------------------------------------------------------------------
1 | #include "smoketest.h"
2 |
3 | SmokeTest::SmokeTest(nzmqt::ZMQContext& context, QString ad, QObject* parent)
4 | : super(parent), address(ad)
5 | {
6 | requestMsg = "smoketest";
7 | replyMsg = "all seems ok";
8 |
9 | reqSocket = context.createSocket(nzmqt::ZMQSocket::TYP_REQ, this);
10 | reqSocket->setLinger(100);
11 | connect(reqSocket, SIGNAL(messageReceived(const QList&)), SLOT(receiveReply(const QList&)));
12 | reqSocket->connectTo(address);
13 |
14 | repSocket = context.createSocket(nzmqt::ZMQSocket::TYP_REP, this);
15 | repSocket->setLinger(100);
16 | connect(repSocket, SIGNAL(messageReceived(const QList&)), SLOT(receiveRequest(const QList&)));
17 | repSocket->bindTo(address);
18 | }
19 |
20 | void SmokeTest::launch()
21 | {
22 | reqSocket->sendMessage(requestMsg.toLocal8Bit());
23 | qDebug()<<"Smoke Test Client :: Request Sent >"<& reply)
27 | {
28 | QString replyString;
29 | for(int i=0; i"<endTest();
35 | }
36 |
37 | void SmokeTest::receiveRequest(const QList& request)
38 | {
39 | QString requestString;
40 | for(int i=0; i"<sendMessage(replyMsg.toLocal8Bit());
46 | qDebug()<<"Smoke Test Server :: Reply Sent >"<close();
52 | reqSocket->close();
53 | qDebug()<<"Smoke Test :: Done";
54 | emit testFinished();
55 | }
56 |
--------------------------------------------------------------------------------
/src/systray/smoketest.h:
--------------------------------------------------------------------------------
1 | #ifndef SMOKETEST_H
2 | #define SMOKETEST_H
3 |
4 | #include
5 | #include
6 |
7 |
8 | class SmokeTest : public QObject
9 | {
10 | Q_OBJECT
11 | typedef QObject super;
12 |
13 | public:
14 | SmokeTest(nzmqt::ZMQContext& context, QString ad, QObject* parent);
15 | void launch();
16 |
17 | signals:
18 | void testFinished();
19 |
20 | private slots:
21 | void receiveReply(const QList& reply);
22 | void receiveRequest(const QList& reply);
23 |
24 | private:
25 | QString address;
26 | QString requestMsg;
27 | QString replyMsg;
28 | void endTest();
29 |
30 | nzmqt::ZMQSocket* reqSocket;
31 | nzmqt::ZMQSocket* repSocket;
32 | };
33 |
34 | #endif // SMOKETEST_H
35 |
--------------------------------------------------------------------------------
/src/systray/systray.pro:
--------------------------------------------------------------------------------
1 | TARGET = pydio-ui
2 |
3 | DESTDIR = $$PWD/../../build
4 | MOC_DIR = $${DESTDIR}/.moc
5 | OBJECTS_DIR = $${DESTDIR}/.obj
6 | RCC_DIR = $${DESTDIR}/.rcc
7 | UI_DIR = $$DESTDIR/.ui
8 |
9 | HEADERS += window.h \
10 | portconfigurer.h \
11 | JSEventHandler.h \
12 | job.h \
13 | httpmanager.h \
14 | jobaction.h \
15 | customtrayicon.h \
16 | jobmenu.h \
17 | cmdhelper.h \
18 | aboutdialog.h \
19 | globals.h \
20 | pydioupdatepinger.h \
21 | updatedialog.h \
22 | localserver.h
23 | SOURCES = main.cpp \
24 | window.cpp \
25 | portconfigurer.cpp \
26 | JSEventHandler.cpp \
27 | job.cpp \
28 | httpmanager.cpp \
29 | jobaction.cpp \
30 | customtrayicon.cpp \
31 | jobmenu.cpp \
32 | aboutdialog.cpp \
33 | cmdhelper.cpp \
34 | pydioupdatepinger.cpp \
35 | updatedialog.cpp \
36 | localserver.cpp
37 |
38 | RESOURCES = systray.qrc
39 |
40 | TRANSLATIONS += languages/pydioUI_fr_FR.ts
41 |
42 | # install
43 | target.path = ./
44 | INSTALLS += target
45 |
46 | QT += widgets \
47 | webkitwidgets \
48 | network
49 |
50 | simulator: warning(This example might not fully work on Simulator platform)
51 |
52 | INCLUDEPATH += \
53 | $(QTDIR)/include \
54 | /usr/local/include
55 |
56 | QMAKE_LIBDIR += \
57 | /usr/local/lib
58 |
59 |
60 | QMAKE_INFO_PLIST = ../../deploy/macos/info.plist
61 |
62 | FORMS +=
63 |
--------------------------------------------------------------------------------
/src/systray/systray.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | webkit-sources/reload_python.html
4 | images/world.png
5 | languages/pydioUI_fr_FR.qm
6 | webkit-sources/about.html
7 | images/PydioSync-Systray-Mac-Transfer.png
8 | images/PydioSync-Systray-Mac.png
9 | images/PydioSync-Systray-Windows-Transfer.png
10 | images/PydioSync-Systray-Mac-Inactive.png
11 | images/folder-32.png
12 | images/PydioSync-Systray-Windows.png
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/systray/updatedialog.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2007-2015 Charles du Jeu - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #include "updatedialog.h"
23 |
24 | UpdateDialog::UpdateDialog(QWidget *parent) :
25 | QDialog(parent)
26 | {
27 | //this->setFixedSize(450, 150);
28 | laterButton = new QPushButton(tr("Download later"), this);
29 | downloadButton = new QPushButton(tr("Download"), this);
30 | label = new QLabel(this);
31 | label->setTextFormat(Qt::RichText);
32 | connect(laterButton, SIGNAL(clicked()), this, SLOT(close()));
33 | connect(downloadButton, SIGNAL(clicked()), this, SLOT(download()));
34 |
35 | layout = new QGridLayout(this);
36 | }
37 |
38 | void UpdateDialog::proposeDownload(QString package, QString version, QString releaseNote, QString md5){
39 | qDebug()<setText("New Pydio available : v"+version);
42 | layout->addWidget(label, 0, 0);
43 | layout->addWidget(laterButton, 1, 0);
44 | layout->addWidget(downloadButton, 1, 1);
45 | this->setLayout(layout);
46 | this->exec();
47 | this->hasFocus();
48 | }
49 |
50 | void UpdateDialog::download(){
51 | QDesktopServices::openUrl(url);
52 | this->close();
53 | }
54 |
--------------------------------------------------------------------------------
/src/systray/updatedialog.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2007-2015 Charles du Jeu - Abstrium SAS
4 | ** This file is part of Pydio.
5 | **
6 | ** Pydio is free software: you can redistribute it and/or modify
7 | ** it under the terms of the GNU General Public License as published by
8 | ** the Free Software Foundation, either version 3 of the License, or
9 | ** (at your option) any later version.
10 | **
11 | ** Pydio is distributed in the hope that it will be useful,
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | ** GNU General Public License for more details.
15 | **
16 | ** You should have received a copy of the GNU General Public License
17 | ** along with Pydio. If not, see .
18 | **
19 | ** The latest code can be found at .
20 | **
21 | ****************************************************************************/
22 | #ifndef UPDATEDIALOG_H
23 | #define UPDATEDIALOG_H
24 |
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 |
35 | class UpdateDialog : public QDialog
36 | {
37 | Q_OBJECT
38 | public:
39 | explicit UpdateDialog(QWidget *parent = 0);
40 |
41 | signals:
42 |
43 | public slots:
44 | void download();
45 | void proposeDownload(QString package, QString version, QString releaseNote, QString md5);
46 |
47 | private:
48 | QNetworkAccessManager *manager;
49 | QGridLayout *layout;
50 | QPushButton *laterButton;
51 | QPushButton *downloadButton;
52 | QLabel *label;
53 |
54 | QString url;
55 |
56 | };
57 |
58 | #endif // UPDATEDIALOG_H
59 |
--------------------------------------------------------------------------------
/src/systray/webkit-sources/about.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
25 |
26 |
31 |
32 |
33 |
34 |
35 |