├── COPYING ├── README ├── README-WINDOWS.txt ├── call-start-grey.png ├── call-start.png ├── callpoppy ├── config.sample └── gtkPopupNotify.py /COPYING: -------------------------------------------------------------------------------- 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: -------------------------------------------------------------------------------- 1 | callPopPy 2 | ========= 3 | 4 | callPopPy is a utility to monitor an Asterisk server's Manager 5 | Interface and provide popup notification of incoming calls. callPopPy 6 | looks up the incoming number in a SQLite database and includes the 7 | caller's name in the popup notification if it is found. Separate 8 | utilities are available for managing this database. 9 | 10 | callPopPy can make use of pynotify on Gnome based Linux distros 11 | such as Ubuntu. Otherwise it will use Daniel Woodhouse's gtkPopupNotify 12 | (https://github.com/woodenbrick/gtkPopupNotify), which is included 13 | in the distribution. 14 | 15 | callPopPy is written by Chris Hastie, http://www.oak-wood.co.uk and 16 | is a fork of pyCalledMe by Olivier H. Beauchesne 17 | http://olihb.com/2010/08/08/incoming-call-popup-under-ubuntu-and-asterisk/ 18 | 19 | Requirements 20 | ============ 21 | 22 | callPopPy is a Python script. It requires Python 23 | (http://www.python.org) 24 | 25 | callPopPy uses the starPy library to interact with Asterisk. Grab that 26 | from http://www.vrplumber.com/programming/starpy/ 27 | 28 | Other requirements will probably be present on a modernish Linux system. 29 | Windows users should refer to README-WINDOWS.txt. Other requirements 30 | include: 31 | 32 | pysqlite2 33 | twisted.internet 34 | zope.interface 35 | gobject 36 | gtk2 37 | 38 | 39 | 40 | Installation 41 | ============ 42 | 43 | Unpack the archive to a suitable location. 44 | 45 | Create the directory /.callpoppy 46 | On Linux/Unix based systems 47 | 48 | mkdir ~/.callpoppy 49 | 50 | On Windows, the directory should be somewhere like 51 | c:\Documents and Settings\\.callpoppy 52 | 53 | Copy config.sample into this directory, edit it and rename it to 54 | config, ie you should now have a file at 55 | 56 | /.callpoppy/config 57 | 58 | If you're not sure where it should be, just run callPopPy anyway and 59 | the resulting error message should help you. 60 | 61 | Create a SQLite database at /.callpoppy/callpoppy.db (see 62 | later). 63 | 64 | Now run callpoppy. From the directory to which you unpacked it: 65 | 66 | python callpoppy 67 | 68 | On Unix like systems you can run it by calling it directly. From the 69 | directory in which it is 70 | 71 | ./callpoppy 72 | 73 | You may have to ensure the first line of the script points to your 74 | python binary, and ensure that the script is executable: 75 | 76 | chmod 755 callpoppy 77 | 78 | Once you're sure that it's all working you'll probably want to set it 79 | up to start when you login or start your computer. How you do this will 80 | depend on your operating system. 81 | 82 | Configuration 83 | ============= 84 | For a minimal configuration you will need to provide information about 85 | logging into the Asterisk server in the [Asterisk] section of the 86 | config file. All values in this section are required, expcept for port, 87 | which defaults to 5038. 88 | 89 | You will also need to configure which extension(s) you wish to monitor. 90 | You can monitor multiple devices for incoming calls. The section 91 | [Extensions] consists of key: value pairs of devices. The key is an 92 | Asterisk channel / device, the value is an arbitary friendly name that 93 | will be used in the popup. For example 94 | 95 | [Extensions] 96 | SIP/john: John 97 | 98 | will monitor the channel SIP/john for incoming calls and result in 99 | a popup titled "Incoming call for John" when it detects one. 100 | 101 | Database 102 | ======== 103 | callPopPy expects to find a SQLite database at 104 | /.callpoppy/callpoppy.db. Other utilities should 105 | maintain this database, such as Squalit 106 | (http://www.oak-wood.co.uk/callpopy/squalit). 107 | 108 | The database must contains at least a table named 'numbers'. 109 | 110 | This table should contain at least a field 'tel' and a field 'name'. 111 | Duplicates should not be allowed in 'tel'. A suggested schema is: 112 | 113 | CREATE TABLE numbers (id INTEGER PRIMARY KEY, tel VARCHAR(20) UNIQUE, name VARCHAR(255)) 114 | 115 | The 'tel' field should contain the phone number, with all punctuation 116 | (hyphens, spaces, periods, brackets) stripped. callPopPy checks against 117 | only the last 10 digits of this number. The number of digits is 118 | configurable (in the [Database] section of config, the 'digits' key), 119 | but in the UK at least, 10 seems a good figure. 120 | 121 | The reason for using only the last 10 digits is to get around 122 | inconsistencies in the way in which different providers and trunks 123 | report calling numbers, some with country codes, some without, some 124 | with dial prefixes. For example, the UK number 01926 410410 may appear 125 | as any of 126 | 127 | 01926410410 128 | 00441926410410 129 | +441926410410 130 | 901926410410 131 | 132 | What is consistent is that the last ten digits are always 133 | 1926410410 134 | 135 | callPopPy does not mind if the database contains additional tables, 136 | or if the table 'numbers' contains additional fields. 137 | 138 | A Thunderbird extension, Squalit, is available that can create and 139 | maintain a suitable database from Thunderbird's address book. 140 | http://www.oak-wood.co.uk/callpopy/squalit -------------------------------------------------------------------------------- /README-WINDOWS.txt: -------------------------------------------------------------------------------- 1 | Using callPopPy on Windows 2 | ========================== 3 | 4 | This information is additional to that in README - read that too! 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6 | 7 | callPopPy is a Python script and requires the Python interpreter to 8 | run. Windows does not come with Python installed by default. Python 9 | can be downloaded from 10 | 11 | http://www.python.org/getit/windows/ 12 | 13 | You should use the latest version in the 2.7 branch. Do not use 14 | version 3 as some of the libraries that callPopPy needs do not yet 15 | work under version 3. 16 | 17 | Dependencies 18 | ============ 19 | 20 | callPopPy depends on a number of third party libraries. These are 21 | brief notes on what you'll need and where to find them: 22 | 23 | twisted.internet 24 | ---------------- 25 | 26 | The version of twisted.internet appropriate to your version of 27 | Python can be grabbed as either an .msi or an .exe installer from 28 | 29 | http://twistedmatrix.com/trac/wiki/Downloads 30 | 31 | Just run the installer 32 | 33 | zope.interface 34 | -------------- 35 | 36 | twisted itself depends on zope.interface, which you'll find at 37 | 38 | http://pypi.python.org/pypi/zope.interface 39 | 40 | zope is distributed as an 'egg' file. The easiest way to install this 41 | is to grab setuptools from 42 | 43 | http://pypi.python.org/pypi/setuptools 44 | 45 | which comes as a .exe installer. Run the installer. Assuming that your 46 | Python installation is at c:\Python27 this will install a file at 47 | c:\Python27\Scripts\easy_install.exe 48 | 49 | Drag and drop the '.egg' file on to this and zope should be installed. 50 | 51 | starPy 52 | ------ 53 | 54 | Grab the source from 55 | 56 | http://www.vrplumber.com/programming/starpy/ 57 | 58 | and unpack. From a command prompt go into the directory you unpacked it 59 | to and run 60 | 61 | > c:\Python27\python setup.py install 62 | 63 | pygtk 64 | ----- 65 | 66 | pygtk can be found at http://www.pygtk.org/ 67 | 68 | An 'all-in-one' installer is available as a .msi, containing several 69 | needed libraries. Grab this and run it. 70 | 71 | pysqlite 72 | -------- 73 | 74 | This is available as a .exe installer from 75 | http://pypi.python.org/pypi/pysqlite/ 76 | 77 | Grab the installer and run it. 78 | 79 | Running callPopPy 80 | ================= 81 | 82 | Initially you should try running callPopPy from a command prompt. cd 83 | into the directory you have unpacked it too and run something like 84 | 85 | > c:\Python27\python callpoppy 86 | 87 | This way you'll see any messages about errors. Once you're sure it's 88 | all working you may want to rename the file to callpoppy.pyw. You can 89 | then run it by double clicking on it. You can also create a shortcut 90 | in your startup folder to cause callPopPy to run at login. -------------------------------------------------------------------------------- /call-start-grey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tipichris/callPopPy/f260584e898a129500a776b87e472e9287a61724/call-start-grey.png -------------------------------------------------------------------------------- /call-start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tipichris/callPopPy/f260584e898a129500a776b87e472e9287a61724/call-start.png -------------------------------------------------------------------------------- /callpoppy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*-coding: utf-8 -*- 3 | """ 4 | Monitor an Asterisk Manager Interface and provide popup notification of 5 | incoming calls. 6 | 7 | callPopPy will attempt to look up the incoming number in a SQLite database 8 | and notify the name associated with the caller. Maintaining the SQLite 9 | database is a job for something else - a Thunderbird extension, Squalit, 10 | exists to do this from a Thunderbird address book. 11 | 12 | Copyright 2011 - 2019 Chris Hastie 13 | 14 | Contains code originally released as pyCalledMe by Olivier H. Beauchesne 15 | and Copyright 2009 Olivier H. Beauchesne 16 | http://olihb.com/2010/08/08/incoming-call-popup-under-ubuntu-and-asterisk/ 17 | 18 | This program is free software: you can redistribute it and/or modify 19 | it under the terms of the GNU General Public License as published by 20 | the Free Software Foundation, either version 3 of the License, or 21 | (at your option) any later version. 22 | 23 | This program is distributed in the hope that it will be useful, 24 | but WITHOUT ANY WARRANTY; without even the implied warranty of 25 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 | GNU General Public License for more details. 27 | 28 | You should have received a copy of the GNU General Public License 29 | along with this program. If not, see . 30 | """ 31 | 32 | __version_info__ = ('0', '2', '1') 33 | __version__ = '.'.join(__version_info__) 34 | 35 | 36 | from twisted.internet import gtk2reactor 37 | gtk2reactor.install(True) 38 | 39 | from twisted.internet import reactor, defer 40 | from twisted.internet.protocol import ReconnectingClientFactory 41 | from starpy.manager import AMIProtocol 42 | from twisted.internet import task 43 | import logging 44 | import logging.handlers 45 | import sys 46 | import os 47 | import os.path 48 | import re 49 | try: 50 | from sqlite3 import dbapi2 as sqlite # python 2.5 51 | except: 52 | try: 53 | from pysqlite2 import dbapi2 as sqlite 54 | except: 55 | print 'This program requires pysqlite2\n',\ 56 | 'http://initd.org/tracker/pysqlite/' 57 | sys.exit(1) 58 | import ConfigParser 59 | 60 | import gtk 61 | 62 | hasGnome = True 63 | try: 64 | import gnome.ui 65 | except: 66 | hasGnome = False 67 | 68 | class cpStatusIcon(): 69 | def __init__(self, iconpath): 70 | self.iconpath = iconpath 71 | self.tray = gtk.StatusIcon() 72 | self.tray.set_from_file(os.path.join(self.iconpath, 'call-start-grey.png')) 73 | self.tray.set_visible(True) 74 | self.tray.connect('popup-menu', self.on_right_click) 75 | self.tray.set_tooltip(appname + "\nWaiting to connect...") 76 | 77 | 78 | def on_right_click(self, icon, event_button, event_time): 79 | self.make_menu(event_button, event_time) 80 | 81 | def make_menu(self, event_button, event_time): 82 | menu = gtk.Menu() 83 | 84 | # show about dialog 85 | about = gtk.MenuItem("About") 86 | about.show() 87 | menu.append(about) 88 | about.connect('activate', self.show_about_dialog) 89 | 90 | # add quit item 91 | quit = gtk.MenuItem("Quit") 92 | quit.show() 93 | menu.append(quit) 94 | quit.connect('activate', killapp) 95 | 96 | menu.popup(None, None, gtk.status_icon_position_menu, 97 | event_button, event_time, self.tray) 98 | 99 | # This seems needed to run in a thread 100 | def __call__(self): 101 | return True 102 | 103 | def show_about_dialog(self, widget): 104 | self.about_dialog = gtk.AboutDialog() 105 | self.about_dialog.set_destroy_with_parent (True) 106 | self.about_dialog.set_icon_name (appname) 107 | self.about_dialog.set_name(appname) 108 | self.about_dialog.set_version(__version__) 109 | self.about_dialog.set_copyright("(C) 2011 - 2019 Chris Hastie") 110 | license = """This program is free software: you can redistribute it and/or modify 111 | it under the terms of the GNU General Public License as published by 112 | the Free Software Foundation, either version 3 of the License, or 113 | (at your option) any later version. 114 | 115 | This program is distributed in the hope that it will be useful, 116 | but WITHOUT ANY WARRANTY; without even the implied warranty of 117 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 118 | GNU General Public License for more details. 119 | 120 | You should have received a copy of the GNU General Public License 121 | along with this program. If not, see http://www.gnu.org/licenses/""" 122 | self.about_dialog.set_license(license) 123 | self.about_dialog.set_website('http://www.oak-wood.co.uk/oss/callpoppy') 124 | self.about_dialog.set_comments(("Pop up who's calling an Asterisk PBX")) 125 | self.about_dialog.set_authors(['Chris Hastie ']) 126 | self.about_dialog.run() 127 | self.about_dialog.destroy() 128 | 129 | def remove(self): 130 | self.tray.set_visible(False) 131 | 132 | def changeToolTip(self, tooltip): 133 | log.debug("Updating tooltip to: '" + tooltip + "'") 134 | self.tray.set_tooltip(tooltip) 135 | 136 | def changeIcon(self, icon): 137 | log.debug("Changing icon to: '" + icon + "'") 138 | self.tray.set_from_file(os.path.join(self.iconpath, icon)) 139 | 140 | class CallPopFactory(ReconnectingClientFactory): 141 | """ Factory for connection. Subclassed from ReconnectingClientFactory 142 | to take advantage of backing off reconnection times 143 | """ 144 | protocol = AMIProtocol 145 | connect_callback=None 146 | 147 | def __init__(self, username, secret, server='localhost', port=5038, statusicon=None): 148 | self.username = username 149 | self.secret = secret 150 | self.server = server 151 | self.port = port 152 | self.statusicon = statusicon 153 | 154 | def login( self, ip='localhost', port=5038, timeout=5 ): 155 | self.loginDefer = defer.Deferred() 156 | reactor.connectTCP(ip,port,self, timeout=timeout) 157 | return self.loginDefer 158 | 159 | def clientConnectionFailed(self, connector, reason): 160 | log.warning( 'Connection failed. Reason: %s', reason) 161 | self.statusicon.changeToolTip(appname + ": Connection failed") 162 | self.statusicon.changeIcon('call-start-grey.png') 163 | ReconnectingClientFactory.clientConnectionFailed(self, self, reason) 164 | 165 | def clientConnectionLost(self, connector, reason): 166 | log.warning( 'Lost connection. Reason: %s', reason) 167 | self.statusicon.changeToolTip(appname + ": Connection lost") 168 | self.statusicon.changeIcon('call-start-grey.png') 169 | ReconnectingClientFactory.clientConnectionLost(self, self, reason) 170 | 171 | def connect(self): 172 | log.info("Connecting to Asterisk at %s:%d", self.server, self.port) 173 | df = self.login(self.server, self.port) 174 | if self.connect_callback!=None: 175 | df.addCallback(self.connect_callback) 176 | 177 | 178 | 179 | class Popup: 180 | """ Abstraction layer to handle popup notifications. Provides a consistent 181 | API whether using pynotify or gtkPopupNotify 182 | """ 183 | 184 | def __init__(self, usePyNotify, params): 185 | self.timeout = params['timeout'] 186 | self.usePyNotify = usePyNotify 187 | self.imagepath = params['imagepath'] 188 | 189 | if self.usePyNotify: 190 | try: 191 | log.debug("Attempting to use pynotify") 192 | import pynotify 193 | self.notifier = pynotify 194 | self.notifier.init(params['appname']) 195 | self.caps = self.notifier.get_server_caps() 196 | except: 197 | log.warning("Unable to import pynotify. Using gtkPopupNotify instead") 198 | self.usePyNotify = False 199 | 200 | if not self.usePyNotify: 201 | log.debug("Importing gtkPopupNotify") 202 | import gtkPopupNotify, gtk 203 | for k in params.keys(): 204 | log.debug("Popup param '%s': %s", k, params[k]) 205 | self.notifier=gtkPopupNotify.NotificationStack(timeout=self.timeout) 206 | self.notifier.show_timeout = False 207 | self.notifier.edge_offset_x = params['xoff'] 208 | self.notifier.edge_offset_y = params['yoff'] 209 | self.notifier.corner = params['left'],params['top'] 210 | self.notifier.max_popups = 1 211 | self.notifier.bg_color = gtk.gdk.Color(params['bg']) 212 | self.notifier.fg_color = gtk.gdk.Color(params['fg']) 213 | self.notifier.fontdesc = ("Sans Bold 10", "Sans 10", "Sans 10") 214 | 215 | def escape(self, text): 216 | text = text.replace('&', '&') 217 | text = text.replace('<', '<') 218 | text = text.replace('>', '>') 219 | return text 220 | 221 | def show(self, title, message): 222 | log.debug("Popup.show called") 223 | 224 | 225 | if self.usePyNotify: 226 | log.debug("Notifying with pynotifier (image at %s)", self.imagepath) 227 | if self.caps and 'body-markup' in self.caps: 228 | title = self.escape(title) 229 | message = self.escape(message) 230 | n=self.notifier.Notification(title,message,self.imagepath) 231 | n.set_timeout(self.timeout * 1000) 232 | n.show() 233 | else: 234 | log.debug("Notifying with gtkPopupNotify (image at %s)", self.imagepath) 235 | self.notifier.new_popup(self.escape(title), self.escape(message), self.imagepath) 236 | return True 237 | 238 | class CallPopHandler: 239 | """ Main application handler """ 240 | 241 | pingtimeout = 5 242 | pinginterval = 120 243 | dbpath = os.path.expanduser('~/.callpoppy/callpoppy.db') 244 | lookupdigits = 10 245 | 246 | def __init__(self, extensions, popup, statusicon): 247 | # set up connection to sqllite 248 | self.sqlconnection = sqlite.connect(self.dbpath) 249 | self.extensions = extensions 250 | self.popup = popup 251 | self.statusicon = statusicon 252 | for k in self.extensions.keys(): 253 | log.debug("Extension configured: '%s': %s", k, self.extensions[k]['name']) 254 | 255 | def onDial(self, protocol, event): 256 | log.debug("Got event %s", event) 257 | # check for both 'destchannel' and 'destination'. Depends on Asterisk version 258 | destination = None 259 | if 'destchannel' in event: 260 | destination=event['destchannel'].lower() 261 | elif 'destination' in event: 262 | destination=event['destination'].lower() 263 | if destination is not None: 264 | for s in self.extensions.keys(): 265 | log.debug("Checking destination %s against extension %s", destination, s.lower()) 266 | if self.extensions[s]['re'].match(destination): 267 | log.debug("Processing call for %s", s) 268 | if 'calleridnum' in event: 269 | cid=event['calleridnum'] 270 | else : 271 | # earlier versions of Asterisk used callerid rather than calleridnum 272 | cid = event['callerid'] 273 | cidname=self.lookupnumber(cid,event['calleridname']) 274 | extname=self.extensions[s]['name'] 275 | log.info("Call from %s (%s) for %s", cidname, cid, extname) 276 | self.popup.show("Incoming call for "+extname, cidname + "\n"+cid) 277 | 278 | def lookupnumber(self, cidnum, out): 279 | idx = cidnum[-self.lookupdigits:] 280 | if len(cidnum) > self.lookupdigits: 281 | idx = '%' + idx 282 | log.debug("Looking up number LIKE '%s'", idx) 283 | try: 284 | row = self.sqlconnection.execute('SELECT name FROM numbers WHERE tel LIKE ?', (idx,)).fetchone() 285 | except Exception as e: 286 | log.warning("Error searching for number: %s", e) 287 | return out 288 | if row: 289 | out = row[0] 290 | return out 291 | 292 | def onLogin(self, protocol): 293 | log.debug('Resetting reconnection delay') 294 | self.statusicon.changeToolTip(appname + "\nMonitoring extensions:\n" + ', '.join(self.extensions.keys())) 295 | self.statusicon.changeIcon('call-start.png') 296 | protocol.factory.resetDelay() 297 | # change of event name from 'Dial' to 'DialBegin' 298 | df = protocol.registerEvent("DialBegin",self.onDial) 299 | dfold = protocol.registerEvent("Dial",self.onDial) 300 | self.timeouttask = task.LoopingCall(self.pinglink, protocol) 301 | self.timeouttask.start(self.pinginterval); 302 | #return df 303 | 304 | def pinglink(self, protocol): 305 | def ontimeout(): 306 | log.debug("Unexpected response or timeout waiting. Closing connection") 307 | self.statusicon.changeToolTip(appname + ": Connection lost") 308 | self.statusicon.changeIcon('call-start-grey.png') 309 | if dc.active(): 310 | dc.cancel() 311 | self.timeouttask.stop() 312 | protocol.transport.loseConnection() 313 | 314 | def canceltimeout(*val): 315 | if dc.active(): 316 | dc.cancel() 317 | log.debug("Received pong. Cancelling timeout") 318 | log.debug("%s", val) 319 | 320 | def success(val): 321 | pass 322 | 323 | log.debug("Pinging server - setting timeout") 324 | dc = reactor.callLater(self.pingtimeout,ontimeout) 325 | df = protocol.ping() 326 | df.addBoth(canceltimeout) 327 | df.addCallback(success) 328 | df.addErrback(ontimeout) 329 | 330 | def main(): 331 | # initialise our notifier 332 | popupparams = conf['popupparams'] 333 | popupparams['imagepath'] = cpicon 334 | popup = Popup(conf['usePyNotify'], conf['popupparams']) 335 | # initialis our handler, passing the notifier to it 336 | handler = CallPopHandler(conf['extensions'], popup, cpsi) 337 | # some handler configuration 338 | handler.dbpath = conf['dbfile'] 339 | handler.lookupdigits = conf['lookupdigits'] 340 | # initialise our factory 341 | factory = CallPopFactory(conf['username'], conf['secret'], conf['server'], conf['port'], cpsi) 342 | 343 | factory.connect_callback=handler.onLogin 344 | factory.maxDelay = 600 345 | factory.connect() 346 | 347 | 348 | def killapp(*args): 349 | reactor.stop() 350 | return True 351 | 352 | def cleanup(): 353 | log.info("Cleaning up...") 354 | if cpsi: 355 | cpsi.remove() 356 | if hasattr(cpsi, 'about_dialog'): 357 | cpsi.about_dialog.destroy() 358 | 359 | 360 | if __name__ == '__main__': 361 | 362 | appname = 'CallPoppy' 363 | 364 | # Keep our logs secret 365 | os.umask(0077); 366 | 367 | config = ConfigParser.ConfigParser({ 368 | 'port': '5038', 369 | 'uselibnotify': 'True', 370 | 'background': '#171717', 371 | 'foreground': '#bbbbbb', 372 | 'top': "0", 373 | 'left': "0", 374 | 'x-offset': "0", 375 | 'y-offset': "0", 376 | 'timeout': "6", 377 | 'loglevel': "4", 378 | 'logfile': os.path.expanduser('~/.callpoppy/callpoppy.log'), 379 | 'dbfile': os.path.expanduser('~/.callpoppy/callpoppy.db'), 380 | 'digits': "10" 381 | }) 382 | 383 | config.optionxform = str 384 | conffile = os.path.expanduser('~/.callpoppy/config') 385 | conf = {} 386 | try: 387 | config.read(conffile) 388 | 389 | conf['server'] = config.get('Asterisk', 'server') 390 | conf['port'] = config.getint('Asterisk', 'port') 391 | conf['username'] = config.get('Asterisk', 'username') 392 | conf['secret'] = config.get('Asterisk', 'secret') 393 | 394 | conf['loglevel'] = config.getint('Logging', 'loglevel') 395 | conf['logfile'] = config.get('Logging', 'logfile') 396 | 397 | conf['dbfile'] = config.get('Database', 'dbfile') 398 | conf['lookupdigits'] = config.getint('Database', 'digits') 399 | 400 | conf['popupparams'] = {} 401 | conf['popupparams']['bg'] = config.get('Popup', 'background') 402 | conf['popupparams']['fg'] = config.get('Popup', 'foreground') 403 | conf['popupparams']['top'] = config.getboolean('Popup', 'top') 404 | conf['popupparams']['left'] = config.getboolean('Popup', 'left') 405 | conf['popupparams']['xoff'] = config.getint('Popup', 'x-offset') 406 | conf['popupparams']['yoff'] = config.getint('Popup', 'y-offset') 407 | conf['popupparams']['timeout'] = config.getint('Popup', 'timeout') 408 | conf['popupparams']['appname'] = appname 409 | 410 | conf['usePyNotify'] = config.getboolean('Popup', 'uselibnotify') 411 | 412 | ext = config.options('Extensions') 413 | 414 | conf['extensions'] = {} 415 | 416 | for s in ext: 417 | # annoyingly, ConfigParser.options returns all the defaults, so 418 | # we need to filter them out 419 | if s not in config.defaults().keys(): 420 | conf['extensions'][s] = {} 421 | conf['extensions'][s]['name'] = config.get('Extensions', s) 422 | conf['extensions'][s]['re'] = re.compile('^' + s + r"(-\w+)?$", re.IGNORECASE) 423 | 424 | except ConfigParser.Error as conferr: 425 | sys.exit(appname + " could not read the configuration file '" + conffile +"':\n" + conferr.__str__()) 426 | 427 | # Set up logging 428 | log = logging.getLogger(appname) 429 | loglevels = [logging.CRITICAL, logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG] 430 | loglevel = loglevels[conf['loglevel'] - 1] 431 | log.setLevel(loglevel) 432 | 433 | # create log handler and set level. This creates a rotating log file 434 | lh = logging.handlers.RotatingFileHandler(conf['logfile'], 'a', 102400, 3) 435 | lh.setLevel(loglevel) 436 | 437 | logformat = logging.Formatter('%(asctime)s %(name)s: %(levelname)s %(message)s') 438 | lh.setFormatter(logformat) 439 | 440 | log.addHandler(lh) 441 | 442 | # set up logging from starpy 443 | logging.getLogger('AMI').setLevel(loglevel) 444 | logging.getLogger('AMI').addHandler(lh) 445 | 446 | log.info("Starting %s version %s", appname, __version__) 447 | log.debug("Configuration read from %s", conffile) 448 | log.debug("Configuration: %s", conf) 449 | 450 | # getting the current path depends on whether we're a compiled 451 | # binary, or a script being run through the interpreter 452 | # http://stackoverflow.com/questions/1511461/py2exe-and-the-file-system 453 | frozen = getattr(sys, 'frozen', '') 454 | if not frozen: 455 | # not frozen: in regular python interpreter 456 | approot = sys.path[0] 457 | elif frozen in ('dll', 'console_exe', 'windows_exe'): 458 | # py2exe: 459 | approot = os.path.dirname(sys.executable) 460 | elif frozen in ('macosx_app',): 461 | # py2app: 462 | # Notes on how to find stuff on MAC, by an expert (Bob Ippolito): 463 | # http://mail.python.org/pipermail/pythonmac-sig/2004-November/012121.html 464 | approot = os.environ['RESOURCEPATH'] 465 | else: 466 | approot = sys.path[0] 467 | 468 | cpicon=os.path.join(approot, 'call-start.png') 469 | 470 | # On Gnome, ensure the script exits when the user 471 | # logs out. 472 | if hasGnome: 473 | gnome.program_init (appname, "1.0") 474 | client = gnome.ui.master_client() 475 | client.connect("save-yourself", killapp) 476 | 477 | #reactor.callInThread(cpStatusIcon(cpicon)) 478 | cpsi = cpStatusIcon(approot) 479 | reactor.callWhenRunning(main) 480 | reactor.addSystemEventTrigger('before', 'shutdown', cleanup) 481 | reactor.run() 482 | -------------------------------------------------------------------------------- /config.sample: -------------------------------------------------------------------------------- 1 | ##################################################################### 2 | # This is the configuration file for callpoppy. It should be copied 3 | # to /.callpoppy/config 4 | # 5 | # Lines beginning # or ; are comments and are ignored 6 | # 7 | # All SECTIONS are required; Most values are optional and sensible 8 | # defaults will be used if not specified. The exception are values in 9 | # the [Asterisk] section, and [Extensions] must contain at least one 10 | # key: value pair 11 | ##################################################################### 12 | 13 | ##################################################################### 14 | ## This section configures the connection to the Asterisk server. 15 | ## All values except port are required. port defaults to 5038 if 16 | ## not specified. 17 | 18 | [Asterisk] 19 | 20 | # Server IP address or fully qualified domain name 21 | server: 192.168.1.1 22 | 23 | # Port to connect to. Defaults to 5038 24 | port: 5038 25 | 26 | # Username for the Asterisk Manager Interface (AMI) 27 | username: callpoppy 28 | 29 | # Secret (password) for AMI 30 | secret: topsecret 31 | 32 | ##################################################################### 33 | ## This section configures the extensions to monitor incoming calls 34 | ## for. It must consist of one or more key: value pairs where the 35 | ## key is the channel to monitor and the value is is human readable 36 | ## name that will be used to identify which channel the call is for 37 | ## in the popup. 38 | ## eg 39 | ## SIP/office: Office 40 | ## will cause a popup for calls to SIP/office to be titled 41 | ## "Incoming call for Office" 42 | 43 | [Extensions] 44 | 45 | ;SIP/home: Home 46 | ;SIP/office: Office 47 | ;IAX2/phil: Phil's phone 48 | 49 | ##################################################################### 50 | ## This section configures the appearance of the popup. All values are 51 | ## optional, but the section must exist 52 | 53 | [Popup] 54 | 55 | # The period, in seconds, after which the pop will close if not closed 56 | # earlier by the user. Default 6. Note on more recent Gnome systems 57 | # using Notify-OSD and pynotify, this is ignored. eg 58 | ;timeout: 10 59 | 60 | # On Gnome based Linux distros, such as Ubuntu, callPopPy will use 61 | # libnotify/Notify-OSD to provide the popups. This has tighter integration 62 | # with the operating system and uses less memory, but is less flexible. 63 | # To force callPopPy to use gtkPopupNotify even if libnotify is 64 | # available, set this to 'no' 65 | # Note that if libnotify is used, the rest of the settings in this section 66 | # have no effect. 67 | ;uselibnotify: no 68 | 69 | # If set to 1 the popup is aligned to the top of the screen. If set 70 | # to 0, it is aligned to the bottom. eg 71 | ;top: 1 72 | 73 | # If set to 1 the popup is aligned to the left of the screen. If set 74 | # to 0, it is aligned to the right. eg 75 | ;left: 1 76 | 77 | # The offset from the left or right edge, in pixels. Default is 0 78 | # eg 79 | ;x-offset: 50 80 | 81 | # The offset from the top or bottom edge, in pixels. Default is 0 82 | # eg 83 | ;y-offset: 50 84 | 85 | # The popup background colour. Given as an HTML style hex code. Default 86 | # is #171717. eg 87 | ;background: #bb0000 88 | 89 | # The popup foreground colour. Given as an HTML style hex code. Default 90 | # is #bbbbbb. eg 91 | ;foreground: #00bb00 92 | 93 | ##################################################################### 94 | ## This section configures logging. You can select which file to log 95 | ## to log to, and the level of detail. All values are optional, but 96 | ## the section must exist. 97 | 98 | [Logging] 99 | 100 | # loglevel is a value between 1 and 5, mapped as follows: 101 | # 1 CRITICAL 102 | # 2 ERROR 103 | # 3 WARNING 104 | # 4 INFO 105 | # 5 DEBUG 106 | # Default is 4. eg 107 | ;loglevel: 5 108 | 109 | # logfile is the file to log to. Default is 110 | # /.callpoppy/callpoppy.log 111 | # eg 112 | ;logfile=/var/log/callpoppy.log 113 | 114 | ##################################################################### 115 | # This section configures the SQLite database used for looking up 116 | # numbers. All values are optional, but the section must exist 117 | 118 | [Database] 119 | 120 | # The path to the SQLite database. Default is 121 | # /.callpoppy/callpoppy.db 122 | # eg 123 | ;dbfile: /var/db/callpoppy.db 124 | 125 | # The number of digits contained in the lookup table. See README. 126 | # Default is 10, which works well for the UK. 127 | # eg 128 | ;digits: 10 129 | -------------------------------------------------------------------------------- /gtkPopupNotify.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | #gtkPopupNotify.py 5 | # 6 | # Copyright 2009 Daniel Woodhouse 7 | # modified by NickCis 2010 http://github.com/NickCis/gtkPopupNotify 8 | # Modifications: 9 | # Added: * Corner support (notifications can be displayed in all corners 10 | # * Use of gtk Stock items or pixbuf to render images in notifications 11 | # * Posibility of use fixed height 12 | # * Posibility of use image as background 13 | # * Not displaying over Windows taskbar(taken from emesene gpl v3) 14 | # * y separation. 15 | # * font description options 16 | # * Callbacks For left, middle and right click 17 | # 18 | #This program is free software: you can redistribute it and/or modify 19 | #it under the terms of the GNU Lesser General Public License as published by 20 | #the Free Software Foundation, either version 3 of the License, or 21 | #(at your option) any later version. 22 | # 23 | #This program is distributed in the hope that it will be useful, 24 | #but WITHOUT ANY WARRANTY; without even the implied warranty of 25 | #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 | #GNU Lesser General Public License for more details. 27 | # 28 | #You should have received a copy of the GNU Lesser General Public License 29 | #along with this program. If not, see . 30 | 31 | 32 | import os 33 | import gtk 34 | import pango 35 | import gobject 36 | 37 | # This code is used only on Windows to get the location on the taskbar 38 | # Taken from emesene Notifications (Gpl v3) 39 | taskbarOffsety = 0 40 | taskbarOffsetx = 0 41 | if os.name == "nt": 42 | import ctypes 43 | from ctypes.wintypes import RECT, DWORD 44 | user = ctypes.windll.user32 45 | MONITORINFOF_PRIMARY = 1 46 | HMONITOR = 1 47 | 48 | class MONITORINFO(ctypes.Structure): 49 | _fields_ = [ 50 | ('cbSize', DWORD), 51 | ('rcMonitor', RECT), 52 | ('rcWork', RECT), 53 | ('dwFlags', DWORD) 54 | ] 55 | 56 | taskbarSide = "bottom" 57 | taskbarOffset = 30 58 | info = MONITORINFO() 59 | info.cbSize = ctypes.sizeof(info) 60 | info.dwFlags = MONITORINFOF_PRIMARY 61 | user.GetMonitorInfoW(HMONITOR, ctypes.byref(info)) 62 | if info.rcMonitor.bottom != info.rcWork.bottom: 63 | taskbarOffsety = info.rcMonitor.bottom - info.rcWork.bottom 64 | if info.rcMonitor.top != info.rcWork.top: 65 | taskbarSide = "top" 66 | taskbarOffsety = info.rcWork.top - info.rcMonitor.top 67 | if info.rcMonitor.left != info.rcWork.left: 68 | taskbarSide = "left" 69 | taskbarOffsetx = info.rcWork.left - info.rcMonitor.left 70 | if info.rcMonitor.right != info.rcWork.right: 71 | taskbarSide = "right" 72 | taskbarOffsetx = info.rcMonitor.right - info.rcWork.right 73 | 74 | class NotificationStack(): 75 | def __init__(self, size_x=300, size_y=-1, timeout=5, corner=(False, False), sep_y=0): 76 | """ 77 | Create a new notification stack. The recommended way to create Popup instances. 78 | Parameters: 79 | `size_x` : The desired width of the notifications. 80 | `size_y` : The desired minimum height of the notifications. If it isn't set, 81 | or setted to None, the size will automatically adjust 82 | `timeout` : Popup instance will disappear after this timeout if there 83 | is no human intervention. This can be overridden temporarily by passing 84 | a new timout to the new_popup method. 85 | `coner` : 2 Value tuple: (true if left, True if top) 86 | `sep_y` : y distance to separate notifications from each other 87 | """ 88 | self.size_x = size_x 89 | self.size_y = -1 if (size_y == None) else size_y 90 | self.timeout = timeout 91 | self.corner = corner 92 | self.sep_y = sep_y 93 | """ 94 | Other parameters: 95 | These will take effect for every popup created after the change. 96 | `edge_offset_y` : distance from the bottom of the screen and 97 | the bottom of the stack. 98 | `edge_offset_x` : distance from the right edge of the screen and 99 | the side of the stack. 100 | `max_popups` : The maximum number of popups to be shown on the screen 101 | at one time. 102 | `bg_color` : if None default is used (usually grey). set with a gtk.gdk.Color. 103 | `bg_pixmap` : Pixmap to use as background of notification. You can set a gtk.gdk.Pixmap 104 | or a path to a image. If none, the color background will be displayed. 105 | `bg_mask` : If a gtk.gdk.pixmap is specified under bg_pixmap, the mask of the pixmap has to be setted here. 106 | `fg_color` : if None default is used (usually black). set with a gtk.gdk.Color. 107 | `show_timeout` : if True, a countdown till destruction will be displayed. 108 | `close_but` : if True, the close button will be displayed. 109 | `fontdesc` : a 3 value Tuple containing the pango.FontDescriptions of the Header, message and counter 110 | (in that order). If a string is suplyed, it will be used for the 3 the same FontDescription. 111 | http://doc.stoq.com.br/devel/pygtk/class-pangofontdescription.html 112 | """ 113 | self.edge_offset_x = 0 114 | self.edge_offset_y = 0 115 | self.max_popups = 5 116 | self.fg_color = None 117 | self.bg_color = None 118 | self.bg_pixmap = None 119 | self.bg_mask = None 120 | self.show_timeout = False 121 | self.close_but = True 122 | self.fontdesc = ("Sans Bold 14", "Sans 12", "Sans 10") 123 | 124 | self._notify_stack = [] 125 | self._offset = 0 126 | 127 | 128 | def new_popup(self, title, message, image=None, leftCb=None, middleCb=None, rightCb=None): 129 | """Create a new Popup instance.""" 130 | if len(self._notify_stack) == self.max_popups: 131 | self._notify_stack[0].hide_notification() 132 | self._notify_stack.append(Popup(self, title, message, image, leftCb, middleCb, rightCb)) 133 | self._offset += self._notify_stack[-1].y 134 | 135 | def destroy_popup_cb(self, popup): 136 | self._notify_stack.remove(popup) 137 | #move popups down if required 138 | offset = 0 139 | for note in self._notify_stack: 140 | offset = note.reposition(offset, self) 141 | self._offset = offset 142 | 143 | 144 | 145 | 146 | class Popup(gtk.Window): 147 | def __init__(self, stack, title, message, image, leftCb, middleCb, rightCb): 148 | gtk.Window.__init__(self, type=gtk.WINDOW_POPUP) 149 | 150 | self.leftclickCB = leftCb 151 | self.middleclickCB = middleCb 152 | self.rightclickCB = rightCb 153 | 154 | self.set_size_request(stack.size_x, stack.size_y) 155 | self.set_decorated(False) 156 | self.set_deletable(False) 157 | self.set_property("skip-pager-hint", True) 158 | self.set_property("skip-taskbar-hint", True) 159 | self.connect("enter-notify-event", self.on_hover, True) 160 | self.connect("leave-notify-event", self.on_hover, False) 161 | self.set_opacity(0.2) 162 | self.destroy_cb = stack.destroy_popup_cb 163 | 164 | if type(stack.fontdesc) == tuple or type(stack.fontdesc) == list: 165 | fontH, fontM, fontC = stack.fontdesc 166 | else: 167 | fontH = fontM = fontC = stack.fontdesc 168 | 169 | main_box = gtk.VBox() 170 | header_box = gtk.HBox() 171 | self.header = gtk.Label() 172 | self.header.set_markup("%s" % title) 173 | self.header.set_padding(3, 3) 174 | self.header.set_alignment(0, 0) 175 | try: 176 | self.header.modify_font(pango.FontDescription(fontH)) 177 | except Exception, e: 178 | print e 179 | header_box.pack_start(self.header, True, True, 5) 180 | if stack.close_but: 181 | close_button = gtk.Image() 182 | 183 | close_button.set_from_stock(gtk.STOCK_CANCEL, gtk.ICON_SIZE_BUTTON) 184 | close_button.set_padding(3, 3) 185 | close_window = gtk.EventBox() 186 | close_window.set_visible_window(False) 187 | close_window.connect("button-press-event", self.hide_notification) 188 | close_window.add(close_button) 189 | header_box.pack_end(close_window, False, False) 190 | main_box.pack_start(header_box) 191 | 192 | body_box = gtk.HBox() 193 | if image is not None: 194 | self.image = gtk.Image() 195 | self.image.set_size_request(70, 70) 196 | self.image.set_alignment(0, 0) 197 | if image in gtk.stock_list_ids(): 198 | self.image.set_from_stock(image, gtk.ICON_SIZE_DIALOG) 199 | elif type(image) == gtk.gdk.Pixbuf: 200 | self.image.set_from_pixbuf(image) 201 | else: 202 | self.image.set_from_file(image) 203 | body_box.pack_start(self.image, False, False, 5) 204 | self.message = gtk.Label() 205 | self.message.set_property("wrap", True) 206 | self.message.set_size_request(stack.size_x - 90, -1) 207 | self.message.set_alignment(0, 0) 208 | self.message.set_padding(5, 10) 209 | self.message.set_markup(message) 210 | try: 211 | self.message.modify_font(pango.FontDescription(fontM)) 212 | except Exception, e: 213 | print e 214 | self.counter = gtk.Label() 215 | self.counter.set_alignment(1, 1) 216 | self.counter.set_padding(3, 3) 217 | try: 218 | self.counter.modify_font(pango.FontDescription(fontC)) 219 | except Exception, e: 220 | print e 221 | self.timeout = stack.timeout 222 | 223 | body_box.pack_start(self.message, True, False, 5) 224 | body_box.pack_end(self.counter, False, False, 5) 225 | main_box.pack_start(body_box) 226 | eventbox = gtk.EventBox() 227 | eventbox.set_property('visible-window', False) 228 | eventbox.set_events(gtk.gdk.BUTTON_PRESS_MASK) 229 | eventbox.connect("button_press_event", self.onClick) 230 | eventbox.add(main_box) 231 | self.add(eventbox) 232 | if stack.bg_pixmap is not None: 233 | if not type(stack.bg_pixmap) == gtk.gdk.Pixmap: 234 | stack.bg_pixmap, stack.bg_mask = gtk.gdk.pixbuf_new_from_file(stack.bg_pixmap).render_pixmap_and_mask() 235 | self.set_app_paintable(True) 236 | self.connect_after("realize", self.callbackrealize, stack.bg_pixmap, stack.bg_mask) 237 | elif stack.bg_color is not None: 238 | self.modify_bg(gtk.STATE_NORMAL, stack.bg_color) 239 | if stack.fg_color is not None: 240 | self.message.modify_fg(gtk.STATE_NORMAL, stack.fg_color) 241 | self.header.modify_fg(gtk.STATE_NORMAL, stack.fg_color) 242 | self.counter.modify_fg(gtk.STATE_NORMAL, stack.fg_color) 243 | self.show_timeout = stack.show_timeout 244 | self.hover = False 245 | self.show_all() 246 | self.x, self.y = self.size_request() 247 | #Not displaying over windows bar 248 | if os.name == 'nt': 249 | if stack.corner[0] and taskbarSide == "left": 250 | stack.edge_offset_x += taskbarOffsetx 251 | elif not stack.corner[0] and taskbarSide == 'right': 252 | stack.edge_offset_x += taskbarOffsetx 253 | if stack.corner[1] and taskbarSide == "top": 254 | stack.edge_offset_x += taskbarOffsety 255 | elif not stack.corner[1] and taskbarSide == 'bottom': 256 | stack.edge_offset_x += taskbarOffsety 257 | 258 | if stack.corner[0]: 259 | posx = stack.edge_offset_x 260 | else: 261 | posx = gtk.gdk.screen_width() - self.x - stack.edge_offset_x 262 | sep_y = 0 if (stack._offset == 0) else stack.sep_y 263 | self.y += sep_y 264 | if stack.corner[1]: 265 | posy = stack._offset + stack.edge_offset_y + sep_y 266 | else: 267 | posy = gtk.gdk.screen_height()- self.y - stack._offset - stack.edge_offset_y 268 | self.move(posx, posy) 269 | self.fade_in_timer = gobject.timeout_add(100, self.fade_in) 270 | 271 | 272 | 273 | def reposition(self, offset, stack): 274 | """Move the notification window down, when an older notification is removed""" 275 | if stack.corner[0]: 276 | posx = stack.edge_offset_x 277 | else: 278 | posx = gtk.gdk.screen_width() - self.x - stack.edge_offset_x 279 | if stack.corner[1]: 280 | posy = offset + stack.edge_offset_y 281 | new_offset = self.y + offset 282 | else: 283 | new_offset = self.y + offset 284 | posy = gtk.gdk.screen_height() - new_offset - stack.edge_offset_y + stack.sep_y 285 | self.move(posx, posy) 286 | return new_offset 287 | 288 | 289 | def fade_in(self): 290 | opacity = self.get_opacity() 291 | opacity += 0.15 292 | if opacity >= 1: 293 | self.wait_timer = gobject.timeout_add(1000, self.wait) 294 | return False 295 | self.set_opacity(opacity) 296 | return True 297 | 298 | def wait(self): 299 | if not self.hover: 300 | self.timeout -= 1 301 | if self.show_timeout: 302 | self.counter.set_markup(str("%s" % self.timeout)) 303 | if self.timeout == 0: 304 | self.fade_out_timer = gobject.timeout_add(100, self.fade_out) 305 | return False 306 | return True 307 | 308 | 309 | def fade_out(self): 310 | opacity = self.get_opacity() 311 | opacity -= 0.10 312 | if opacity <= 0: 313 | self.in_progress = False 314 | self.hide_notification() 315 | return False 316 | self.set_opacity(opacity) 317 | return True 318 | 319 | def on_hover(self, window, event, hover): 320 | """Starts/Stops the notification timer on a mouse in/out event""" 321 | self.hover = hover 322 | 323 | 324 | def hide_notification(self, *args): 325 | """Destroys the notification and tells the stack to move the 326 | remaining notification windows""" 327 | for timer in ("fade_in_timer", "fade_out_timer", "wait_timer"): 328 | if hasattr(self, timer): 329 | gobject.source_remove(getattr(self, timer)) 330 | self.destroy() 331 | self.destroy_cb(self) 332 | 333 | def callbackrealize(self, widget, pixmap, mask=False): 334 | #width, height = pixmap.get_size() 335 | #self.resize(width, height) 336 | if mask is not False: 337 | self.shape_combine_mask(mask, 0, 0) 338 | self.window.set_back_pixmap(pixmap, False) 339 | return True 340 | 341 | def onClick(self, widget, event): 342 | if event.button == 1 and self.leftclickCB != None: 343 | self.leftclickCB() 344 | self.hide_notification() 345 | if event.button == 2 and self.middleclickCB != None: 346 | self.middleclickCB() 347 | self.hide_notification() 348 | if event.button == 3 and self.rightclickCB != None: 349 | self.rightclickCB() 350 | self.hide_notification() 351 | 352 | if __name__ == "__main__": 353 | #example usage 354 | 355 | import random 356 | color_combos = (("red", "white"), ("white", "blue"), ("green", "black")) 357 | messages = (("Hello", "This is a popup"), 358 | ("Some Latin", "Quidquid latine dictum sit, altum sonatur."), 359 | ("A long message", "The quick brown fox jumped over the lazy dog. " * 6)) 360 | images = ("logo1_64.png", None) 361 | 362 | def notify_factory(): 363 | color = random.choice(color_combos) 364 | message = random.choice(messages) 365 | image = random.choice(images) 366 | notifier.bg_color = gtk.gdk.Color(color[0]) 367 | notifier.fg_color = gtk.gdk.Color(color[1]) 368 | notifier.show_timeout = random.choice((True, False)) 369 | notifier.edge_offset_x = 20 370 | notifier.new_popup(title=message[0], message=message[1], image=image) 371 | return True 372 | 373 | def gtk_main_quit(): 374 | print "quitting" 375 | gtk.main_quit() 376 | 377 | notifier = NotificationStack(timeout=6) 378 | gobject.timeout_add(4000, notify_factory) 379 | gobject.timeout_add(20000, gtk_main_quit) 380 | gtk.main() --------------------------------------------------------------------------------