├── .gitignore ├── CHANGELOG ├── LICENSE ├── README.md ├── deskcon.sh ├── gnome-shell └── deskcon@screenfreeze.net │ ├── extension.js │ ├── icons │ └── sphone-symbolic.svg │ ├── metadata.json │ └── stylesheet.css ├── screenshots ├── deskcon_gnome_extension.png ├── deskcon_indicator.png └── deskcon_settings.png ├── server ├── __init__.py ├── authentication.py ├── bin │ ├── deskcon-server │ └── deskcon-server-settings ├── configmanager.py ├── dbusservice.py ├── deskcon-server ├── filechooser.py ├── filetransfer.py ├── fingerprints.py ├── mediacontrol.py ├── notificationmanager.py ├── pair.py ├── ping.py ├── pyperclip.py ├── settingswindow.py ├── setupdevice.py ├── share │ ├── config.conf │ ├── deskcon-server-settings.desktop.in │ ├── deskcon-server.desktop.in │ └── ui │ │ ├── pairingwindow.glade │ │ ├── settings.glade │ │ └── sms.glade ├── sms.py └── windows.py ├── setup_device.sh └── unity ├── bin └── deskcon-indicator ├── darkindicator-deskcon.svg ├── deskcon-indicator ├── deskcon-indicator.desktop.in └── indicator-deskcon.svg /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[cod] 2 | *~ 3 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | Release 0.3 2 | fixed adding compose button 3 | 4 | Release 0.2.8 5 | changed Filechooser Path 6 | fixed Windows in GS3.12 7 | new Cipher List 8 | GS 3.12 support 9 | 10 | Release 0.2.7 11 | added Signal Handling 12 | added Settings Window 13 | added Pairing Window 14 | changed Connection making, pairing 15 | fixed Fedora Notifications 16 | removed MAC Label 17 | 18 | Release 0.2.5 19 | added Connection Timeout and Wakelock 20 | fixed large Filetransfer 21 | fixed Picasa Images* 22 | added Ping Notification 23 | added File upload to Device 24 | 25 | Release 0.2.1 26 | added Mediaplayer Widget 27 | fixed Powerstate Listener 28 | fixed Startup Issues 29 | 30 | Release 0.2 31 | added multi Filetransfer 32 | added License 33 | Priority 999 StatusUpdateService 34 | added Ping,fixed Wifilock 35 | small improvments 36 | 37 | Release 0.1 38 | first commit 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DeskCon 2 | ------- 3 | Version 0.3 4 | 5 | integrates your Android Device in the Desktop. Receive Notifications, Files 6 | and Commands from your mobile Device on your Desktop PC. The Data is send over a 7 | secure TLS Connection. The Connection is encrypted and authenticated with 8 | self-signed Certificates (RSA-2048 PK). 9 | 10 | Warning: This Project is still in development (beta) and may contain some Bugs or 11 | Security Holes. If you find any, please report them ^^ 12 | 13 | 14 | Information: 15 | ------------ 16 | - Project Website http://www.screenfreeze.net/deskcon 17 | - Source https://github.com/screenfreeze/deskcon-desktop 18 | - Google Play Store https://play.google.com/store/apps/details?id=net.screenfreeze.deskcon 19 | 20 | 21 | Requirements (Desktop Server): 22 | ------------------------------ 23 | - Python >= 2.7 < 3.x 24 | - pyopenssl 25 | - GTK3 26 | 27 | 28 | Install: 29 | -------- 30 | - make sure Ports 8082 and 8083 tcp are open 31 | - start deskcon.sh in Root Folder of the Project 32 | - (optional) copy the Gnome Shell (>=3.8) Extension to ~/.local/share/gnome-shell/extensions 33 | and activate it 34 | - (optional) start unity/deskcon-indicator for a Unity Indicator 35 | 36 | 37 | Usage: 38 | ------ 39 | - start the DeskCon Desktop Server 40 | - (optional) change config File in ~/.deskcon 41 | - To pair with a new Device, start setup_device.sh or use the Gnome Extension or Unity Indicator 42 | - start DeskCon App on your Android Device 43 | - select Network > Desktop Hosts 44 | - click the + Button and enter the IP of your Desktop PC 45 | - check whether the Fingerprints match 46 | 47 | 48 | Todo: 49 | ----- 50 | - Translations 51 | - Mac/Windows support 52 | - Fingerprint validation via QR Code 53 | - Browser Extensions 54 | 55 | 56 | Bugs: 57 | ----- 58 | - UI Design 59 | -------------------------------------------------------------------------------- /deskcon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | BINPATH=`dirname $0` 4 | cd $BINPATH/server/ 5 | ./deskcon-server -------------------------------------------------------------------------------- /gnome-shell/deskcon@screenfreeze.net/extension.js: -------------------------------------------------------------------------------- 1 | const Gio = imports.gi.Gio; 2 | const GLib = imports.gi.GLib; 3 | const Lang = imports.lang; 4 | const Shell = imports.gi.Shell; 5 | const St = imports.gi.St; 6 | 7 | const Main = imports.ui.main; 8 | const PanelMenu = imports.ui.panelMenu; 9 | const PopupMenu = imports.ui.popupMenu; 10 | const Panel = imports.ui.panel; 11 | const Tweener = imports.ui.tweener; 12 | 13 | const iface = ' \ 14 | \ 15 | \ 16 | \ 17 | \ 18 | \ 19 | \ 20 | \ 21 | \ 22 | \ 23 | \ 24 | \ 25 | \ 26 | \ 27 | \ 28 | \ 29 | \ 30 | \ 31 | \ 32 | \ 33 | \ 34 | \ 35 | \ 36 | \ 37 | '; 38 | 39 | 40 | const DBusClient = new Lang.Class({ 41 | Name: 'DBusClient', 42 | _init: function() { 43 | this.ProxyClass = Gio.DBusProxy.makeProxyWrapper(iface); 44 | 45 | this.proxy = new this.ProxyClass(Gio.DBus.session, 46 | 'net.screenfreeze.desktopconnector', 47 | '/net/screenfreeze/desktopconnector', Lang.bind(this, this._onError)); 48 | this.changesig = this.proxy.connectSignal("changed", updatehandler); 49 | this.notificationsig = this.proxy.connectSignal("new_notification", notificationhandler); 50 | }, 51 | _onError: function(obj, error) { 52 | if (error) { 53 | print('error :',error); 54 | } 55 | }, 56 | destroy: function() { 57 | this.proxy.disconnectSignal(this.changesig); 58 | this.proxy.disconnectSignal(this.notificationsig); 59 | }, 60 | getProxy: function() { 61 | return this.proxy; 62 | }, 63 | getStats: function() { 64 | let info = this.proxy.call_sync('stats', null, 0, 1000, null); 65 | let ui = info.get_child_value(0); 66 | let jsonstr = ui.get_string()[0]; 67 | return jsonstr; 68 | }, 69 | getNotification: function() { 70 | let info = this.proxy.call_sync('notification', null, 0, 1000, null); 71 | let ui = info.get_child_value(0); 72 | let jsonstr = ui.get_string()[0]; 73 | return jsonstr; 74 | }, 75 | composesms: function(ip, port) { 76 | host = ip + ":" + port; 77 | let parameters = new GLib.Variant('(s)', [host]); 78 | this.proxy.call_sync('compose_sms', parameters, 0, 1000, null); 79 | }, 80 | pingdevice: function(ip, port) { 81 | host = ip + ":" + port; 82 | let parameters = new GLib.Variant('(s)', [host]); 83 | this.proxy.call_sync('ping_device', parameters, 0, 1000, null); 84 | }, 85 | sendfile: function(ip, port) { 86 | host = ip + ":" + port; 87 | let parameters = new GLib.Variant('(s)', [host]); 88 | this.proxy.call_sync('send_file', parameters, 0, 1000, null); 89 | }, 90 | showsettings: function() { 91 | this.proxy.call_sync('show_settings', null, 0, 1000, null); 92 | }, 93 | setupdevice: function() { 94 | this.proxy.call_sync('setup_device', null, 0, 1000, null); 95 | }, 96 | }); 97 | 98 | function updatehandler() { 99 | let jsonstr = "{}"; 100 | try { 101 | jsonstr = dbusclient.getStats(); 102 | } catch (e) { 103 | jsonstr = "{}"; 104 | } 105 | 106 | let phonesObject = JSON.parse(jsonstr); 107 | 108 | let phonesArray = phonesObject.phones; 109 | 110 | for (var pos in phonesArray) { 111 | let phone = phonesArray[pos]; 112 | 113 | //test if phone is already in Menu 114 | if (regPhones[phone.uuid] == undefined) { 115 | 116 | let deviceItem = new DeviceMenuItem(phone); 117 | regPhones[phone.uuid] = deviceItem; 118 | 119 | _indicator.menu.addMenuItem(deviceItem.infoitem, 0); 120 | _indicator.menu.addMenuItem(deviceItem.notificationsmenuitem, 1); 121 | _indicator.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem(), 2); 122 | 123 | } 124 | else { 125 | regPhones[phone.uuid].update(phone); 126 | } 127 | } 128 | } 129 | 130 | function notificationhandler() { 131 | let not = dbusclient.getNotification().split("::", 2); 132 | let uuid = not[0]; 133 | let text = not[1]; 134 | 135 | if (regPhones[uuid] == undefined) { 136 | 137 | } 138 | else { 139 | regPhones[uuid].addnotification(text); 140 | } 141 | } 142 | 143 | const DeviceMenuItem = new Lang.Class({ 144 | Name: 'DeviceMenuItem', 145 | 146 | _init: function(info) { 147 | this.infoitem = new PopupMenu.PopupSubMenuMenuItem(info.name); 148 | let pingb = new PopupMenu.PopupMenuItem("Ping"); 149 | let sendfileb = new PopupMenu.PopupMenuItem("Send File(s)"); 150 | let composeb = new PopupMenu.PopupMenuItem("Compose Message"); 151 | composeb.connect('activate', Lang.bind(this, this.composemsg)); 152 | pingb.connect('activate', Lang.bind(this, this.ping)); 153 | sendfileb.connect('activate', Lang.bind(this, this.sendfile)); 154 | 155 | this._ip = info.ip; 156 | this._port = info.controlport; 157 | let can_message = info.canmessage; 158 | 159 | if (can_message) { 160 | this.composeb = composeb; 161 | this.infoitem.menu.addMenuItem(this.composeb); 162 | } 163 | this.infoitem.menu.addMenuItem(sendfileb); 164 | this.infoitem.menu.addMenuItem(pingb); 165 | 166 | this.notificationsmenuitem = new PopupMenu.PopupSubMenuMenuItem("Notifications"); 167 | let clearb = new PopupMenu.PopupMenuItem("Clear"); 168 | clearb.connect('activate', Lang.bind(this, this.clearnotifications)); 169 | this.notifcationsArray = new Array(); 170 | this.notificationsmenuitem.menu.addMenuItem(clearb); 171 | this.notificationsmenuitem.actor.hide() 172 | this.update(info) 173 | }, 174 | 175 | composemsg: function(event) { 176 | dbusclient.composesms(this._ip, this._port); 177 | _indicator.menu.close(); 178 | }, 179 | 180 | ping: function(event) { 181 | dbusclient.pingdevice(this._ip, this._port); 182 | _indicator.menu.close(); 183 | }, 184 | 185 | sendfile: function(event) { 186 | dbusclient.sendfile(this._ip, this._port); 187 | _indicator.menu.close(); 188 | }, 189 | 190 | addnotification: function(text) { 191 | let newnot = new PopupMenu.PopupMenuItem(text, {reactive: false}); 192 | this.notifcationsArray.push(newnot); 193 | newnot.connect('clicked', Lang.bind(this, function() { newnot.destroy(); })); 194 | this.notificationsmenuitem.menu.addMenuItem(newnot, 0); 195 | this.notificationsmenuitem.actor.show(); 196 | }, 197 | 198 | clearnotifications: function() { 199 | for (i=0;i 0) { missedmsgsstr = "unread Messages "+ info.missedsmscount; } 225 | if (info.missedcallcount > 0) { missedcallsstr = "missed Calls "+ info.missedcallcount; } 226 | 227 | let newtxt = (name+"\n"+batterystr+" / "+volumestr+" / "+storagestr); 228 | 229 | if (missedmsgsstr != "") { 230 | newtxt = newtxt+"\n"+missedmsgsstr 231 | } 232 | if (missedcallsstr != "") { 233 | newtxt = newtxt+"\n"+missedcallsstr 234 | } 235 | 236 | this.infoitem.label.set_text(newtxt); 237 | 238 | let can_message = info.canmessage; 239 | 240 | if (can_message && typeof this.composeb === 'undefined') { 241 | this.composeb = new PopupMenu.PopupMenuItem("Compose Message"); 242 | this.composeb.connect('activate', Lang.bind(this, this.composemsg)); 243 | this.infoitem.menu.addMenuItem(this.composeb); 244 | } 245 | }, 246 | }); 247 | 248 | const PhonesMenu = new Lang.Class({ 249 | Name: 'PhonesMenu.PhoneMenu', 250 | Extends: PanelMenu.Button, 251 | 252 | _init: function() { 253 | this.parent(0.0, 'PhoneMenu'); 254 | let hbox = new St.BoxLayout({ style_class: 'panel-status-menu-box' }); 255 | let icon = new St.Icon({ icon_name: 'sphone-symbolic', 256 | style_class: 'system-status-icon' }); 257 | 258 | hbox.add_child(icon); 259 | this.actor.add_child(hbox); 260 | 261 | let settingsbutton = new PopupMenu.PopupMenuItem("Settings"); 262 | let setupdevicebutton = new PopupMenu.PopupMenuItem("Setup new Device"); 263 | 264 | settingsbutton.connect('activate', Lang.bind(this, this.show_settings)); 265 | setupdevicebutton.connect('activate', Lang.bind(this, this.setup_device)); 266 | this.menu.addMenuItem(setupdevicebutton); 267 | this.menu.addMenuItem(settingsbutton); 268 | 269 | this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); 270 | }, 271 | 272 | show: function() { 273 | this.actor.show(); 274 | updatehandler(); 275 | }, 276 | 277 | destroy: function() { 278 | this.parent(); 279 | }, 280 | 281 | show_settings: function() { 282 | dbusclient.showsettings(); 283 | }, 284 | 285 | setup_device: function() { 286 | dbusclient.setupdevice(); 287 | }, 288 | 289 | }); 290 | 291 | // GS 3.8 292 | const PhonesMenuOld = new Lang.Class({ 293 | Name: 'PhonesMenu.PhoneMenu', 294 | Extends: PanelMenu.SystemStatusButton, 295 | 296 | _init: function() { 297 | this.parent('sphone-symbolic'); 298 | }, 299 | 300 | show: function() { 301 | this.actor.show(); 302 | updatehandler(); 303 | }, 304 | 305 | destroy: function() { 306 | this.parent(); 307 | }, 308 | 309 | }); 310 | 311 | 312 | function init(extensionMeta) { 313 | let theme = imports.gi.Gtk.IconTheme.get_default(); 314 | theme.append_search_path(extensionMeta.path + "/icons"); 315 | } 316 | 317 | let _indicator; 318 | let regPhones = {}; 319 | let dbusclient; 320 | let shellversion; 321 | 322 | function enable() { 323 | dbusclient = new DBusClient(); 324 | shellversion = imports.misc.config.PACKAGE_VERSION.split(".").map(function (x) { return +x; }) 325 | 326 | // GS 3.8 support 327 | if (shellversion[1] >= 10) { 328 | _indicator = new PhonesMenu; 329 | } 330 | else { 331 | _indicator = new PhonesMenuOld; 332 | } 333 | 334 | Main.panel.addToStatusArea('phonesMenu', _indicator, 1); 335 | 336 | updatehandler(); 337 | } 338 | 339 | function disable() { 340 | dbusclient.destroy(); 341 | _indicator.destroy(); 342 | regPhones = {}; 343 | } 344 | 345 | -------------------------------------------------------------------------------- /gnome-shell/deskcon@screenfreeze.net/icons/sphone-symbolic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xml -------------------------------------------------------------------------------- /gnome-shell/deskcon@screenfreeze.net/metadata.json: -------------------------------------------------------------------------------- 1 | {"shell-version": ["3.8", "3.10", "3.12"], "uuid": "deskcon@screenfreeze.net", "name": "DeskCon", "description": "Get Notifications in Gnome Shell from your Smartphone."} 2 | -------------------------------------------------------------------------------- /gnome-shell/deskcon@screenfreeze.net/stylesheet.css: -------------------------------------------------------------------------------- 1 | 2 | .phonesMenu { 3 | width: 20px; 4 | font-size: 36px; 5 | font-weight: bold; 6 | color: #ffffff; 7 | background-color: rgba(10,10,10,0.7); 8 | border-radius: 5px; 9 | padding: .5em; 10 | } 11 | 12 | .device-label { 13 | font-weight: bold; 14 | font-size: 16px; 15 | 16 | min-width: 220px; 17 | } 18 | 19 | .notifications-label { 20 | font-weight: bold; 21 | padding-top: .2em; 22 | } 23 | 24 | .notifications-box { 25 | padding-bottom: .8em; 26 | spacing: 0.2em; 27 | max-width: 220px; 28 | } 29 | -------------------------------------------------------------------------------- /screenshots/deskcon_gnome_extension.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/screenfreeze/deskcon-desktop/267804122188fa79c37f2b21f54fe05c898610e6/screenshots/deskcon_gnome_extension.png -------------------------------------------------------------------------------- /screenshots/deskcon_indicator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/screenfreeze/deskcon-desktop/267804122188fa79c37f2b21f54fe05c898610e6/screenshots/deskcon_indicator.png -------------------------------------------------------------------------------- /screenshots/deskcon_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/screenfreeze/deskcon-desktop/267804122188fa79c37f2b21f54fe05c898610e6/screenshots/deskcon_settings.png -------------------------------------------------------------------------------- /server/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/screenfreeze/deskcon-desktop/267804122188fa79c37f2b21f54fe05c898610e6/server/__init__.py -------------------------------------------------------------------------------- /server/authentication.py: -------------------------------------------------------------------------------- 1 | import random 2 | from OpenSSL import SSL, crypto 3 | import socket 4 | import ssl 5 | import configmanager 6 | import hashlib 7 | import subprocess 8 | import os 9 | 10 | PROGRAMDIR = os.getcwd() 11 | 12 | def generate_keypair(uuid): 13 | hostname = socket.gethostname() 14 | # create a key pair 15 | keypair = crypto.PKey() 16 | keypair.generate_key(crypto.TYPE_RSA, 2048) 17 | 18 | # create a self-signed cert 19 | cert = crypto.X509() 20 | cert.set_version(2) 21 | cert.get_subject().CN = str(uuid)+"/"+hostname 22 | cert.get_issuer().CN = str(uuid)+"/"+hostname 23 | cert.set_serial_number(1000) 24 | cert.gmtime_adj_notBefore(0) 25 | cert.gmtime_adj_notAfter(10*365*24*60*60) 26 | cert.set_pubkey(keypair) 27 | cert.sign(keypair, 'sha256') 28 | 29 | certificate = crypto.dump_certificate(crypto.FILETYPE_PEM, cert) 30 | privatekey = crypto.dump_privatekey(crypto.FILETYPE_PEM, keypair) 31 | return certificate, privatekey 32 | 33 | 34 | 35 | def pair(clientsocket): 36 | print "wants to pair" 37 | mycert = open(os.path.join(configmanager.keydir, "server.crt"), "r").read() 38 | secure_port = str(configmanager.secure_port) 39 | 40 | myder_cert = ssl.PEM_cert_to_DER_cert(mycert) 41 | m = hashlib.sha256(myder_cert) 42 | myfp = m.hexdigest().upper() 43 | myfp = " ".join(myfp[i:i+4] for i in range(0, len(myfp), 4)) 44 | print "\nMy SHA256: "+myfp 45 | #send my certiuficate 46 | clientsocket.sendall(myder_cert.encode('base64')) 47 | 48 | #receive client Certificate 49 | clientcert = clientsocket.recv(2048) 50 | 51 | m = hashlib.sha256(clientcert) 52 | devicefp = m.hexdigest().upper() 53 | devicefp = " ".join(devicefp[i:i+4] for i in range(0, len(devicefp), 4)) 54 | print "\nClient SHA256: "+devicefp 55 | 56 | fpdiag = subprocess.Popen([PROGRAMDIR+"/fingerprints.py", myfp, devicefp], stdout=subprocess.PIPE) 57 | (vout, verr) = fpdiag.communicate() 58 | 59 | if (vout.strip()=="True"): 60 | clientsocket.sendall(secure_port+"\n") 61 | else: 62 | clientsocket.sendall("0\n"); 63 | pass 64 | 65 | ack = clientsocket.recv(2) 66 | if (ack=="OK"): 67 | #save pub key 68 | with open(os.path.join(configmanager.keydir, "cas.pem"), 'a') as the_file: 69 | the_file.write(ssl.DER_cert_to_PEM_cert(clientcert)) 70 | print "Successfully paired the Device!" 71 | 72 | else: 73 | print "Failed to pair Device." 74 | 75 | 76 | -------------------------------------------------------------------------------- /server/bin/deskcon-server: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd /usr/share/deskcon-server/ 4 | ./deskcon-server & 5 | -------------------------------------------------------------------------------- /server/bin/deskcon-server-settings: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd /usr/share/deskcon-server/ 4 | python2 "settingswindow.py" $@ 5 | -------------------------------------------------------------------------------- /server/configmanager.py: -------------------------------------------------------------------------------- 1 | import os 2 | import ConfigParser 3 | import time 4 | import shutil 5 | import authentication 6 | import random 7 | 8 | homedir = os.path.expanduser('~') 9 | default_configfile = os.getcwd()+"/share/config.conf" 10 | 11 | config = ConfigParser.ConfigParser() 12 | configdir = homedir + "/.deskcon/" 13 | configfile = configdir + "config.conf" 14 | pidfile = configdir + "server.pid" 15 | keydir = os.path.join(configdir, "keys") 16 | privatekeypath = os.path.join(keydir, "private.key") 17 | certificatepath = os.path.join(keydir, "server.crt") 18 | cafilepath = os.path.join(keydir, "cas.pem") 19 | 20 | def copy_default_config(): 21 | if os.path.isdir(configdir): 22 | shutil.copyfile(default_configfile, configfile) 23 | else: 24 | os.mkdir(configdir) 25 | os.mkdir(keydir) 26 | shutil.copyfile(default_configfile, configfile) 27 | 28 | def gen_and_store_keys(uuid): 29 | certificate, privatekey = authentication.generate_keypair(uuid) 30 | with open(privatekeypath, 'w') as the_file: 31 | the_file.write(privatekey) 32 | with open(certificatepath, 'w') as the_file: 33 | the_file.write(certificate) 34 | with open(cafilepath, 'w') as the_file: 35 | the_file.write("") 36 | 37 | # if no config file present, setup config files 38 | if os.path.isfile(configfile): 39 | config.read(configfile) 40 | privatekey = open(privatekeypath, "r").read() 41 | certificate = open(certificatepath, "r").read() 42 | else: 43 | print "created new config file" 44 | copy_default_config() 45 | config.read(configfile) 46 | #gen uuid 47 | uuid = random.randint(100000000000000L, 999999999999999L) 48 | #set Path to Download Folder 49 | default_download_dir = os.path.join(homedir, "Downloads") 50 | cfgfile = open(configfile, 'w') 51 | config.set('general','uuid', uuid) 52 | config.set('general','download_dir', default_download_dir) 53 | config.write(cfgfile) 54 | cfgfile.close() 55 | #generate Keys and store in keydir 56 | gen_and_store_keys(uuid) 57 | config.read(configfile) 58 | 59 | def load(): 60 | global port, secure_port, bindip, uuid, downloaddir, auto_store_clipboard 61 | global auto_open_urls, auto_accept_files 62 | if os.path.isfile(configfile): 63 | config.read(configfile) 64 | port = config.get('network', 'port') 65 | secure_port = config.get('network', 'secure_port') 66 | bindip = config.get('network', 'bindip') 67 | uuid = config.getint('general', 'uuid') 68 | downloaddir = os.path.join(config.get('general', 'download_dir')) 69 | auto_accept_files = config.getboolean('permissions', 'auto_accept_files') 70 | auto_open_urls = config.getboolean('permissions', 'auto_open_urls') 71 | auto_store_clipboard = config.getboolean('permissions', 'auto_store_clipboard') 72 | 73 | def get_port(): 74 | return port 75 | 76 | def get_bindip(): 77 | return bindip 78 | 79 | def get_download_dir(): 80 | return downloaddir+"/" 81 | 82 | def write_config(datadict): 83 | if (not config): 84 | copy_default_config() 85 | 86 | cfgfile = open(configfile, 'w') 87 | config.set('general','download_dir', datadict['downloaddir']) 88 | config.set('general','debug', datadict['debug']) 89 | config.set('network','bindip', datadict['bindip']) 90 | config.set('network','port', datadict['port']) 91 | config.set('network','secure_port', datadict['secure_port']) 92 | config.set('permissions','auto_open_urls', datadict['auto_open_urls']) 93 | config.set('permissions','auto_store_clipboard', datadict['auto_store_clipboard']) 94 | config.set('permissions','auto_accept_files', datadict['auto_accept_files']) 95 | config.write(cfgfile) 96 | cfgfile.close() 97 | 98 | #store server Process ID 99 | def write_pidfile(pid): 100 | pfile = open(pidfile, 'w') 101 | pfile.write(pid) 102 | pfile.close() 103 | 104 | load() -------------------------------------------------------------------------------- /server/dbusservice.py: -------------------------------------------------------------------------------- 1 | import dbus 2 | import dbus.service 3 | import threading 4 | from gi.repository import GObject, Gtk 5 | from dbus.mainloop.glib import DBusGMainLoop 6 | 7 | dbusname = 'net.screenfreeze.desktopconnector' 8 | 9 | class DbusThread(threading.Thread): 10 | def __init__(self, connector_object): 11 | threading.Thread.__init__(self) 12 | self.connector = connector_object 13 | 14 | def run(self): 15 | DBusGMainLoop(set_as_default=True) 16 | GObject.threads_init() 17 | dbus.mainloop.glib.threads_init() 18 | self.dbusservice = self.DbusService(self.connector) 19 | Gtk.main() 20 | 21 | def emit_changed_signal(self): 22 | self.dbusservice.changed() 23 | 24 | def emit_new_notification_signal(self): 25 | self.dbusservice.new_notification() 26 | 27 | # Defining the Dbus interface 28 | class DbusService(dbus.service.Object): 29 | def __init__(self, connector_object): 30 | self.connector = connector_object 31 | bus_name = dbus.service.BusName(dbusname, bus=dbus.SessionBus()) 32 | dbus.service.Object.__init__(self, bus_name, '/net/screenfreeze/desktopconnector') 33 | 34 | @dbus.service.method(dbusname, out_signature='s') 35 | def stats(self): 36 | return self.connector.get_mid_info() 37 | 38 | @dbus.service.method(dbusname, out_signature='s') 39 | def notification(self): 40 | return self.connector.get_last_notification() 41 | 42 | @dbus.service.method(dbusname, in_signature='s') 43 | def compose_sms(self, host): 44 | ip = host.split(":")[0] 45 | port = host.split(":")[1] 46 | self.connector.compose_sms("", ip, port) 47 | 48 | @dbus.service.method(dbusname, in_signature='s') 49 | def ping_device(self, host): 50 | ip = host.split(":")[0] 51 | port = host.split(":")[1] 52 | self.connector.ping_device(ip, port) 53 | 54 | @dbus.service.method(dbusname, in_signature='s') 55 | def send_file(self, host): 56 | ip = host.split(":")[0] 57 | port = host.split(":")[1] 58 | self.connector.send_file(ip, port) 59 | 60 | @dbus.service.method(dbusname) 61 | def show_settings(self): 62 | self.connector.show_settings() 63 | 64 | @dbus.service.method(dbusname) 65 | def setup_device(self): 66 | self.connector.setup_device() 67 | 68 | @dbus.service.signal(dbusname) 69 | def changed(self): 70 | pass 71 | 72 | @dbus.service.signal(dbusname) 73 | def new_notification(self): 74 | pass 75 | -------------------------------------------------------------------------------- /server/deskcon-server: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | # DesCon Desktop Server 3 | # Version 0.2 4 | 5 | import socket 6 | import SocketServer 7 | import webbrowser 8 | import signal 9 | import subprocess 10 | import platform 11 | import json 12 | import time 13 | import sms 14 | import os 15 | import notificationmanager 16 | import filetransfer 17 | import authentication 18 | import threading 19 | import thread 20 | import configmanager 21 | import mediacontrol 22 | from gi.repository import Gio, GLib, Gtk, GObject, Gdk 23 | from OpenSSL import SSL, crypto 24 | from dbusservice import DbusThread 25 | 26 | configmanager.write_pidfile(str(os.getpid())) 27 | abspath = os.path.abspath(__file__) 28 | 29 | HOST = configmanager.get_bindip() 30 | SECUREPORT = int(configmanager.secure_port) 31 | PROGRAMDIR = os.path.dirname(abspath) 32 | BUFFERSIZE = 4096 33 | 34 | AUTO_ACCEPT_FILES = configmanager.auto_accept_files 35 | AUTO_OPEN_URLS = configmanager.auto_open_urls 36 | AUTO_STORE_CLIPBOARD = configmanager.auto_store_clipboard 37 | 38 | def reload_config(): 39 | global HOST, SECUREPORT, AUTO_STORE_CLIPBOARD, AUTO_ACCEPT_FILES, AUTO_OPEN_URLS 40 | configmanager.load() 41 | HOST = configmanager.get_bindip() 42 | SECUREPORT = int(configmanager.secure_port) 43 | AUTO_ACCEPT_FILES = configmanager.auto_accept_files 44 | AUTO_OPEN_URLS = configmanager.auto_open_urls 45 | AUTO_STORE_CLIPBOARD = configmanager.auto_store_clipboard 46 | 47 | class Connector(): 48 | def __init__(self): 49 | signal.signal(signal.SIGINT, self.signal_handler) 50 | signal.signal(signal.SIGUSR1, self.signal_handler) 51 | self.uuid_list = {} 52 | self.mid_info = {'phones': [], 'settings': {}} 53 | self.last_notification = ""; 54 | 55 | self.dbus_service_thread = DbusThread(self) 56 | self.dbus_service_thread.daemon = True 57 | 58 | self.sslserver = sslserver(self) 59 | self.sslserver.daemon = True 60 | 61 | def run(self): 62 | GObject.threads_init() 63 | self.dbus_service_thread.start() 64 | self.sslserver.start() 65 | print "Server started" 66 | signal.pause() 67 | 68 | def signal_handler(self, signum, frame): 69 | if (signum == 10): 70 | print "restart Server" 71 | self.sslserver.stop() 72 | self.sslserver.join() 73 | # reload settings 74 | reload_config() 75 | # create new Thread 76 | self.sslserver = sslserver(self) 77 | self.sslserver.daemon = True 78 | self.sslserver.start() 79 | print "Server started" 80 | signal.pause() 81 | else: 82 | print "shuting down Server" 83 | self.sslserver.stop() 84 | self.sslserver.join() 85 | 86 | def get_mid_info(self): 87 | return json.dumps(self.mid_info) 88 | 89 | def get_last_notification(self): 90 | return self.last_notification 91 | 92 | def parseData(self, data, address, csocket): 93 | jsondata = json.loads(data) 94 | uuid = jsondata['uuid'] 95 | name = jsondata['devicename'] 96 | msgtype = jsondata['type'] 97 | message = jsondata['data'] 98 | 99 | print "UUID ",uuid 100 | print "NAME ",name 101 | print "TYPE ",msgtype 102 | print "MSG ",message 103 | 104 | if uuid not in self.uuid_list: 105 | self.mid_info['phones'].append({'uuid': uuid, 'name': name, 106 | 'battery': -1, 'volume': -1, 107 | 'batterystate': False, 'missedsmscount': 0, 108 | 'missedcallcount': 0, 'ip': address, 109 | 'canmessage': False, 'controlport': 9096, 110 | 'storage': -1}) 111 | 112 | apos = 0 113 | for x in range(0, len(self.mid_info['phones'])): 114 | if self.mid_info['phones'][x]['uuid'] == uuid: 115 | apos = x 116 | 117 | self.uuid_list[uuid] = apos 118 | print "created "+uuid+" at pos "+str(apos) 119 | 120 | pos = self.uuid_list[uuid] 121 | 122 | if (msgtype == "STATS"): 123 | newstats = json.loads(message) 124 | if (newstats.has_key('volume')): 125 | self.mid_info['phones'][pos]['volume'] = newstats['volume'] 126 | if (newstats.has_key('controlport')): 127 | self.mid_info['phones'][pos]['controlport'] = newstats['controlport'] 128 | if (newstats.has_key('battery')): 129 | self.mid_info['phones'][pos]['battery'] = newstats['battery'] 130 | self.mid_info['phones'][pos]['batterystate'] = newstats['batterystate'] 131 | if (newstats.has_key('missedmsgs')): 132 | self.mid_info['phones'][pos]['missedsmscount'] = newstats['missedmsgs'] 133 | if (newstats.has_key('missedcalls')): 134 | self.mid_info['phones'][pos]['missedcallcount'] = newstats['missedcalls'] 135 | if (newstats.has_key('canmessage')): 136 | self.mid_info['phones'][pos]['canmessage'] = newstats['canmessage'] 137 | if (newstats.has_key('storage')): 138 | self.mid_info['phones'][pos]['storage'] = newstats['storage'] 139 | self.mid_info['phones'][pos]['ip'] = address 140 | 141 | elif (msgtype == "SMS"): 142 | smsobj = json.loads(message) 143 | name = smsobj['name'] 144 | number = smsobj['number'] 145 | smsmess = smsobj['message'] 146 | notificationmanager.buildSMSReceivedNotification(name, number, smsmess, address, self.mid_info['phones'][pos]['controlport'], self.compose_sms) 147 | 148 | elif (msgtype == "CALL"): 149 | notificationmanager.buildTransientNotification(name, "incoming Call from "+message) 150 | 151 | elif (msgtype == "URL"): 152 | if (AUTO_OPEN_URLS): 153 | webbrowser.open(message, 0 ,True) 154 | else: 155 | notificationmanager.buildNotification("URL", "Link: "+message) 156 | 157 | elif (msgtype == "CLPBRD"): 158 | clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) 159 | clipboard.set_text(message, -1) 160 | notificationmanager.buildTransientNotification("Clipboard", message) 161 | 162 | elif (msgtype == "MIS_CALL"): 163 | notificationmanager.buildNotification(name, "missed Call from "+message) 164 | 165 | elif (msgtype == "PING"): 166 | notificationmanager.buildTransientNotification("Ping from "+name, 167 | "Name: "+name+ 168 | "\nUUID: "+uuid+ 169 | "\nIP: "+address) 170 | 171 | elif (msgtype == "OTH_NOT"): 172 | msginfo = message.split(': ', 1) 173 | new_notification = uuid+"::"+message 174 | if (self.last_notification != new_notification): 175 | self.last_notification = new_notification 176 | self.dbus_service_thread.emit_new_notification_signal() 177 | if (len(msginfo) > 1): 178 | sender = msginfo[0] 179 | notification = msginfo[1] 180 | notificationmanager.buildTransientNotification(sender, notification) 181 | else: 182 | notificationmanager.buildTransientNotification(name, message) 183 | 184 | elif (msgtype == "FILE_UP"): 185 | filenames = json.loads(message) 186 | if (AUTO_ACCEPT_FILES): 187 | print "accepted" 188 | filetransfer.write_files(filenames, csocket) 189 | else: 190 | accepted = notificationmanager.buildIncomingFileNotification(filenames, name) 191 | print "wait for ui" 192 | if (accepted): 193 | print "accepted" 194 | fpaths = filetransfer.write_files(filenames, csocket) 195 | notificationmanager.buildFileReceivedNotification(fpaths, self.open_file) 196 | else: 197 | print "not accepted" 198 | 199 | elif (msgtype == "MEDIACTRL"): 200 | thread.start_new_thread(mediacontrol.control, (message,)) 201 | 202 | else: 203 | print "ERROR: Non parsable Data received" 204 | 205 | #print json.dumps(self.mid_info) 206 | 207 | 208 | def compose_sms(self, number, ip, port): 209 | subprocess.Popen([PROGRAMDIR+"/sms.py", ip, port, number], stdin=subprocess.PIPE, 210 | stdout=subprocess.PIPE, stderr=subprocess.PIPE) 211 | 212 | def ping_device(self, ip, port): 213 | subprocess.Popen([PROGRAMDIR+"/ping.py", ip, port], stdin=subprocess.PIPE, 214 | stdout=subprocess.PIPE, stderr=subprocess.PIPE) 215 | 216 | def send_file(self, ip, port): 217 | subprocess.Popen([PROGRAMDIR+"/filechooser.py", ip, port], stdin=subprocess.PIPE, 218 | stdout=subprocess.PIPE, stderr=subprocess.PIPE) 219 | 220 | def open_file(self, path): 221 | if (path == ""): 222 | path = configmanager.downloaddir 223 | if platform.system() == "Windows": 224 | os.startfile(path) 225 | elif platform.system() == "Darwin": 226 | subprocess.Popen(["open", path], stdin=subprocess.PIPE, 227 | stdout=subprocess.PIPE, stderr=subprocess.PIPE) 228 | else: 229 | subprocess.Popen(["xdg-open", path], stdin=subprocess.PIPE, 230 | stdout=subprocess.PIPE, stderr=subprocess.PIPE) 231 | 232 | def show_settings(self): 233 | subprocess.Popen([PROGRAMDIR+"/settingswindow.py"], stdin=subprocess.PIPE, 234 | stdout=subprocess.PIPE, stderr=subprocess.PIPE) 235 | 236 | def setup_device(self): 237 | subprocess.Popen([PROGRAMDIR+"/setupdevice.py"], stdin=subprocess.PIPE, 238 | stdout=subprocess.PIPE, stderr=subprocess.PIPE) 239 | 240 | 241 | 242 | class sslserver(threading.Thread): 243 | 244 | def __init__(self, conn): 245 | threading.Thread.__init__(self) 246 | self.running = True 247 | self.conn = conn 248 | 249 | def run(self): 250 | # Initialize context 251 | try: 252 | ctx = SSL.Context(SSL.SSLv23_METHOD) 253 | ctx.set_options(SSL.OP_NO_SSLv2|SSL.OP_NO_SSLv3) #TLS1 and up 254 | ctx.set_verify(SSL.VERIFY_PEER|SSL.VERIFY_FAIL_IF_NO_PEER_CERT, verify_cb) #Demand a certificate 255 | ctx.set_cipher_list('HIGH:!SSLv2:!aNULL:!eNULL:!3DES:@STRENGTH') 256 | ctx.use_privatekey_file(configmanager.privatekeypath) 257 | ctx.use_certificate_file(configmanager.certificatepath) 258 | ctx.load_verify_locations(configmanager.cafilepath) 259 | except Exception as e: 260 | error = e[0] 261 | if (len(error)>0): # ignore empty cafile error 262 | print error 263 | self.sslserversocket = SSL.Connection(ctx, socket.socket(socket.AF_INET, 264 | socket.SOCK_STREAM)) 265 | 266 | self.sslserversocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 267 | self.sslserversocket.bind(('', SECUREPORT)) 268 | self.sslserversocket.listen(5) 269 | while self.running: 270 | sslcsocket = None 271 | try: 272 | sslcsocket, ssladdress = self.sslserversocket.accept() 273 | address = format(ssladdress[0]) 274 | print "SSL connected" 275 | # receive data 276 | data = sslcsocket.recv(4096) 277 | self.conn.parseData(data, address, sslcsocket) 278 | # emit new data dbus Signal 279 | self.conn.dbus_service_thread.emit_changed_signal() 280 | except Exception as e: 281 | errnum = e[0] 282 | if (errnum != 22): 283 | print "Error " + str(e[0]) 284 | finally: 285 | # close connection 286 | if sslcsocket: 287 | sslcsocket.shutdown() 288 | sslcsocket.close() 289 | 290 | print "Server stopped" 291 | 292 | def stop(self): 293 | self.running = False 294 | self.sslserversocket.sock_shutdown(0) 295 | self.sslserversocket.close() 296 | 297 | 298 | def verify_cb(conn, cert, errnum, depth, ok): 299 | # This obviously has to be updated 300 | #print "er"+str(errnum) 301 | #print "de"+str(depth) 302 | #print "ok "+str(ok) 303 | return ok 304 | 305 | 306 | def main(): 307 | os.chdir(PROGRAMDIR) 308 | app = Connector() 309 | app.run() 310 | 311 | if __name__ == '__main__': 312 | try: 313 | main() 314 | except KeyboardInterrupt: 315 | print "\nServer stopped" 316 | pass -------------------------------------------------------------------------------- /server/filechooser.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | import os 3 | import sys 4 | import socket 5 | import configmanager 6 | import threading 7 | import json 8 | from OpenSSL import SSL, crypto 9 | from gi.repository import Gtk, GObject 10 | 11 | sent_size = 0 12 | total_size = 0 13 | 14 | class FileChooserWindow(Gtk.Window): 15 | 16 | def __init__(self): 17 | Gtk.Window.__init__(self) 18 | self.dialog = Gtk.FileChooserDialog("Please choose a file", self, 19 | Gtk.FileChooserAction.OPEN, 20 | (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, 21 | Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) 22 | 23 | homefolder = os.path.expanduser("~") 24 | self.dialog.set_select_multiple(True) 25 | self.dialog.set_current_folder(homefolder) 26 | 27 | def run(self, ip, port): 28 | response = self.dialog.run() 29 | if response == Gtk.ResponseType.OK: 30 | files = self.dialog.get_filenames() 31 | pd = ProgressbarDialog(self.dialog) 32 | t = threading.Thread(target=pd.run, args = ()) 33 | t.daemon = True 34 | t.start() 35 | 36 | send_data(self.dialog, files, ip, port, pd) 37 | elif response == Gtk.ResponseType.CANCEL: 38 | self.dialog.destroy() 39 | 40 | 41 | class ProgressbarDialog(Gtk.Dialog): 42 | 43 | def __init__(self, parent): 44 | Gtk.Dialog.__init__(self, "Filetransfer", parent, 0) 45 | 46 | self.set_default_size(150, 50) 47 | self.set_position(Gtk.WindowPosition.CENTER) 48 | self.set_transient_for(parent) 49 | 50 | label = Gtk.Label("Transfering Files ...") 51 | self.progressbar = Gtk.ProgressBar() 52 | 53 | box = self.get_content_area() 54 | box.add(label) 55 | box.add(self.progressbar) 56 | self.show_all() 57 | 58 | def send_data(dialog, files, ip, port, pd): 59 | HOST, PORT = ip, int(port) 60 | uuid = configmanager.uuid 61 | hostname = socket.gethostname() 62 | 63 | filenames = [] 64 | for filepath in files: 65 | head, name = os.path.split(filepath) 66 | filenames.append(name) 67 | 68 | jsonobj = {'uuid': uuid, 'name': hostname, 69 | 'type': "fileup", 'data': json.dumps(filenames)} 70 | 71 | data = json.dumps(jsonobj) 72 | 73 | # Initialize context 74 | ctx = SSL.Context(SSL.TLSv1_METHOD) 75 | ctx.set_options(SSL.OP_NO_SSLv2|SSL.OP_NO_SSLv3) #TLS1 and up 76 | ctx.set_verify(SSL.VERIFY_PEER, verify_cb) #Demand a certificate 77 | ctx.use_privatekey_file(configmanager.privatekeypath) 78 | ctx.use_certificate_file(configmanager.certificatepath) 79 | ctx.load_verify_locations(configmanager.cafilepath) 80 | sslclientsocket = SSL.Connection(ctx, socket.socket(socket.AF_INET, socket.SOCK_STREAM)) 81 | 82 | succ = False 83 | try: 84 | sslclientsocket.connect((HOST, PORT)) 85 | sslclientsocket.sendall(data) 86 | print "wait for ack" 87 | response = sslclientsocket.recv(2) #wait for Ack 88 | if (response == "OK"): 89 | # Get total transfer size 90 | global total_size 91 | for filepath in files: #send files 92 | total_size = total_size + os.path.getsize(filepath) 93 | 94 | print "send files" 95 | for filepath in files: #send files 96 | send_file(filepath, sslclientsocket, pd) 97 | print "succesfully send Files" 98 | 99 | succ = True 100 | 101 | except Exception as e: 102 | print "Error " + str(e) 103 | 104 | finally: 105 | if (succ): 106 | sslclientsocket.shutdown() 107 | sslclientsocket.close() 108 | dialog.destroy() 109 | 110 | def send_file(filepath, socket, pd): 111 | filesize = os.path.getsize(filepath) 112 | 113 | socket.send(str(filesize)+"\n") 114 | socket.recv(1) #wait for ready 115 | 116 | ofile = open(filepath, 'rb') 117 | fbuffer = ofile.read(4096) 118 | sent_size = 0 119 | while (fbuffer): 120 | socket.send(fbuffer) 121 | fbuffer = ofile.read(4096) 122 | update_progress(pd) 123 | 124 | ofile.close() 125 | 126 | def update_progress(pd): 127 | global sent_size 128 | sent_size = sent_size+4096 129 | perc = (sent_size/float(total_size)) 130 | pd.progressbar.set_fraction(perc) 131 | 132 | def verify_cb(conn, cert, errnum, depth, ok): 133 | # This obviously has to be updated 134 | #print "er"+str(errnum) 135 | #print "de"+str(depth) 136 | #print "ok "+str(ok) 137 | return ok 138 | 139 | def main(args): 140 | GObject.threads_init() 141 | ip = args[1] 142 | port = args[2] 143 | win = FileChooserWindow() 144 | win.run(ip, port) 145 | 146 | if __name__ == '__main__': 147 | if(len(sys.argv) < 3): 148 | print "not enough arguments given" 149 | else: 150 | main(sys.argv) 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | -------------------------------------------------------------------------------- /server/filetransfer.py: -------------------------------------------------------------------------------- 1 | import socket 2 | from OpenSSL import SSL, crypto 3 | import notificationmanager 4 | import configmanager 5 | 6 | DOWNLOAD_DIR = configmanager.get_download_dir() 7 | 8 | def write_files(filenames, csocket): 9 | print "write files" 10 | csocket.sendall('1') # accept send 11 | 12 | filepaths = [] 13 | for filename in filenames: 14 | filepath = write_file(filename, csocket) 15 | filepaths.append(filepath) 16 | 17 | return filepaths 18 | 19 | 20 | def write_file(filename, csocket): 21 | recsocket = csocket 22 | filepath = DOWNLOAD_DIR + filename 23 | 24 | nfile = open(filepath, 'wb') 25 | filesize = int(recsocket.recv(4096)) 26 | loopcnt = filesize/4096 27 | if filesize%4096 != 0: 28 | loopcnt = loopcnt+1 29 | 30 | recsocket.sendall('1') # send ready 31 | for i in range(0, loopcnt): 32 | data_chunk = recsocket.recv(4096) 33 | nfile.write(data_chunk) 34 | nfile.close() 35 | 36 | return filepath -------------------------------------------------------------------------------- /server/fingerprints.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys 4 | import configmanager 5 | from gi.repository import Gio, GLib, Gtk, GObject, Gdk 6 | 7 | 8 | class PairingWindow(Gtk.Window): 9 | def __init__(self, myfp, devicefp): 10 | Gtk.Window.__init__(self, title="Pairing") 11 | self.set_wmclass ("DeskCon", "Pairing") 12 | self.set_resizable(False) 13 | self.set_size_request(300, 300) 14 | self.set_icon_name("phone") 15 | self.accepted = False 16 | 17 | vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6) 18 | self.add(vbox) 19 | 20 | infolabel = Gtk.Label("A Device want to pair with your Desktop, please check "+ 21 | "\nwhether these Fingerprints are the same as"+ 22 | "\nthe ones displayed on your mobile Device") 23 | info2label = Gtk.Label("This Desktops Fingerprint:") 24 | myfplabel = Gtk.Label() 25 | myfplabel.set_line_wrap(True) 26 | myfplabel.set_max_width_chars(10) 27 | myfplabel.set_markup(''+myfp+'') 28 | info3label = Gtk.Label("Mobile Device Fingerprint:") 29 | devicefplabel = Gtk.Label() 30 | devicefplabel.set_line_wrap(True) 31 | devicefplabel.set_max_width_chars(10) 32 | devicefplabel.set_markup(''+devicefp+'') 33 | info4label = Gtk.Label("Are they the same? (Do you trust this Device?)") 34 | infolabel.set_padding(5,0) 35 | info2label.set_padding(5,5) 36 | info3label.set_padding(5,5) 37 | info4label.set_padding(5,5) 38 | infolabel.set_alignment(0, 0) 39 | info2label.set_alignment(0, 0) 40 | info3label.set_alignment(0, 0) 41 | info4label.set_alignment(0, 0) 42 | vbox.pack_start(infolabel, False, True, 10) 43 | vbox.pack_start(info2label, False, True, 10) 44 | vbox.pack_start(myfplabel, False, False, 0) 45 | vbox.pack_start(info3label, False, True, 10) 46 | vbox.pack_start(devicefplabel, False, False, 0) 47 | vbox.pack_start(info4label, True, True, 10) 48 | 49 | hbox = Gtk.Box(spacing=6) 50 | self.nobutton = Gtk.Button(label="no") 51 | self.nobutton.connect("clicked", self.on_cancel_button_clicked) 52 | self.yesbutton = Gtk.Button(label="yes") 53 | self.yesbutton.connect("clicked", self.on_yes_button_clicked) 54 | hbox.pack_start(self.nobutton, True, True, 0) 55 | hbox.pack_start(self.yesbutton, True, True, 0) 56 | vbox.pack_start(hbox, False, False, 10) 57 | 58 | def start(self): 59 | self.connect("destroy", Gtk.main_quit) 60 | self.set_position(Gtk.WindowPosition.CENTER) 61 | self.show_all() 62 | GObject.threads_init() 63 | Gtk.main() 64 | return self.accepted 65 | 66 | def on_yes_button_clicked(self, widget): 67 | self.accepted = True 68 | Gtk.main_quit() 69 | 70 | def on_cancel_button_clicked(self, widget): 71 | self.accepted = False 72 | Gtk.main_quit() 73 | 74 | 75 | def main(args): 76 | myfp = args[1] 77 | devicefp = args[2] 78 | pairing = PairingWindow(myfp, devicefp) 79 | choice = pairing.start() 80 | print choice 81 | 82 | 83 | if __name__ == '__main__': 84 | if(len(sys.argv) < 2): 85 | print "not enough arguments given" 86 | else: 87 | main(sys.argv) 88 | 89 | 90 | -------------------------------------------------------------------------------- /server/mediacontrol.py: -------------------------------------------------------------------------------- 1 | import dbus 2 | import subprocess 3 | import time 4 | 5 | def control(data): 6 | mediacmd = data.split("::")[0] 7 | mediaplayer = data.split("::")[1].lower() 8 | 9 | player = getPlayerProxy(mediaplayer) 10 | if (not player): 11 | startPlayer(mediaplayer) 12 | player = getPlayerProxy(mediaplayer) 13 | 14 | if (mediacmd == "PLAY"): 15 | player.PlayPause() 16 | elif (mediacmd == "NEXT"): 17 | player.Next() 18 | elif (mediacmd == "PREVIOUS"): 19 | player.Previous() 20 | 21 | def getPlayerProxy(pname): 22 | bus = dbus.SessionBus() 23 | 24 | if (pname == "default"): 25 | objname = "" 26 | names = bus.list_names() 27 | for name in names: 28 | if (name.startswith("org.mpris.")): #first player it finds 29 | objname = name 30 | break 31 | 32 | try: 33 | proxy = bus.get_object(objname, '/org/mpris/MediaPlayer2') 34 | player = dbus.Interface(proxy, 'org.mpris.MediaPlayer2.Player') 35 | except: 36 | return None 37 | 38 | else: 39 | try: 40 | proxy = bus.get_object('org.mpris.MediaPlayer2.'+pname, #specific player 41 | '/org/mpris/MediaPlayer2') 42 | player = dbus.Interface(proxy, 'org.mpris.MediaPlayer2.Player') 43 | except: 44 | return None 45 | 46 | return player 47 | 48 | # find default media player 49 | def getDefaultPlayer(): 50 | xdgmime = subprocess.Popen(['xdg-mime', 'query', 'default', 'audio/x-mpeg'], 51 | stdout=subprocess.PIPE) 52 | (vout, verr) = xdgmime.communicate() 53 | desktopfile = vout.strip().split(".") 54 | playername = desktopfile[0] 55 | return playername 56 | 57 | def startPlayer(pname): 58 | if (pname == "default"): 59 | try: 60 | pname = getDefaultPlayer() 61 | except: 62 | return 63 | 64 | subprocess.Popen([pname], stdin=subprocess.PIPE, 65 | stdout=subprocess.PIPE, stderr=subprocess.PIPE) 66 | time.sleep(5) 67 | -------------------------------------------------------------------------------- /server/notificationmanager.py: -------------------------------------------------------------------------------- 1 | import os 2 | import subprocess 3 | import platform 4 | import time 5 | import threading 6 | import sms 7 | from gi.repository import GObject 8 | from gi.repository import Notify 9 | from gi.repository import Gio, GLib, Gtk 10 | 11 | Notify.init ("Desktop Connector") 12 | icon_name = "phone" 13 | FILE_TIMEOUT = 60 14 | 15 | def buildNotification(header, body): 16 | notification=Notify.Notification.new (header, body, icon_name) 17 | notification.show() 18 | 19 | def buildTransientNotification(header, body): 20 | notification=Notify.Notification.new (header, body, icon_name) 21 | notification.set_hint("transient", GLib.Variant.new_boolean(True)) 22 | notification.set_urgency(urgency=Notify.Urgency.NORMAL) 23 | notification.set_timeout(1) 24 | notification.show() 25 | 26 | def buildIncomingFileNotification(filenames, name): 27 | filenotification_thread = FileNotification(filenames, name) 28 | value = filenotification_thread.run() 29 | return value 30 | 31 | def buildFileReceivedNotification(filenames, callback): 32 | filenotification_thread = FileReceivedNotification(filenames, callback) 33 | filenotification_thread.daemon = True 34 | filenotification_thread.start() 35 | 36 | def buildSMSReceivedNotification(name, number, message, ip, port, callback): 37 | smsnotification_thread = SMSReceivedNotification(name, number, message, ip, port, callback) 38 | smsnotification_thread.daemon = True 39 | smsnotification_thread.start() 40 | 41 | 42 | class FileNotification(threading.Thread): 43 | def __init__(self, filenames, name): 44 | threading.Thread.__init__(self) 45 | self.filenames = filenames 46 | filestxt = "" 47 | for filename in self.filenames: 48 | filestxt = filestxt + "\n" + filename 49 | 50 | self.waiting_for_user_input = True 51 | self.accepted = False 52 | self.file_notification = Notify.Notification.new ("File upload", 53 | "incoming File"+filestxt+ 54 | "\nfrom "+name,"phone") 55 | # Fedora workaround 56 | try: 57 | self.file_notification.add_action("acc_file","accept", self.accept,None, None) 58 | self.file_notification.add_action("cancel_file","cancel", self.cancel,None, None) 59 | except TypeError: 60 | self.file_notification.add_action("acc_file","accept", self.accept,None) 61 | self.file_notification.add_action("cancel_file","cancel", self.cancel,None) 62 | 63 | 64 | def run(self): 65 | GObject.threads_init() 66 | self.file_notification.show() 67 | 68 | timeout_thread = threading.Thread(target=self.input_timeout, args=()) 69 | timeout_thread.daemon = True 70 | timeout_thread.start() 71 | 72 | Gtk.main() 73 | return self.accepted 74 | 75 | def accept(self, ac_name, args, a): 76 | self.waiting_for_user_input = False 77 | self.accepted = True 78 | Gtk.main_quit() 79 | 80 | def cancel(self, ac_name, args, a): 81 | self.waiting_for_user_input = False 82 | self.accepted = False 83 | Gtk.main_quit() 84 | 85 | def input_timeout(self): 86 | GObject.threads_init() 87 | timeout = FILE_TIMEOUT 88 | while self.waiting_for_user_input: 89 | time.sleep(1) 90 | timeout = timeout - 1 91 | if timeout == 0: 92 | self.file_notification.close() 93 | self.waiting_for_user_input = False 94 | buildNotification("File", "Filetranfser was canceled after 60 seconds") 95 | Gtk.main_quit() 96 | break 97 | 98 | 99 | class FileReceivedNotification(threading.Thread): 100 | def __init__(self, filenames, callback): 101 | threading.Thread.__init__(self) 102 | self.filenames = filenames 103 | self.callback = callback 104 | filestxt = "" 105 | for filename in self.filenames: 106 | filestxt = filestxt + "\n" + filename 107 | filestxt = filestxt.lstrip("\n") 108 | 109 | self.nnotification = Notify.Notification.new ("File received", filestxt, "phone") 110 | if (len(self.filenames) == 1): 111 | # Fedora workaround 112 | try: 113 | self.nnotification.add_action("open_path","open", self.open_file, filenames[0], None) 114 | except TypeError: 115 | self.nnotification.add_action("open_path","open", self.open_file, filenames[0]) 116 | 117 | # Fedora workaround 118 | try: 119 | self.nnotification.add_action("open_folder","open Folder", self.open_folder, "" , None) 120 | except TypeError: 121 | self.nnotification.add_action("open_folder","open Folder", self.open_folder, "" ) 122 | 123 | def run(self): 124 | GObject.threads_init() 125 | self.nnotification.show() 126 | Gtk.main() 127 | 128 | def open_file(self, ac_name, filename, a): 129 | Gtk.main_quit() 130 | self.callback(a) 131 | 132 | def open_folder(self, ac_name, args, a): 133 | Gtk.main_quit() 134 | self.callback("") 135 | 136 | 137 | class SMSReceivedNotification(threading.Thread): 138 | def __init__(self, name, number, message, ip, port, callback): 139 | threading.Thread.__init__(self) 140 | self.number = number 141 | self.ip = ip 142 | self.port = str(port) 143 | self.callback = callback 144 | if name == "": 145 | name = number 146 | self.sms_notification = Notify.Notification.new ("SMS from "+name, message, icon_name) 147 | # Fedora workaround 148 | try: 149 | self.sms_notification.add_action("reply", "reply", self.reply_sms, None, None) 150 | except TypeError: 151 | self.sms_notification.add_action("reply", "reply", self.reply_sms, None) 152 | 153 | 154 | def run(self): 155 | GObject.threads_init() 156 | self.sms_notification.show() 157 | Gtk.main() 158 | 159 | def reply_sms(self, ac_name, filename, obj): 160 | Gtk.main_quit() 161 | self.callback(self.number, self.ip, self.port) 162 | -------------------------------------------------------------------------------- /server/pair.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import socket 4 | import SocketServer 5 | import subprocess 6 | import platform 7 | import json 8 | import time 9 | from multiprocessing import Process, Queue 10 | import random 11 | import hashlib 12 | import os 13 | import threading 14 | import thread 15 | import configmanager 16 | import ssl 17 | from OpenSSL import SSL, crypto 18 | 19 | def pair(q): 20 | serversocket = socket.socket( 21 | socket.AF_INET, socket.SOCK_STREAM) 22 | 23 | port = int(configmanager.port) 24 | host = configmanager.bindip 25 | serversocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 26 | serversocket.bind((host, port)) 27 | 28 | serversocket.listen(1) 29 | 30 | print "waiting for Connection" 31 | 32 | (clientsocket, address) = serversocket.accept() 33 | 34 | req = clientsocket.recv(1) 35 | 36 | if req=="P": 37 | pair_client(clientsocket, q) 38 | else: 39 | print "closed" 40 | 41 | clientsocket.close() 42 | 43 | 44 | def pair_client(clientsocket, q): 45 | print "wants to pair" 46 | mycert = open(os.path.join(configmanager.keydir, "server.crt"), "r").read() 47 | secure_port = str(configmanager.secure_port) 48 | 49 | myder_cert = ssl.PEM_cert_to_DER_cert(mycert) 50 | m = hashlib.sha256(myder_cert) 51 | myfp = m.hexdigest().upper() 52 | myfp = " ".join(myfp[i:i+4] for i in range(0, len(myfp), 4)) 53 | print "\nMy SHA256: "+myfp 54 | #send my certiuficate 55 | clientsocket.sendall(myder_cert.encode('base64')) 56 | 57 | #receive client Certificate 58 | clientcert = clientsocket.recv(2048) 59 | 60 | m = hashlib.sha256(clientcert) 61 | devicefp = m.hexdigest().upper() 62 | devicefp = " ".join(devicefp[i:i+4] for i in range(0, len(devicefp), 4)) 63 | print "\nClient SHA256: "+devicefp 64 | 65 | if (q): #GUI 66 | q.put([myfp, devicefp]) 67 | vout = q.get(True) 68 | else: #CMDLine only 69 | vout = raw_input("Do they match?(yes/no)\n") 70 | 71 | if (vout.strip().lower()=="yes"): 72 | clientsocket.sendall(secure_port+"\n") 73 | else: 74 | clientsocket.sendall("0\n"); 75 | pass 76 | 77 | print "wait for Device..." 78 | ack = clientsocket.recv(2) 79 | 80 | if (ack=="OK"): 81 | #save pub key 82 | with open(os.path.join(configmanager.keydir, "cas.pem"), 'a') as the_file: 83 | the_file.write(ssl.DER_cert_to_PEM_cert(clientcert)) 84 | 85 | if (q): 86 | q.put(1) 87 | 88 | restart_server() 89 | print "Successfully paired the Device!" 90 | 91 | else: 92 | if (q): 93 | q.put(0) 94 | print "Failed to pair Device." 95 | 96 | def restart_server(): 97 | pid = int(open(configmanager.pidfile, "r").read()) 98 | os.kill(pid, 10) 99 | 100 | if __name__ == '__main__': 101 | pair(None) -------------------------------------------------------------------------------- /server/ping.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import os 4 | import sys 5 | import socket 6 | import configmanager 7 | import json 8 | from OpenSSL import SSL, crypto 9 | 10 | def send_ping(ip, port): 11 | HOST, PORT = ip, int(port) 12 | uuid = configmanager.uuid 13 | hostname = socket.gethostname() 14 | 15 | jsonobj = {'uuid': uuid, 'name': hostname, 16 | 'type': "ping", 'data': ""} 17 | 18 | data = json.dumps(jsonobj) 19 | 20 | # Initialize context 21 | ctx = SSL.Context(SSL.TLSv1_METHOD) 22 | ctx.set_options(SSL.OP_NO_SSLv2|SSL.OP_NO_SSLv3) #TLS1 and up 23 | ctx.set_verify(SSL.VERIFY_PEER, verify_cb) #Demand a certificate 24 | ctx.use_privatekey_file(configmanager.privatekeypath) 25 | ctx.use_certificate_file(configmanager.certificatepath) 26 | ctx.load_verify_locations(configmanager.cafilepath) 27 | sslclientsocket = SSL.Connection(ctx, socket.socket(socket.AF_INET, socket.SOCK_STREAM)) 28 | 29 | succ = False 30 | try: 31 | sslclientsocket.connect((HOST, PORT)) 32 | sslclientsocket.sendall(data) 33 | sslclientsocket.recv(2) 34 | succ = True 35 | 36 | except Exception as e: 37 | print "Error " + str(e[0]) 38 | 39 | finally: 40 | if (succ): 41 | sslclientsocket.shutdown() 42 | sslclientsocket.close() 43 | 44 | 45 | 46 | def verify_cb(conn, cert, errnum, depth, ok): 47 | # This obviously has to be updated 48 | #print "er"+str(errnum) 49 | #print "de"+str(depth) 50 | #print "ok "+str(ok) 51 | return ok 52 | 53 | def main(args): 54 | ip = args[1] 55 | port = args[2] 56 | send_ping(ip, port) 57 | 58 | 59 | if __name__ == '__main__': 60 | if(len(sys.argv) < 3): 61 | print "not enough arguments given" 62 | else: 63 | main(sys.argv) 64 | 65 | 66 | -------------------------------------------------------------------------------- /server/pyperclip.py: -------------------------------------------------------------------------------- 1 | # Pyperclip v1.3 2 | # A cross-platform clipboard module for Python. (only handles plain text for now) 3 | # By Al Sweigart al@coffeeghost.net 4 | 5 | # Usage: 6 | # import pyperclip 7 | # pyperclip.copy('The text to be copied to the clipboard.') 8 | # spam = pyperclip.paste() 9 | 10 | # On Mac, this module makes use of the pbcopy and pbpaste commands, which should come with the os. 11 | # On Linux, this module makes use of the xclip command, which should come with the os. Otherwise run "sudo apt-get install xclip" 12 | 13 | 14 | # Copyright (c) 2010, Albert Sweigart 15 | # All rights reserved. 16 | # 17 | # BSD-style license: 18 | # 19 | # Redistribution and use in source and binary forms, with or without 20 | # modification, are permitted provided that the following conditions are met: 21 | # * Redistributions of source code must retain the above copyright 22 | # notice, this list of conditions and the following disclaimer. 23 | # * Redistributions in binary form must reproduce the above copyright 24 | # notice, this list of conditions and the following disclaimer in the 25 | # documentation and/or other materials provided with the distribution. 26 | # * Neither the name of the pyperclip nor the 27 | # names of its contributors may be used to endorse or promote products 28 | # derived from this software without specific prior written permission. 29 | # 30 | # THIS SOFTWARE IS PROVIDED BY Albert Sweigart "AS IS" AND ANY 31 | # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 32 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 33 | # DISCLAIMED. IN NO EVENT SHALL Albert Sweigart BE LIABLE FOR ANY 34 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 35 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 37 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 38 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 39 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 40 | 41 | # Change Log: 42 | # 1.2 Use the platform module to help determine OS. 43 | # 1.3 Changed ctypes.windll.user32.OpenClipboard(None) to ctypes.windll.user32.OpenClipboard(0), after some people ran into some TypeError 44 | 45 | import platform, os 46 | 47 | def winGetClipboard(): 48 | ctypes.windll.user32.OpenClipboard(0) 49 | pcontents = ctypes.windll.user32.GetClipboardData(1) # 1 is CF_TEXT 50 | data = ctypes.c_char_p(pcontents).value 51 | #ctypes.windll.kernel32.GlobalUnlock(pcontents) 52 | ctypes.windll.user32.CloseClipboard() 53 | return data 54 | 55 | def winSetClipboard(text): 56 | GMEM_DDESHARE = 0x2000 57 | ctypes.windll.user32.OpenClipboard(0) 58 | ctypes.windll.user32.EmptyClipboard() 59 | try: 60 | # works on Python 2 (bytes() only takes one argument) 61 | hCd = ctypes.windll.kernel32.GlobalAlloc(GMEM_DDESHARE, len(bytes(text))+1) 62 | except TypeError: 63 | # works on Python 3 (bytes() requires an encoding) 64 | hCd = ctypes.windll.kernel32.GlobalAlloc(GMEM_DDESHARE, len(bytes(text, 'ascii'))+1) 65 | pchData = ctypes.windll.kernel32.GlobalLock(hCd) 66 | try: 67 | # works on Python 2 (bytes() only takes one argument) 68 | ctypes.cdll.msvcrt.strcpy(ctypes.c_char_p(pchData), bytes(text)) 69 | except TypeError: 70 | # works on Python 3 (bytes() requires an encoding) 71 | ctypes.cdll.msvcrt.strcpy(ctypes.c_char_p(pchData), bytes(text, 'ascii')) 72 | ctypes.windll.kernel32.GlobalUnlock(hCd) 73 | ctypes.windll.user32.SetClipboardData(1,hCd) 74 | ctypes.windll.user32.CloseClipboard() 75 | 76 | def macSetClipboard(text): 77 | outf = os.popen('pbcopy', 'w') 78 | outf.write(text) 79 | outf.close() 80 | 81 | def macGetClipboard(): 82 | outf = os.popen('pbpaste', 'r') 83 | content = outf.read() 84 | outf.close() 85 | return content 86 | 87 | def gtkGetClipboard(): 88 | return gtk.Clipboard().wait_for_text() 89 | 90 | def gtkSetClipboard(text): 91 | cb = gtk.Clipboard() 92 | cb.set_text(text) 93 | cb.store() 94 | 95 | def qtGetClipboard(): 96 | return str(cb.text()) 97 | 98 | def qtSetClipboard(text): 99 | cb.setText(text) 100 | 101 | def xclipSetClipboard(text): 102 | outf = os.popen('xclip -selection c', 'w') 103 | outf.write(text) 104 | outf.close() 105 | 106 | def xclipGetClipboard(): 107 | outf = os.popen('xclip -selection c -o', 'r') 108 | content = outf.read() 109 | outf.close() 110 | return content 111 | 112 | def xselSetClipboard(text): 113 | outf = os.popen('xsel -i', 'w') 114 | outf.write(text) 115 | outf.close() 116 | 117 | def xselGetClipboard(): 118 | outf = os.popen('xsel -o', 'r') 119 | content = outf.read() 120 | outf.close() 121 | return content 122 | 123 | 124 | if os.name == 'nt' or platform.system() == 'Windows': 125 | import ctypes 126 | getcb = winGetClipboard 127 | setcb = winSetClipboard 128 | elif os.name == 'mac' or platform.system() == 'Darwin': 129 | getcb = macGetClipboard 130 | setcb = macSetClipboard 131 | elif os.name == 'posix' or platform.system() == 'Linux': 132 | xclipExists = os.system('which xclip') == 0 133 | if xclipExists: 134 | getcb = xclipGetClipboard 135 | setcb = xclipSetClipboard 136 | else: 137 | xselExists = os.system('which xsel') == 0 138 | if xselExists: 139 | getcb = xselGetClipboard 140 | setcb = xselSetClipboard 141 | try: 142 | import gtk 143 | getcb = gtkGetClipboard 144 | setcb = gtkSetClipboard 145 | except: 146 | try: 147 | import PyQt4.QtCore 148 | import PyQt4.QtGui 149 | app = QApplication([]) 150 | cb = PyQt4.QtGui.QApplication.clipboard() 151 | getcb = qtGetClipboard 152 | setcb = qtSetClipboard 153 | except: 154 | raise Exception('Pyperclip requires the gtk or PyQt4 module installed, or the xclip command.') 155 | copy = setcb 156 | paste = getcb -------------------------------------------------------------------------------- /server/settingswindow.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import os 4 | import sys 5 | import configmanager 6 | import json 7 | from gi.repository import Gtk, GObject 8 | 9 | class EntryWindow(): 10 | 11 | def __init__(self): 12 | 13 | builder = Gtk.Builder() 14 | builder.add_from_file(os.getcwd()+"/share/ui/settings.glade") 15 | builder.connect_signals(self) 16 | self.window = builder.get_object("settingswindow") 17 | self.ipentry = builder.get_object("ipentry") 18 | self.portentry = builder.get_object("portentry") 19 | self.secportentry = builder.get_object("secportentry") 20 | self.downloadfilechooserbutton = builder.get_object("downloadfilechooserbutton") 21 | self.uuidlabel = builder.get_object("uuidlabel") 22 | self.autourlswitch = builder.get_object("autourlswitch") 23 | self.autoclipboardswitch = builder.get_object("autoclipboardswitch") 24 | self.autofileswitch = builder.get_object("autofileswitch") 25 | 26 | self.uuidlabel.set_text(str(configmanager.uuid)) 27 | self.downloadfilechooserbutton.set_filename(configmanager.downloaddir) 28 | self.ipentry.set_text(configmanager.bindip) 29 | self.portentry.set_text(configmanager.port) 30 | self.secportentry.set_text(configmanager.secure_port) 31 | self.autourlswitch.set_active(configmanager.auto_open_urls) 32 | self.autoclipboardswitch.set_active(configmanager.auto_store_clipboard) 33 | self.autofileswitch.set_active(configmanager.auto_accept_files) 34 | 35 | self.window.set_wmclass ("DeskCon", "Settings") 36 | 37 | self.window.show_all() 38 | 39 | def on_sendbutton_clicked(self, widget): 40 | siter = self.textbuffer.get_start_iter() 41 | eiter = self.textbuffer.get_end_iter() 42 | txt = self.textbuffer.get_text(siter, eiter, False).strip() 43 | number = self.numberentry.get_text().strip() 44 | 45 | if (number == ""): 46 | self.errordialog.format_secondary_text("No Number.") 47 | self.errordialog.run() 48 | self.errordialog.hide() 49 | elif (txt == ""): 50 | self.errordialog.format_secondary_text("Text is empty.") 51 | self.errordialog.run() 52 | self.errordialog.hide() 53 | else: 54 | send_sms(number,txt, self.ip, self.port, self.errordialog) 55 | 56 | def on_closebutton_clicked(self, widget): 57 | Gtk.main_quit() 58 | 59 | def on_okbutton_clicked(self, widget): 60 | datadict = {} 61 | datadict['downloaddir'] = self.downloadfilechooserbutton.get_filename() 62 | datadict['bindip'] = self.ipentry.get_text() 63 | datadict['port'] = int(self.portentry.get_text()) 64 | datadict['secure_port'] = int(self.secportentry.get_text()) 65 | datadict['debug'] = False 66 | datadict['auto_open_urls'] = self.autourlswitch.get_active() 67 | datadict['auto_store_clipboard'] = self.autoclipboardswitch.get_active() 68 | datadict['auto_accept_files'] = self.autofileswitch.get_active() 69 | configmanager.write_config(datadict) 70 | restart_server() 71 | Gtk.main_quit() 72 | 73 | def on_settingswindow_destroy(self, *args): 74 | Gtk.main_quit(*args) 75 | 76 | def on_errordialog_close(self, widget): 77 | Gtk.main_quit() 78 | 79 | 80 | def restart_server(): 81 | pid = int(open(configmanager.pidfile, "r").read()) 82 | os.kill(pid, 10) 83 | 84 | 85 | def main(args): 86 | GObject.threads_init() 87 | win = EntryWindow() 88 | Gtk.main() 89 | 90 | if __name__ == '__main__': 91 | main(sys.argv) 92 | 93 | 94 | -------------------------------------------------------------------------------- /server/setupdevice.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import os 4 | import sys 5 | import configmanager 6 | import json 7 | import socket 8 | from gi.repository import Gtk, GObject 9 | import pair 10 | from multiprocessing import Process, Queue 11 | import threading 12 | import thread 13 | 14 | class EntryWindow(): 15 | 16 | def __init__(self): 17 | builder = Gtk.Builder() 18 | builder.add_from_file(os.getcwd()+"/share/ui/pairingwindow.glade") 19 | builder.connect_signals(self) 20 | self.window = builder.get_object("pairingwindow") 21 | self.notebook = builder.get_object("notebook1") 22 | self.cancelbutton = builder.get_object("cancelbutton") 23 | self.forwardbutton = builder.get_object("forwardbutton") 24 | self.openportslabel = builder.get_object("openportslabel") 25 | self.hostlabel = builder.get_object("hostlabel") 26 | self.desktopfplabel = builder.get_object("desktopfplabel") 27 | self.devicefplabel = builder.get_object("devicefplabel") 28 | self.succlabel = builder.get_object("succlabel") 29 | self.faillabel = builder.get_object("faillabel") 30 | 31 | pairport = str(configmanager.port) 32 | openports = pairport + ", " + str(configmanager.secure_port) 33 | lanip = socket.gethostname() 34 | hosttxt = "Host: "+lanip+" or IP"+"\nPort: "+pairport 35 | 36 | self.stage = 0 37 | 38 | self.openportslabel.set_text(openports) 39 | self.hostlabel.set_text(hosttxt) 40 | 41 | self.window.set_wmclass ("DeskCon", "Setup Device") 42 | 43 | self.window.show_all() 44 | 45 | def on_cancelbutton_clicked(self, widget): 46 | if (self.stage == 0): 47 | Gtk.main_quit() 48 | elif (self.stage == 2): 49 | self.pthread.response(0) 50 | self.succlabel.hide() 51 | self.notebook.set_current_page(3) 52 | self.stage = 3 53 | else: 54 | self.pthread.stop() 55 | Gtk.main_quit() 56 | 57 | def on_forwardbutton_clicked(self, widget): 58 | if (self.stage == 0): 59 | self.pthread = pairingThread(self) 60 | self.pthread.daemon = True 61 | self.pthread.start() 62 | self.dthread = discoveryThread() 63 | self.dthread.daemon = True 64 | self.dthread.start() 65 | self.notebook.set_current_page(1) 66 | self.stage = 1 67 | 68 | elif (self.stage == 2): 69 | self.notebook.set_current_page(4) 70 | self.pthread.response(1) 71 | 72 | def on_pairingwindow_destroy(self, *args): 73 | if ("self.pthread" in locals()): 74 | self.pthread.stop() 75 | Gtk.main_quit(*args) 76 | 77 | 78 | class discoveryThread (threading.Thread): 79 | 80 | def __init__(self): 81 | threading.Thread.__init__(self) 82 | 83 | def run(self): 84 | UDP_IP = "0.0.0.0" 85 | UDP_PORT = 5108 86 | 87 | sock = socket.socket(socket.AF_INET, # Internet 88 | socket.SOCK_DGRAM) # UDP 89 | sock.bind((UDP_IP, UDP_PORT)) 90 | 91 | while (True): 92 | data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes 93 | 94 | spl = data.split("::") 95 | if (spl[0] == "0"): 96 | print "received discovery broadcast" 97 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 98 | s.bind(('', 0)) 99 | s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) 100 | uuid = str(configmanager.uuid) 101 | pairport = str(configmanager.port) 102 | hostname = socket.gethostname() 103 | data = uuid+"::"+hostname+"::"+pairport 104 | s.sendto(data, (addr[0], UDP_PORT)) 105 | 106 | 107 | class pairingThread (threading.Thread): 108 | 109 | def __init__(self, window): 110 | threading.Thread.__init__(self) 111 | self.window = window 112 | self.q = Queue() 113 | self.pairprocess = Process(target=pair.pair, args=(self.q,)) 114 | self.pairprocess.daemon = True 115 | 116 | def run(self): 117 | self.pairprocess.start() 118 | fingerprints = self.q.get(True) 119 | self.window.desktopfplabel.set_text(fingerprints[0]) 120 | self.window.devicefplabel.set_text(fingerprints[1]) 121 | self.window.notebook.set_current_page(2) 122 | self.window.stage = 2 123 | 124 | def response(self, r): 125 | thread.start_new_thread(self.sendresponse, (r,)) 126 | 127 | def sendresponse(self, r): 128 | if (r == 1): #fingerprints match 129 | self.q.put("yes", True) 130 | result = self.q.get(True) 131 | 132 | if (result == 1): 133 | self.window.faillabel.hide() 134 | self.window.notebook.set_current_page(3) 135 | self.window.stage = 3 136 | else: 137 | self.window.succlabel.hide() 138 | self.window.notebook.set_current_page(3) 139 | self.window.stage = 3 140 | 141 | else: #fingerprints do not match 142 | self.q.put("no", True) 143 | 144 | def stop(self): 145 | self.pairprocess.terminate() 146 | 147 | def main(args): 148 | GObject.threads_init() 149 | win = EntryWindow() 150 | Gtk.main() 151 | 152 | if __name__ == '__main__': 153 | main(sys.argv) -------------------------------------------------------------------------------- /server/share/config.conf: -------------------------------------------------------------------------------- 1 | [network] 2 | port = 8082 3 | secure_port = 8083 4 | bindip = 0.0.0.0 5 | 6 | [general] 7 | download_dir = Downloads 8 | uuid = 0000000000000000 9 | debug = false 10 | 11 | [permissions] 12 | auto_accept_files = false 13 | auto_open_urls = true 14 | auto_store_clipboard = true 15 | -------------------------------------------------------------------------------- /server/share/deskcon-server-settings.desktop.in: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=DeskCon Settings 3 | Comment=Configure DeskCon 4 | Exec=deskcon-server-settings 5 | Icon=phone 6 | Terminal=false 7 | StartupNotify=true 8 | Type=Application 9 | Categories=Utility; -------------------------------------------------------------------------------- /server/share/deskcon-server.desktop.in: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=DeskCon 3 | Comment=DeskCon Desktop Server 4 | Exec=deskcon-server 5 | Terminal=false 6 | StartupNotify=false 7 | Type=Application 8 | Categories= 9 | X-GNOME-Autostart-Phase=Application 10 | X-GNOME-Autostart-Notify=true -------------------------------------------------------------------------------- /server/share/ui/pairingwindow.glade: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | False 7 | Pairing 8 | center 9 | 10 | 11 | 12 | True 13 | False 14 | 5 15 | 5 16 | 5 17 | 5 18 | 19 | 20 | True 21 | False 22 | vertical 23 | 5 24 | 25 | 26 | True 27 | True 28 | False 29 | 30 | 31 | True 32 | False 33 | vertical 34 | 25 35 | 36 | 37 | True 38 | False 39 | To pair this Desktop PC with your mobile Device, 40 | follow the Instructions in this Setup Guide. 41 | center 42 | end 43 | 44 | 45 | False 46 | True 47 | 0 48 | 49 | 50 | 51 | 52 | True 53 | False 54 | Attention: If you are using a Firewall, please make sure 55 | the following TCP Ports are open 56 | 57 | 58 | False 59 | True 60 | 1 61 | 62 | 63 | 64 | 65 | True 66 | False 67 | 8082, 8086 68 | end 69 | 70 | 71 | 72 | 73 | 74 | False 75 | True 76 | 2 77 | 78 | 79 | 80 | 81 | True 82 | False 83 | 84 | 85 | gtk-cancel 86 | True 87 | True 88 | True 89 | True 90 | 91 | 92 | 93 | False 94 | True 95 | 0 96 | 97 | 98 | 99 | 100 | gtk-go-forward 101 | True 102 | True 103 | True 104 | True 105 | right 106 | 107 | 108 | 109 | False 110 | True 111 | 1 112 | 113 | 114 | 115 | 116 | False 117 | True 118 | end 119 | 3 120 | 121 | 122 | 123 | 124 | 125 | 126 | True 127 | False 128 | page 1 129 | 130 | 131 | False 132 | 133 | 134 | 135 | 136 | True 137 | False 138 | vertical 139 | 25 140 | 141 | 142 | True 143 | False 144 | 1. Open the <b>DeskCon App</b> on your mobile Device 145 | True 146 | middle 147 | 148 | 149 | False 150 | True 151 | 0 152 | 153 | 154 | 155 | 156 | True 157 | False 158 | 2. Click on <b>Desktop Hosts</b> in the Network Section 159 | and touch the <b>(+) Plus</b> Sign 160 | True 161 | center 162 | 163 | 164 | False 165 | True 166 | 1 167 | 168 | 169 | 170 | 171 | True 172 | False 173 | 3. Use the following Values in the new Dialog 174 | 175 | 176 | False 177 | True 178 | 2 179 | 180 | 181 | 182 | 183 | True 184 | False 185 | Host: 192.168.0.20 186 | Port: 8082 187 | 188 | 189 | 190 | 191 | 192 | False 193 | True 194 | 3 195 | 196 | 197 | 198 | 199 | True 200 | False 201 | and click <b>OK</b> 202 | True 203 | 204 | 205 | False 206 | True 207 | 4 208 | 209 | 210 | 211 | 212 | True 213 | False 214 | waiting for Connection ... 215 | 216 | 217 | False 218 | False 219 | 5 220 | 221 | 222 | 223 | 224 | True 225 | False 226 | start 227 | 228 | 229 | gtk-cancel 230 | True 231 | True 232 | True 233 | True 234 | 235 | 236 | 237 | False 238 | True 239 | 0 240 | 241 | 242 | 243 | 244 | False 245 | False 246 | end 247 | 6 248 | 249 | 250 | 251 | 252 | 1 253 | 254 | 255 | 256 | 257 | True 258 | False 259 | page 2 260 | 261 | 262 | 1 263 | False 264 | 265 | 266 | 267 | 268 | True 269 | False 270 | vertical 271 | 25 272 | 273 | 274 | True 275 | False 276 | Exchanged Certificates between Devices. 277 | 278 | 279 | False 280 | True 281 | 0 282 | 283 | 284 | 285 | 286 | True 287 | False 288 | 4. please check whether these <b>Fingerprints</b> are the same as 289 | the ones displayed on your mobile Device 290 | True 291 | center 292 | 293 | 294 | False 295 | True 296 | 1 297 | 298 | 299 | 300 | 301 | True 302 | False 303 | This Desktops Fingerprint: 304 | 305 | 306 | False 307 | True 308 | 2 309 | 310 | 311 | 312 | 313 | True 314 | False 315 | label 316 | True 317 | 318 | 319 | 320 | 321 | 322 | False 323 | True 324 | 3 325 | 326 | 327 | 328 | 329 | True 330 | False 331 | Mobile Device Fingerprint: 332 | 333 | 334 | False 335 | True 336 | 4 337 | 338 | 339 | 340 | 341 | True 342 | False 343 | label 344 | True 345 | 346 | 347 | 348 | 349 | 350 | False 351 | True 352 | 5 353 | 354 | 355 | 356 | 357 | True 358 | False 359 | Are the colored Fingerprints the <b>same</b> (do you trust this Device?) 360 | True 361 | 362 | 363 | False 364 | True 365 | 6 366 | 367 | 368 | 369 | 370 | True 371 | False 372 | 373 | 374 | gtk-no 375 | True 376 | True 377 | True 378 | True 379 | 380 | 381 | 382 | False 383 | True 384 | 0 385 | 386 | 387 | 388 | 389 | gtk-yes 390 | True 391 | True 392 | True 393 | True 394 | 395 | 396 | 397 | False 398 | True 399 | 1 400 | 401 | 402 | 403 | 404 | False 405 | True 406 | end 407 | 7 408 | 409 | 410 | 411 | 412 | 2 413 | 414 | 415 | 416 | 417 | True 418 | False 419 | page 3 420 | 421 | 422 | 2 423 | False 424 | 425 | 426 | 427 | 428 | True 429 | False 430 | vertical 431 | 432 | 433 | True 434 | False 435 | Pairing was successful. 436 | 437 | 438 | True 439 | True 440 | 0 441 | 442 | 443 | 444 | 445 | False 446 | Pairing failed. 447 | 448 | 449 | True 450 | True 451 | 1 452 | 453 | 454 | 455 | 456 | True 457 | False 458 | end 459 | 460 | 461 | gtk-close 462 | True 463 | True 464 | True 465 | none 466 | True 467 | 468 | 469 | 470 | False 471 | True 472 | 0 473 | 474 | 475 | 476 | 477 | False 478 | False 479 | end 480 | 2 481 | 482 | 483 | 484 | 485 | 3 486 | 487 | 488 | 489 | 490 | True 491 | False 492 | page 4 493 | 494 | 495 | 3 496 | False 497 | 498 | 499 | 500 | 501 | True 502 | False 503 | waiting for Device Answer ... 504 | 0.059999999999999998 505 | 506 | 507 | 4 508 | 509 | 510 | 511 | 512 | True 513 | False 514 | page 5 515 | 516 | 517 | 4 518 | False 519 | 520 | 521 | 522 | 523 | False 524 | True 525 | 0 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | -------------------------------------------------------------------------------- /server/share/ui/settings.glade: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | False 7 | DeskCon Settings 8 | center 9 | 400 10 | 11 | 12 | 13 | True 14 | False 15 | 5 16 | 5 17 | 5 18 | 5 19 | 20 | 21 | True 22 | False 23 | vertical 24 | 7 25 | 26 | 27 | True 28 | False 29 | 0 30 | none 31 | 32 | 33 | True 34 | False 35 | 12 36 | 37 | 38 | True 39 | False 40 | 5 41 | 42 | 43 | True 44 | False 45 | True 46 | 0 47 | UUID: 48 | 49 | 50 | 0 51 | 0 52 | 1 53 | 1 54 | 55 | 56 | 57 | 58 | True 59 | False 60 | 0 61 | Download Folder: 62 | 63 | 64 | 0 65 | 1 66 | 1 67 | 1 68 | 69 | 70 | 71 | 72 | True 73 | False 74 | 0 75 | Debug: 76 | 77 | 78 | 0 79 | 2 80 | 1 81 | 1 82 | 83 | 84 | 85 | 86 | True 87 | False 88 | 0 89 | 90 | 91 | 1 92 | 0 93 | 1 94 | 1 95 | 96 | 97 | 98 | 99 | enable 100 | True 101 | True 102 | False 103 | 0 104 | True 105 | 106 | 107 | 1 108 | 2 109 | 1 110 | 1 111 | 112 | 113 | 114 | 115 | True 116 | False 117 | select-folder 118 | Select a Folder 119 | 120 | 121 | 1 122 | 1 123 | 1 124 | 1 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | True 134 | False 135 | General 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | False 144 | True 145 | 0 146 | 147 | 148 | 149 | 150 | True 151 | False 152 | 0 153 | none 154 | 155 | 156 | True 157 | False 158 | 12 159 | 160 | 161 | True 162 | False 163 | 5 164 | 165 | 166 | True 167 | False 168 | True 169 | 0 170 | Bind IP: 171 | 172 | 173 | 0 174 | 0 175 | 1 176 | 1 177 | 178 | 179 | 180 | 181 | True 182 | False 183 | 0 184 | Port: 185 | 186 | 187 | 0 188 | 1 189 | 1 190 | 1 191 | 192 | 193 | 194 | 195 | True 196 | False 197 | 0 198 | Secure Port: 199 | 200 | 201 | 0 202 | 2 203 | 1 204 | 1 205 | 206 | 207 | 208 | 209 | True 210 | True 211 | 1 212 | 213 | 214 | 1 215 | 0 216 | 1 217 | 1 218 | 219 | 220 | 221 | 222 | True 223 | True 224 | 1 225 | digits 226 | 227 | 228 | 1 229 | 1 230 | 1 231 | 1 232 | 233 | 234 | 235 | 236 | True 237 | True 238 | 1 239 | digits 240 | 241 | 242 | 1 243 | 2 244 | 1 245 | 1 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | True 255 | False 256 | Network 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | False 265 | True 266 | 1 267 | 268 | 269 | 270 | 271 | True 272 | False 273 | 10 274 | bottom 275 | 276 | 277 | gtk-close 278 | True 279 | True 280 | True 281 | True 282 | 283 | 284 | 285 | False 286 | True 287 | 0 288 | 289 | 290 | 291 | 292 | gtk-ok 293 | True 294 | True 295 | True 296 | True 297 | 298 | 299 | 300 | False 301 | True 302 | 1 303 | 304 | 305 | 306 | 307 | False 308 | False 309 | end 310 | 2 311 | 312 | 313 | 314 | 315 | True 316 | False 317 | True 318 | 0 319 | none 320 | 321 | 322 | True 323 | False 324 | 12 325 | 326 | 327 | True 328 | False 329 | 5 330 | 331 | 332 | True 333 | False 334 | True 335 | 0 336 | Auto open URLs: 337 | 338 | 339 | 0 340 | 0 341 | 1 342 | 1 343 | 344 | 345 | 346 | 347 | True 348 | False 349 | 0 350 | Auto store in Clipboard: 351 | 352 | 353 | 0 354 | 1 355 | 1 356 | 1 357 | 358 | 359 | 360 | 361 | True 362 | False 363 | 0 364 | Auto accept Files: 365 | 366 | 367 | 0 368 | 2 369 | 1 370 | 1 371 | 372 | 373 | 374 | 375 | True 376 | True 377 | 378 | 379 | 1 380 | 0 381 | 1 382 | 1 383 | 384 | 385 | 386 | 387 | True 388 | True 389 | 390 | 391 | 1 392 | 1 393 | 1 394 | 1 395 | 396 | 397 | 398 | 399 | True 400 | True 401 | 402 | 403 | 1 404 | 2 405 | 1 406 | 1 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | True 416 | False 417 | Permissions 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | False 426 | True 427 | 3 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | -------------------------------------------------------------------------------- /server/share/ui/sms.glade: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | False 7 | Error 8 | True 9 | center-on-parent 10 | True 11 | dialog 12 | center 13 | error 14 | ok 15 | Could not send your Message 16 | 17 | 18 | False 19 | vertical 20 | 2 21 | 22 | 23 | False 24 | end 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | False 34 | True 35 | end 36 | 0 37 | 38 | 39 | 40 | 41 | 42 | 43 | False 44 | Compose 45 | center 46 | 440 47 | 250 48 | phone 49 | 50 | 51 | 52 | True 53 | False 54 | 5 55 | 5 56 | 5 57 | 5 58 | 59 | 60 | True 61 | False 62 | vertical 63 | 1 64 | 65 | 66 | True 67 | True 68 | word 69 | 70 | 71 | True 72 | True 73 | 2 74 | 0 75 | 76 | 77 | 78 | 79 | True 80 | False 81 | 82 | 83 | True 84 | False 85 | Number: 86 | 87 | 88 | False 89 | True 90 | 0 91 | 92 | 93 | 94 | 95 | True 96 | False 97 | 98 | 99 | False 100 | True 101 | end 102 | 1 103 | 104 | 105 | 106 | 107 | False 108 | True 109 | 1 110 | 111 | 112 | 113 | 114 | True 115 | False 116 | 5 117 | 118 | 119 | True 120 | True 121 | 122 | 123 | True 124 | True 125 | 0 126 | 127 | 128 | 129 | 130 | Send 131 | True 132 | True 133 | True 134 | 135 | 136 | 137 | False 138 | True 139 | end 140 | 1 141 | 142 | 143 | 144 | 145 | gtk-cancel 146 | True 147 | True 148 | True 149 | True 150 | 151 | 152 | 153 | False 154 | True 155 | 2 156 | 157 | 158 | 159 | 160 | False 161 | True 162 | 2 163 | 2 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | -------------------------------------------------------------------------------- /server/sms.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import os 4 | import sys 5 | import socket 6 | import configmanager 7 | import json 8 | from OpenSSL import SSL, crypto 9 | from gi.repository import Gtk, GObject 10 | 11 | class EntryWindow(): 12 | 13 | def __init__(self, ip, port, number): 14 | 15 | builder = Gtk.Builder() 16 | builder.add_from_file(os.getcwd()+"/share/ui/sms.glade") 17 | builder.connect_signals(self) 18 | self.window = builder.get_object("smswindow") 19 | self.numberentry = builder.get_object("numberentry") 20 | self.messagetextview = builder.get_object("messagetextview") 21 | self.charlabel = builder.get_object("charcountlabel") 22 | self.errordialog = builder.get_object("errordialog") 23 | 24 | self.window.set_wmclass ("DeskCon", "Compose") 25 | 26 | self.ip = ip 27 | self.port = port 28 | 29 | self.numberentry.set_text(number) 30 | self.textbuffer = self.messagetextview.get_buffer() 31 | self.window.show_all() 32 | 33 | def on_sendbutton_clicked(self, widget): 34 | siter = self.textbuffer.get_start_iter() 35 | eiter = self.textbuffer.get_end_iter() 36 | txt = self.textbuffer.get_text(siter, eiter, False).strip() 37 | number = self.numberentry.get_text().strip() 38 | 39 | if (number == ""): 40 | self.errordialog.format_secondary_text("No Number.") 41 | self.errordialog.run() 42 | self.errordialog.hide() 43 | elif (txt == ""): 44 | self.errordialog.format_secondary_text("Text is empty.") 45 | self.errordialog.run() 46 | self.errordialog.hide() 47 | else: 48 | send_sms(number,txt, self.ip, self.port, self.errordialog) 49 | 50 | 51 | def on_cancelbutton_clicked(self, widget): 52 | Gtk.main_quit() 53 | 54 | def on_smswindow_destroy(self, *args): 55 | Gtk.main_quit(*args) 56 | 57 | def on_errordialog_close(self, widget): 58 | Gtk.main_quit() 59 | 60 | 61 | def send_sms(recver, msg, ip, port, errordialog): 62 | HOST, PORT = ip, int(port) 63 | uuid = configmanager.uuid 64 | hostname = socket.gethostname() 65 | 66 | jsonobj = {'uuid': uuid, 'name': hostname, 67 | 'type': "sms", 'data': {'number': recver, 'message': msg}} 68 | 69 | data = json.dumps(jsonobj) 70 | 71 | # Initialize context 72 | ctx = SSL.Context(SSL.TLSv1_METHOD) 73 | ctx.set_options(SSL.OP_NO_SSLv2|SSL.OP_NO_SSLv3) #TLS1 and up 74 | ctx.set_verify(SSL.VERIFY_PEER, verify_cb) #Demand a certificate 75 | ctx.use_privatekey_file(configmanager.privatekeypath) 76 | ctx.use_certificate_file(configmanager.certificatepath) 77 | ctx.load_verify_locations(configmanager.cafilepath) 78 | sslclientsocket = SSL.Connection(ctx, socket.socket(socket.AF_INET, socket.SOCK_STREAM)) 79 | 80 | succ = False 81 | try: 82 | sslclientsocket.connect((HOST, PORT)) 83 | sslclientsocket.sendall(data) 84 | sslclientsocket.recv(2) 85 | succ = True 86 | 87 | except Exception as e: 88 | errnum = e[0] 89 | print "Error " + str(e[0]) 90 | if (errnum == -5): 91 | errordialog.format_secondary_text("The Device is not reachable. Maybe it's not on your Network") 92 | else: 93 | errordialog.format_secondary_text("Errornumber "+str(errnum)) 94 | errordialog.run() 95 | errordialog.hide() 96 | 97 | finally: 98 | if (succ): 99 | sslclientsocket.shutdown() 100 | sslclientsocket.close() 101 | Gtk.main_quit() 102 | 103 | 104 | 105 | def verify_cb(conn, cert, errnum, depth, ok): 106 | # This obviously has to be updated 107 | #print "er"+str(errnum) 108 | #print "de"+str(depth) 109 | #print "ok "+str(ok) 110 | return ok 111 | 112 | def main(args): 113 | GObject.threads_init() 114 | ip = args[1] 115 | port = args[2] 116 | if (len(args) == 4): 117 | number = args[3] 118 | else: 119 | number = "" 120 | 121 | win = EntryWindow(ip, port, number) 122 | Gtk.main() 123 | 124 | 125 | if __name__ == '__main__': 126 | if(len(sys.argv) < 3): 127 | print "not enough arguments given" 128 | else: 129 | main(sys.argv) 130 | 131 | 132 | -------------------------------------------------------------------------------- /server/windows.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | import threading 3 | import os 4 | import sys 5 | import socket 6 | import configmanager 7 | from OpenSSL import SSL, crypto 8 | from gi.repository import Gio, GLib, Gtk, GObject, Gdk 9 | 10 | def build_Pairing_Window(MyFp, DeviceFp): 11 | pairing = PairingWindow(MyFp, DeviceFp) 12 | choice = pairing.start() 13 | return choice 14 | 15 | class PairingWindow(Gtk.Window): 16 | def __init__(self, myfp, devicefp): 17 | Gtk.Window.__init__(self, title="Pairing") 18 | self.set_resizable(False) 19 | self.set_size_request(300, 300) 20 | self.accepted = False 21 | 22 | vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6) 23 | self.add(vbox) 24 | 25 | infolabel = Gtk.Label("Please check whether these Fingerprints are the same as"+ 26 | "\nthe ones displayed on your mobile Device") 27 | info2label = Gtk.Label("This Desktops Fingerprint:") 28 | myfplabel = Gtk.Label(myfp) 29 | myfplabel.set_line_wrap(True) 30 | myfplabel.set_max_width_chars(10) 31 | info3label = Gtk.Label("Mobile Device Fingerprint:") 32 | devicefplabel = Gtk.Label(devicefp) 33 | devicefplabel.set_line_wrap(True) 34 | devicefplabel.set_max_width_chars(10) 35 | info4label = Gtk.Label("Are they the same? (Do you trust this Device?)") 36 | infolabel.set_padding(5,0) 37 | info2label.set_padding(5,5) 38 | info3label.set_padding(5,5) 39 | info4label.set_padding(5,5) 40 | infolabel.set_alignment(0, 0) 41 | info2label.set_alignment(0, 0) 42 | info3label.set_alignment(0, 0) 43 | info4label.set_alignment(0, 0) 44 | vbox.pack_start(infolabel, False, True, 10) 45 | vbox.pack_start(info2label, False, True, 10) 46 | vbox.pack_start(myfplabel, False, False, 0) 47 | vbox.pack_start(info3label, False, True, 10) 48 | vbox.pack_start(devicefplabel, False, False, 0) 49 | vbox.pack_start(info4label, True, True, 10) 50 | 51 | hbox = Gtk.Box(spacing=6) 52 | self.nobutton = Gtk.Button(label="no") 53 | self.nobutton.connect("clicked", self.on_cancel_button_clicked) 54 | self.yesbutton = Gtk.Button(label="yes") 55 | self.yesbutton.connect("clicked", self.on_yes_button_clicked) 56 | hbox.pack_start(self.nobutton, True, True, 0) 57 | hbox.pack_start(self.yesbutton, True, True, 0) 58 | vbox.pack_start(hbox, False, False, 10) 59 | 60 | def start(self): 61 | self.connect("destroy", Gtk.main_quit) 62 | self.set_position(Gtk.WindowPosition.CENTER) 63 | self.show_all() 64 | GObject.threads_init() 65 | Gtk.main() 66 | return self.accepted 67 | 68 | def on_yes_button_clicked(self, widget): 69 | self.accepted = True 70 | Gtk.main_quit() 71 | 72 | def on_cancel_button_clicked(self, widget): 73 | self.accepted = False 74 | Gtk.main_quit() 75 | -------------------------------------------------------------------------------- /setup_device.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | BINPATH=`dirname $0` 4 | cd $BINPATH/server/ 5 | ./setupdevice.py -------------------------------------------------------------------------------- /unity/bin/deskcon-indicator: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd /usr/share/deskcon-indicator/ 4 | python deskcon-indicator 5 | -------------------------------------------------------------------------------- /unity/darkindicator-deskcon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xml -------------------------------------------------------------------------------- /unity/deskcon-indicator: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import dbus 4 | import json 5 | import os 6 | from gi.repository import GObject, Gtk 7 | from gi.repository import AppIndicator3 as appindicator 8 | from dbus import glib 9 | from dbus.mainloop.glib import DBusGMainLoop 10 | glib.init_threads() 11 | 12 | class IndicatorDeskCon: 13 | def __init__(self): 14 | workingdir = os.getcwd() 15 | 16 | self.ind = appindicator.Indicator.new("indicator-deskcon", 17 | "indicator-deskcon", 18 | appindicator.IndicatorCategory.APPLICATION_STATUS) 19 | 20 | self.ind.set_status (appindicator.IndicatorStatus.ACTIVE) 21 | 22 | self.menu = Gtk.Menu() 23 | 24 | self.menu.show() 25 | self.ind.set_menu(self.menu) 26 | self.dbusclient = DbusClient(self) 27 | self.devicelist = {} 28 | 29 | #Settings Button 30 | self.settingsitem = Gtk.MenuItem("Settings") 31 | self.settingsitem.connect("activate", self.showsettings) 32 | self.settingsitem.show() 33 | self.menu.append(self.settingsitem) 34 | #Setup Button 35 | self.setupdeviceitem = Gtk.MenuItem("Setup Device") 36 | self.setupdeviceitem.connect("activate", self.setupdevice) 37 | self.setupdeviceitem.show() 38 | self.menu.append(self.setupdeviceitem) 39 | 40 | def update(self): 41 | try: 42 | jsonstr = self.dbusclient.getStats() 43 | except Exception: 44 | jsonstr = "{}" 45 | data = json.loads(jsonstr) 46 | 47 | if (not data.has_key('phones')): 48 | return 49 | devices = data['phones'] 50 | 51 | for device in devices: 52 | uuid = device['uuid'] 53 | if (self.devicelist.has_key(uuid)): 54 | self.devicelist[uuid].update(device) 55 | else: 56 | newdevice = DeviceMenuBundle(self, device) 57 | self.devicelist[uuid] = newdevice 58 | 59 | def notificationhandler(self): 60 | notification = self.dbusclient.getNotifications().split('::') 61 | uuid = notification[0] 62 | text = notification[1] 63 | 64 | if (self.devicelist.has_key(uuid)): 65 | self.devicelist[uuid].addnotification(text) 66 | else: 67 | self.update() 68 | self.devicelist[uuid].addnotification(text) 69 | 70 | 71 | def handler_menu_exit(self, evt): 72 | Gtk.main_quit() 73 | 74 | def compose(self, evt, ip, port): 75 | self.dbusclient.compose(ip, port) 76 | 77 | def ping(self, evt, ip, port): 78 | self.dbusclient.ping(ip, port) 79 | 80 | def sendfile(self, evt, ip, port): 81 | self.dbusclient.send_file(ip, port) 82 | 83 | def showsettings(self, evt): 84 | self.dbusclient.show_settings() 85 | 86 | def setupdevice(self, evt): 87 | self.dbusclient.setup_device() 88 | 89 | def main(self): 90 | self.dbusclient.run() 91 | self.update() 92 | Gtk.main() 93 | 94 | class DeviceMenuBundle(): 95 | def __init__(self, indicator, data): 96 | self.indicator = indicator 97 | 98 | self.statsitem = Gtk.MenuItem("") 99 | self.statsitem.show() 100 | self.actionmenu = Gtk.Menu() 101 | self.statsitem.set_submenu(self.actionmenu) 102 | self.indicator.menu.insert(self.statsitem, 0) 103 | self.composeitem = None 104 | 105 | #Actions 106 | if (data['canmessage']): 107 | self.composeitem = Gtk.MenuItem("Compose Message ...") 108 | self.composeitem.connect("activate", self.indicator.compose, 109 | data['ip'], data['controlport']) 110 | self.composeitem.show() 111 | self.actionmenu.append(self.composeitem) 112 | 113 | self.pingitem = Gtk.MenuItem("Ping") 114 | self.pingitem.connect("activate", self.indicator.ping, 115 | data['ip'], data['controlport']) 116 | self.pingitem.show() 117 | self.actionmenu.append(self.pingitem) 118 | 119 | self.sendfileitem = Gtk.MenuItem("Send File(s)") 120 | self.sendfileitem.connect("activate", self.indicator.sendfile, 121 | data['ip'], data['controlport']) 122 | self.sendfileitem.show() 123 | self.actionmenu.append(self.sendfileitem) 124 | 125 | #Notifications 126 | self.notificationlist = [] 127 | self.notificationitem = Gtk.MenuItem("Notifications") 128 | self.notificationsmenu = Gtk.Menu() 129 | self.notificationitem.set_submenu(self.notificationsmenu) 130 | self.notclearitem = Gtk.MenuItem("clear") 131 | self.notclearitem.connect("activate", self.clearnotifications) 132 | self.notclearitem.show() 133 | separator = Gtk.SeparatorMenuItem() 134 | separator.show() 135 | self.notificationsmenu.append(separator) 136 | self.notificationsmenu.append(self.notclearitem) 137 | 138 | separator = Gtk.SeparatorMenuItem() 139 | separator.show() 140 | self.indicator.menu.insert(self.notificationitem, 1) 141 | #Sep 142 | self.indicator.menu.insert(separator, 2) 143 | 144 | self.update(data) 145 | 146 | def update(self, data): 147 | name = data['name'] 148 | volume = str(data['volume']) 149 | battery = str(data['battery']) 150 | storage = str(data['storage']) 151 | missedsmstxt = "" 152 | missedcalltxt = "" 153 | if (data['missedsmscount'] > 0): 154 | missedsmstxt = "\nunread Messages "+ str(data['missedsmscount']) 155 | if (data['missedcallcount'] > 0): 156 | missedcalltxt = "\nmissed Calls "+ str(data['missedcallcount']) 157 | missedtxt = missedsmstxt+missedcalltxt 158 | 159 | text = (name+ 160 | "\nBat: "+battery+"% / Vol: "+volume+"% / Str: "+storage+"%"+ 161 | missedtxt) 162 | 163 | self.statsitem.set_label(text) 164 | if (data['canmessage'] and self.composeitem == None): 165 | self.composeitem = Gtk.MenuItem("Compose Message ...") 166 | self.composeitem.connect("activate", self.indicator.compose, 167 | data['ip'], data['controlport']) 168 | self.composeitem.show() 169 | self.actionmenu.append(self.composeitem) 170 | 171 | def addnotification(self, text): 172 | notificationitem = Gtk.MenuItem(text) 173 | notificationitem.show() 174 | self.notificationlist.append(notificationitem) 175 | self.notificationsmenu.insert(notificationitem, 0) 176 | self.notificationitem.show() 177 | 178 | def clearnotifications(self, widget): 179 | for item in self.notificationlist: 180 | self.notificationlist.remove(item) 181 | item.destroy() 182 | self.notificationitem.hide() 183 | 184 | # get pos child poc in menu 185 | def getmenuposition(self): 186 | pos = 0 187 | for child in self.indicator.menu.get_children(): 188 | if (child == self.statsitem): 189 | return pos 190 | pos = pos + 1 191 | 192 | 193 | class DbusClient(): 194 | def __init__(self, indicator): 195 | self.indicator = indicator 196 | bus = dbus.SessionBus() 197 | try: 198 | proxy = bus.get_object("net.screenfreeze.desktopconnector", 199 | "/net/screenfreeze/desktopconnector", 200 | True, True) 201 | self.iface = dbus.Interface(proxy, 'net.screenfreeze.desktopconnector') 202 | except Exception: 203 | print "dbus error" 204 | 205 | bus.add_signal_receiver(self.indicator.update, 206 | dbus_interface="net.screenfreeze.desktopconnector", 207 | signal_name="changed") 208 | bus.add_signal_receiver(self.indicator.notificationhandler, 209 | dbus_interface="net.screenfreeze.desktopconnector", 210 | signal_name="new_notification") 211 | 212 | def run(self): 213 | DBusGMainLoop(set_as_default=True) 214 | GObject.threads_init() 215 | dbus.mainloop.glib.threads_init() 216 | 217 | def getStats(self): 218 | return self.iface.stats() 219 | 220 | def getNotifications(self): 221 | return self.iface.notification() 222 | 223 | def compose(self, ip, port): 224 | host = ip + ":" + str(port) 225 | self.iface.compose_sms(host) 226 | 227 | def ping(self, ip, port): 228 | host = ip + ":" + str(port) 229 | self.iface.ping_device(host) 230 | 231 | def send_file(self, ip, port): 232 | host = ip + ":" + str(port) 233 | self.iface.send_file(host) 234 | 235 | def show_settings(self): 236 | self.iface.show_settings() 237 | 238 | def setup_device(self): 239 | self.iface.setup_device() 240 | 241 | 242 | if __name__ == "__main__": 243 | ind = IndicatorDeskCon() 244 | ind.main() 245 | -------------------------------------------------------------------------------- /unity/deskcon-indicator.desktop.in: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=DeskCon Indicator 3 | Comment=DeskCon Indicator 4 | Exec=deskcon-indicator 5 | Type=Application 6 | Terminal=false 7 | StartupNotify=false 8 | Categories= 9 | OnlyShowIn=GNOME;Unity; 10 | X-GNOME-Autostart-Delay=5 11 | X-GNOME-Autostart-Phase=Application 12 | X-GNOME-Autostart-Notify=true -------------------------------------------------------------------------------- /unity/indicator-deskcon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xml --------------------------------------------------------------------------------