pidgin-mra-20100304/0000755000000000000000000000000011773017070012475 5ustar rootrootpidgin-mra-20100304/INSTALL0000664000000000000000000000012211773017044013524 0ustar rootrootINSTALL ~~~~~~~ 0. sudo apt-get install pidgin-dev 1. make 2. sudo make install pidgin-mra-20100304/.gitignore0000664000000000000000000000003011773017044014461 0ustar rootroot*.so src/tags src/*.swp pidgin-mra-20100304/img/0000775000000000000000000000000011773017044013254 5ustar rootrootpidgin-mra-20100304/img/mra22.png0000664000000000000000000001022211773017044014702 0ustar rootrootPNG  IHDRĴl; pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3- cHRMz%u0`:o_FIDATxڌU{l~~rs\svԖmRV.:PFP" qid6E8c \б9͖5CIjtfCPC[swf`{z$ϓ}UAs`bw%7"sF㙾ޙ S|^ZejGŏ6[dvJA@tT3[/7_Fxǚ@eA@VlZ ը$2)X3&Wv\4> 1s9:9Y!it-{rjG @PŁovO?lζ/,|RU78?QsI}У<{Uһ;*LԻ_l|nfѶ[>t;}lPW3]^]׸҇4yt"Nڹo:F]-D]DukM4sd:NJ^7]]jC'_ g=Շ>ى,|HM>=n_EMe1u IzJ,yQ-q!w\[݁˃ӫxhߧM?dۡ֍g|ckl )-Vk1:*q!4L~/<!Q'wmcgN=v=C*C# >5Uaps=HDI5/pi?}39rF;5:B0r:!d/f2!M@@>C2_`d z-! "4> !Iv vU'5Jږ,[6^VlR:k@!Iʳ9jMBY5&l~r+OMAGpDnJ6W+^r&8`Ǫm5s,KI=>VTo,y^}3C9ӺmRL^˂rușhQY`&(XdA'9޻y;'lb9mvZ>aYTlVO:Q=7ݕWi17Z!(6p葱#3~mx%pW*J['Dtd?i{i3T=IENDB`pidgin-mra-20100304/img/mra16.png0000664000000000000000000000710611773017044014714 0ustar rootrootPNG  IHDRa pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3- cHRMz%u0`:o_FqIDATxlSmL~G~\ Vi$cusF2`6AqD1٢H4f?L A`N6H\Cp.Xh((׏ݽ:y}'OA*jo`J((-4mz^'AGW}^{ؒH S%ۅazgٛLG7yXk[lnMx- u69HWu~x~`#~|{ȯ8Ps,AS/ H;᫞Kx}&V?qCT^=sCªu}K\jv!%EhhJ*F0:Q8wҷ4@#b6dح/ɬ"AI`R9TH ?Ҁ& ">#66E ''j""ya XH@1EwKɨ0 q^m㴮ڲSҒHd U'_Jy(\VRC;أRcZL]O V]l7UjJݷf"&JI(҃wCoRԖj`|=Sj V:W^k/"mDyXtN)uybvA&'Ylm3gE$ix(ȈO)ȱ~umн$#A)!9_o~&c0zVJ@|~F"y=Lmp*xf#HIENDB`pidgin-mra-20100304/img/mra48.png0000664000000000000000000000701411773017044014717 0ustar rootrootPNG  IHDR00W IDATxڽZXSWdH aYj֭UZZ-Zb_a+Zk-ZdA!#B=K0~8wD?8xoo7o}eoZa f7G\.owgOGǼ$lHtС'mPx^\B"`q8Ppؐ= x5qvdjEApoȦ@4 xpol%笏Aҫjx%:W^ANL4mf+V l+<C5@M$eu^ m!&;M}Ê>[8 z5x Y6K{HaՋ߭ >ah-gXGwuɳ%WQGFqk [_xMqjhR^1mGEvEB[MI >lC^V >6?BX %%o1E3(jEfk x8RX#"hSW~sx2IkYD+WPxD)bԨ=콷@{Uu,9?nir29eh3i^1%c̒n2 =Tr/o=Fc 4#kC"f1oszqWT}hpD"5fԄ}[k>6 UmnOY70z,(?6}[rJnQHNj݋Lp+l?RyjnzMlHɿ4~?3ho8r5=Q|.hPB2u˳krUmɞ)U%?w]JudxϪ&I2N7{ R-| ;zV),Se8 Y_tH ֻLZ>ǡ<@=,Ĕsb'jͩx' ænGɩ*Jb9$TZW!A hN ՂԧKv/4S̼Ŗv L?Mt v chY{| I&AE m (D΋͢A2uH3FG->zbBݕS;@e> VaGl Xw-!Z3VΤD>tV_|rua)yַKAΫWz/MGC$ȼ# >AaY@__,rtuJ}vTa@$C#޴4n4:1,qTy\`:RU5S?/*^_gy3/wgNҪ.?˔uO$ OVτ[^Np6;b|3-jy:nEնKR} 7a>l7ۡ b-c# QAl$$oG|J3pQc:;"ӹnum6GW$,r&SR9܍<&0$ *P NwT_zPaiFdV6";Ab'T< B*ϥS9琼by>'1o&t:|EރM(ۥ"]Dle!풓E1-y㞛`u#KҟA C'.acȆf685AiEsǑI.#Ƀ8r_˚ O?dI|_|ߌdSӹliP9ٴml9Yɩ'FX8_䚏^4@ :TX zYt@-8wyW%64\$vIgK@v!Wx};:1 镭K7f#/ƅ= 3.%i*'!9KjZ3-%^A6N!g:?u;@O,ScfT,%{Xw?bHy@ T%m{t"1E'HeSކ?.v;hNWUArPZ?+枭 5֧@HfՖhaf:YXD1ZQqOkå*IKu?M 8$cy(aZFb.$Lp:5\N*UtoX^ 3"XjӬ~WT=А[ݓ[J JE<. L1.jXL&V?z4Bp'qU)3~.?;֦ҔKO1; H 'V3-yC*0'"N(.Ρ> .tF ة)MB!U 4i6(6,%;^Fikɮ3-Mw x} +kbڅ7:*csЎ֣Pr7ds߽"h_kkS<8ps>'-Z""8EfW9േ򁋵M% T;*q4lƝm9P/$A[W& :Hd!@aqod$Nu b04[ yŲ*~_ ~xOįj1]36d +,s{ȬV#2 @ɵ7jVQ2,wlin{̟slװ9U~SӸ% .wh}'&8W\Yy-)ȅ ߿ a(/$ ۲J(>[2TÇK[㽶rhhd$*%>w &CFC>plsab[_#aԫRz$'hkG+_օ 74@MvLoNm5KgxZQ~8 y.QQpCd7:SOVF7WH< 9Ou8BDJ%M.ς?XWȲڿ}V"p&D?:NbLL2JTfZ͇S./47(oh<468lUC?I5kdtÇIENDB`pidgin-mra-20100304/COPYING0000664000000000000000000004313111773017044013535 0ustar rootroot GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. pidgin-mra-20100304/TODO0000664000000000000000000000100011773017044013157 0ustar rootrootTODO ~~~~ 1. Coding style - normal configure and make - clean and rewrite code 2. Features - add localization + add avatars into contact list (done) + add user info window (done) + add 'new emails' feature (done) - change proto.h version to 1.22 (more functions) - add rtf-messages support - add chat support - add extra statuses - add contacts searching dialog - add smiles support - add extra-smiles support - add 'wake up' feature - add sms-sending feature - add file-transfer feature - voice (why not? =) pidgin-mra-20100304/ChangeLog0000664000000000000000000000235211773017044014254 0ustar rootroot2010-03-04 Vladimir Rudnyh * Base functional 2010-03-31 Konstantin Menyaev * Add 'Get info about contact' feature * Add 'New mail notification' feature 2010-04-20 Vladimir Rudnyh * Fix logout (account usage on another computer). * Fix email validation (http://github.com/dreadatour/pidgin-mra/issues#issue/2): Capital letters are allowed now. Email validation is fixed (no more segfault now). * Fix not email contacts crash (http://github.com/dreadatour/pidgin-mra/issues#issue/2): Phone and other strange contacts are skipped. * Add 'Rename users' feature (http://github.com/dreadatour/pidgin-mra/issues#issue/6) 2010-04-21 Vladimir Rudnyh * Fix 'New mail notification' feature: Now it is depend on setting. * Fix contact list parser * Change protocol icons * Add simple chat feature: NB! You need to add chat contact to user list to chat work correctly. 2010-04-21 Vladimir Rudnyh * Fix variables types -> hope, it will work in 64-bit base systems 2010-07-14 Vladimir Rudnyh * Add user avatars * Add connection server request pidgin-mra-20100304/src/0000775000000000000000000000000011773017044013267 5ustar rootrootpidgin-mra-20100304/src/proto.h0000664000000000000000000002001111773017044014575 0ustar rootroot/* Copyright (C) Mail.ru More info at http://agent.mail.ru/ru/developers/licence.html */ #ifndef _MRA_PROTO_H_ #define _MRA_PROTO_H_ #include #define PROTO_VERSION_MAJOR 1 #define PROTO_VERSION_MINOR 8 #define PROTO_VERSION ((((u_long)(PROTO_VERSION_MAJOR))<<16)|(u_long)(PROTO_VERSION_MINOR)) #define PROTO_MAJOR(p) (((p)&0xFFFF0000)>>16) #define PROTO_MINOR(p) ((p)&0x0000FFFF) #define CS_MAGIC 0xDEADBEEF // client magic (C->S) typedef struct _mrim_packet_header_t { uint32_t magic; // magic uint32_t proto; // protocol version uint32_t seq; // sequence number uint32_t msg; // packet type uint32_t dlen; // data length uint32_t from; // sender address uint32_t fromport; // sender port u_char reserved[16]; // reserved } mrim_packet_header_t; //================================================================================================= // Client-server proto //================================================================================================= #define MRIM_CS_HELLO 0x1001 // C -> S // empty #define MRIM_CS_HELLO_ACK 0x1002 // S -> C // mrim_connection_params_t #define MRIM_CS_LOGIN_ACK 0x1004 // S -> C // empty #define MRIM_CS_LOGIN_REJ 0x1005 // S -> C // LPS reason #define MRIM_CS_PING 0x1006 // C -> S // empty #define MRIM_CS_MESSAGE 0x1008 // C -> S // UL flags // LPS to // LPS message // LPS rtf-formatted message (>=1.1) #define MESSAGE_FLAG_OFFLINE 0x00000001 #define MESSAGE_FLAG_NORECV 0x00000004 #define MESSAGE_FLAG_AUTHORIZE 0x00000008 // X-MRIM-Flags: 00000008 #define MESSAGE_FLAG_SYSTEM 0x00000040 #define MESSAGE_FLAG_RTF 0x00000080 #define MESSAGE_FLAG_CONTACT 0x00000200 #define MESSAGE_FLAG_NOTIFY 0x00000400 #define MESSAGE_FLAG_MULTICAST 0x00001000 #define MAX_MULTICAST_RECIPIENTS 50 #define MESSAGE_USERFLAGS_MASK 0x000036A8 // Flags that user is allowed to set himself #define MRIM_CS_MESSAGE_ACK 0x1009 // S -> C // UL msg_id // UL flags // LPS from // LPS message // LPS rtf-formatted message (>=1.1) #define MRIM_CS_MESSAGE_RECV 0x1011 // C -> S // LPS from // UL msg_id #define MRIM_CS_MESSAGE_STATUS 0x1012 // S -> C // UL status #define MESSAGE_DELIVERED 0x0000 // Message delivered directly to user #define MESSAGE_REJECTED_NOUSER 0x8001 // Message rejected - no such user #define MESSAGE_REJECTED_INTERR 0x8003 // Internal server error #define MESSAGE_REJECTED_LIMIT_EXCEEDED 0x8004 // Offline messages limit exceeded #define MESSAGE_REJECTED_TOO_LARGE 0x8005 // Message is too large #define MESSAGE_REJECTED_DENY_OFFMSG 0x8006 // User does not accept offline messages #define MRIM_CS_USER_STATUS 0x100F // S -> C // UL status #define STATUS_OFFLINE 0x00000000 #define STATUS_ONLINE 0x00000001 #define STATUS_AWAY 0x00000002 #define STATUS_UNDETERMINATED 0x00000003 #define STATUS_FLAG_INVISIBLE 0x80000000 // LPS user #define MRIM_CS_LOGOUT 0x1013 // S -> C // UL reason #define LOGOUT_NO_RELOGIN_FLAG 0x0010 // Logout due to double login #define MRIM_CS_CONNECTION_PARAMS 0x1014 // S -> C // mrim_connection_params_t #define MRIM_CS_USER_INFO 0x1015 // S -> C // (LPS key, LPS value)* X #define MRIM_CS_ADD_CONTACT 0x1019 // C -> S // UL flags (group(2) or usual(0) // UL group id (unused if contact is group) // LPS contact // LPS name // LPS unused #define CONTACT_FLAG_REMOVED 0x00000001 #define CONTACT_FLAG_GROUP 0x00000002 #define CONTACT_FLAG_INVISIBLE 0x00000004 #define CONTACT_FLAG_VISIBLE 0x00000008 #define CONTACT_FLAG_IGNORE 0x00000010 #define CONTACT_FLAG_SHADOW 0x00000020 #define MRIM_CS_ADD_CONTACT_ACK 0x101A // S -> C // UL status // UL contact_id or (u_long)-1 if status is not OK #define CONTACT_OPER_SUCCESS 0x0000 #define CONTACT_OPER_ERROR 0x0001 #define CONTACT_OPER_INTERR 0x0002 #define CONTACT_OPER_NO_SUCH_USER 0x0003 #define CONTACT_OPER_INVALID_INFO 0x0004 #define CONTACT_OPER_USER_EXISTS 0x0005 #define CONTACT_OPER_GROUP_LIMIT 0x0006 #define MRIM_CS_MODIFY_CONTACT 0x101B // C -> S // UL id // UL flags - same as for MRIM_CS_ADD_CONTACT // UL group id (unused if contact is group) // LPS contact // LPS name // LPS unused #define MRIM_CS_MODIFY_CONTACT_ACK 0x101C // S -> C // UL status, same as for MRIM_CS_ADD_CONTACT_ACK #define MRIM_CS_OFFLINE_MESSAGE_ACK 0x101D // S -> C // UIDL // LPS offline message #define MRIM_CS_DELETE_OFFLINE_MESSAGE 0x101E // C -> S // UIDL #define MRIM_CS_AUTHORIZE 0x1020 // C -> S // LPS user #define MRIM_CS_AUTHORIZE_ACK 0x1021 // S -> C // LPS user #define MRIM_CS_CHANGE_STATUS 0x1022 // C -> S // UL new status #define MRIM_CS_GET_MPOP_SESSION 0x1024 // C -> S #define MRIM_CS_MPOP_SESSION 0x1025 // S -> C #define MRIM_GET_SESSION_FAIL 0 #define MRIM_GET_SESSION_SUCCESS 1 //UL status // LPS mpop session //white pages! #define MRIM_CS_WP_REQUEST 0x1029 // C -> S //DWORD field, LPS value #define PARAMS_NUMBER_LIMIT 50 #define PARAM_VALUE_LENGTH_LIMIT 64 //if last symbol in value eq '*' it will be replaced by LIKE '%' // params define // must be in consecutive order (0..N) to quick check in check_anketa_info_request enum { MRIM_CS_WP_REQUEST_PARAM_USER = 0, MRIM_CS_WP_REQUEST_PARAM_DOMAIN, MRIM_CS_WP_REQUEST_PARAM_NICKNAME, MRIM_CS_WP_REQUEST_PARAM_FIRSTNAME, MRIM_CS_WP_REQUEST_PARAM_LASTNAME, MRIM_CS_WP_REQUEST_PARAM_SEX, MRIM_CS_WP_REQUEST_PARAM_BIRTHDAY, MRIM_CS_WP_REQUEST_PARAM_DATE1, MRIM_CS_WP_REQUEST_PARAM_DATE2, //!!!!!!!!!!!!!!!!!!!online request param must be at end of request!!!!!!!!!!!!!!! MRIM_CS_WP_REQUEST_PARAM_ONLINE, MRIM_CS_WP_REQUEST_PARAM_STATUS, MRIM_CS_WP_REQUEST_PARAM_CITY_ID, MRIM_CS_WP_REQUEST_PARAM_ZODIAC, MRIM_CS_WP_REQUEST_PARAM_BIRTHDAY_MONTH, MRIM_CS_WP_REQUEST_PARAM_BIRTHDAY_DAY, MRIM_CS_WP_REQUEST_PARAM_COUNTRY_ID, MRIM_CS_WP_REQUEST_PARAM_MAX }; #define MRIM_CS_ANKETA_INFO 0x1028 // S -> C //DWORD status #define MRIM_ANKETA_INFO_STATUS_OK 1 #define MRIM_ANKETA_INFO_STATUS_NOUSER 0 #define MRIM_ANKETA_INFO_STATUS_DBERR 2 #define MRIM_ANKETA_INFO_STATUS_RATELIMERR 3 //DWORD fields_num //DWORD max_rows //DWORD server_time sec since 1970 (unixtime) //fields set //%fields_num == 0 //values set //%fields_num == 0 //LPS value (numbers too) #define MRIM_CS_MAILBOX_STATUS 0x1033 // S -> C //DWORD new messages in mailbox #define MRIM_CS_CONTACT_LIST2 0x1037 // S -> C // UL status #define GET_CONTACTS_OK 0x0000 #define GET_CONTACTS_ERROR 0x0001 #define GET_CONTACTS_INTERR 0x0002 //DWORD status - if ...OK than this staff: //DWORD groups number //mask symbols table: //'s' - lps //'u' - unsigned long //'z' - zero terminated string //LPS groups fields mask //LPS contacts fields mask //group fields //contacts fields //groups mask 'us' == flags, name //contact mask 'uussuu' flags, flags, internal flags, status #define CONTACT_INTFLAG_NOT_AUTHORIZED 0x0001 //old packet cs_login with cs_statistic #define MRIM_CS_LOGIN2 0x1038 // C -> S #define MAX_CLIENT_DESCRIPTION 256 // LPS login // LPS password // DWORD status //+ statistic packet data: // LPS client description //max 256 typedef struct mrim_connection_params_t { unsigned long ping_period; } mrim_connection_params_t; #endif /* _MRA_PROTO_H_ */ pidgin-mra-20100304/src/libmra.c0000664000000000000000000017240211773017044014707 0ustar rootroot/* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Special thanx to Aleksey B. Copyright (C) 2010, Vladimir Rudnyh */ #define PURPLE_PLUGIN #include "libmra.h" static PurplePlugin *this_plugin; /************************************************************************************************** Check email **************************************************************************************************/ gboolean mra_email_is_valid(const char *email) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ purple_debug_info("mra", "[%s] check email '%s'\n", __func__, email); /* FIXME */ // check email by purple if (!purple_email_is_valid(email)) { purple_debug_info("mra", "[%s] failed check 'purple_email_is_valid'\n", __func__); /* FIXME */ return FALSE; } char **eml = g_strsplit(email, "@", 2); gboolean ret = TRUE; // check if email is too long if (strlen(eml[0]) > 32) { ret = FALSE; purple_debug_info("mra", "[%s] failed check 'username length'\n", __func__); /* FIXME */ } // check username (allowed symbols) if (ret) { while (*email != '@') { // only 'a-z', 'A-Z', '0-9', '_', '-' and '.' allowed if (ret && (*email < '0' || *email > '9') && (*email < 'a' || *email > 'z') && (*email < 'A' || *email > 'Z') && *email != '_' && *email != '-' && *email != '.') { ret = FALSE; purple_debug_info("mra", "[%s] failed check 'allowed symbols'\n", __func__);/* FIXME */ break; } email++; } } // check domain if (ret && strcmp(eml[1], "mail.ru") != 0 && strcmp(eml[1], "list.ru") != 0 && strcmp(eml[1], "inbox.ru") != 0 && strcmp(eml[1], "bk.ru") != 0 && strcmp(eml[1], "corp.mail.ru") != 0 && strcmp(eml[1], "chat.agent") != 0) { ret = FALSE; purple_debug_info("mra", "[%s] failed check 'allowed domains'\n", __func__); /* FIXME */ } g_strfreev(eml); return ret; } /************************************************************************************************** Load server to connect to callback **************************************************************************************************/ void mra_get_connection_server_cb(PurpleUtilFetchUrlData *url_data, gpointer data, const gchar *url_text, gsize len, const gchar *error_message) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ UNUSED(url_data); UNUSED(len); UNUSED(error_message); gchar **srv = NULL; gchar *server = NULL; int port = 0; mra_serv_conn *mmp = data; g_return_if_fail(mmp != NULL); PurpleAccount *acct = mmp->acct; g_return_if_fail(acct != NULL); PurpleConnection *gc = mmp->gc; g_return_if_fail(gc != NULL); if (!url_text) { purple_debug_info("mra", "[%s] failed to get server to connect to\n", __func__); /* FIXME */ purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Connection problem")); return; } purple_debug_info("mra", "[%s] server to connect to: '%s'\n", __func__, url_text); /* FIXME */ srv = g_strsplit(url_text, ":", 2); server = g_strdup(srv[0]); port = atoi(srv[1]); mmp->connect_data = purple_proxy_connect(gc, acct, server, port, mra_connect_cb, gc); if (mmp->connect_data == NULL) { purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Connection problem")); } g_strfreev(srv); g_free(server); } /************************************************************************************************** Get server to connect to **************************************************************************************************/ void mra_get_connection_server(gpointer data, const char *server, int port) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ gchar *url = NULL; url = g_strdup_printf("http://%s:%u/", server, port); purple_debug_info("mra", "[%s] connection server url: %s\n", __func__, url); /* FIXME */ purple_util_fetch_url(url, TRUE, NULL, TRUE, mra_get_connection_server_cb, data); g_free(url); } /************************************************************************************************** Load user avatar callback **************************************************************************************************/ void mra_load_avatar_cb(PurpleUtilFetchUrlData *url_data, gpointer data, const gchar *url_text, gsize len, const gchar *error_message) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ UNUSED(url_data); UNUSED(error_message); PurpleAccount *account = NULL; PurpleBuddy *buddy = NULL; buddy = data; g_return_if_fail(buddy != NULL); g_return_if_fail(buddy->name != NULL); // check email by purple if (!purple_email_is_valid(buddy->name)) { purple_debug_info("mra", "[%s] user is invalid: %s (%s)\n", __func__, buddy->name, buddy->alias); /* FIXME */ return; } purple_debug_info("mra", "[%s] downloaded avatar for user %s\n", __func__, buddy->name); /* FIXME */ if (error_message) { purple_debug_info("mra", "[%s] error: %s\n", __func__, error_message); /* FIXME */ } purple_debug_info("mra", "[%s] downloaded: %" G_GSIZE_FORMAT " bytes\n", __func__, len); /* FIXME */ if (!url_text) { purple_debug_info("mra", "[%s] failed to download avatar for %s\n", __func__, buddy->name); /* FIXME */ return; } account = purple_buddy_get_account(buddy); g_return_if_fail(account != NULL); purple_buddy_icons_set_for_user(account, buddy->name, g_memdup((gchar *)url_text, len), len, NULL); } /************************************************************************************************** Load user avatar **************************************************************************************************/ void mra_load_avatar(gpointer data, const char *email) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ PurpleBuddy *buddy; mra_serv_conn *mmp; gchar **eml = NULL; gchar *domain = NULL; gchar *url = NULL; mmp = data; g_return_if_fail(mmp != NULL); buddy = purple_find_buddy(mmp->acct, email); g_return_if_fail(buddy != NULL); purple_debug_info("mra", "[%s] find avatar for email: %s\n", __func__, email); /* FIXME */ eml = g_strsplit(email, "@", 2); if (strcmp(eml[1], "corp.mail.ru") == 0) { domain = g_strdup("corp"); } else if (strcmp(eml[1], "mail.ru") == 0) { domain = g_strdup("mail"); } else if (strcmp(eml[1], "list.ru") == 0) { domain = g_strdup("list"); } else if (strcmp(eml[1], "inbox.ru") == 0) { domain = g_strdup("inbox"); } else if (strcmp(eml[1], "bk.ru") == 0) { domain = g_strdup("bk"); } else { purple_debug_info("mra", "[%s] unknown email domain: %s\n", __func__, eml[1]); /* FIXME */ g_strfreev(eml); return; } url = g_strdup_printf("http://obraz.foto.mail.ru/%s/%s/_mrimavatar", domain, eml[0]); purple_debug_info("mra", "[%s] avatar url: %s\n", __func__, url); /* FIXME */ purple_util_fetch_url(url, TRUE, NULL, TRUE, mra_load_avatar_cb, buddy); g_strfreev(eml); g_free(domain); g_free(url); } /************************************************************************************************** Set contact status **************************************************************************************************/ void mra_contact_set_status(gpointer data, char *email, uint32_t status) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mra_serv_conn *mmp = data; g_return_if_fail(mmp != NULL); purple_debug_info("mra", "[%s] %s status: 0x%08x\n", __func__, email, status); /* FIXME */ if (status & STATUS_FLAG_INVISIBLE) { purple_debug_info("mra", "[%s] %s status is invisible\n", __func__, email); /* FIXME */ purple_prpl_got_user_status(mmp->acct, email, MRA_STATUS_ID_INVISIBLE, NULL); } switch (status & 0x7FFFFFFF) { case STATUS_OFFLINE: purple_debug_info("mra", "[%s] %s status is offline\n", __func__, email); /* FIXME */ purple_prpl_got_user_status(mmp->acct, email, MRA_STATUS_ID_OFFLINE, NULL); break; case STATUS_ONLINE: purple_debug_info("mra", "[%s] %s status is online\n", __func__, email); /* FIXME */ purple_prpl_got_user_status(mmp->acct, email, MRA_STATUS_ID_ONLINE, NULL); break; case STATUS_AWAY: purple_debug_info("mra", "[%s] %s status is away\n", __func__, email); /* FIXME */ purple_prpl_got_user_status(mmp->acct, email, MRA_STATUS_ID_AWAY, NULL); break; case STATUS_UNDETERMINATED: default: purple_debug_info("mra", "[%s] %s status is unknown\n", __func__, email); /* FIXME */ purple_prpl_got_user_status(mmp->acct, email, MRA_STATUS_ID_UNDETERMINATED, NULL); } // load avatar mra_load_avatar(data, email); } /************************************************************************************************** Callback for 'hello' function **************************************************************************************************/ void mra_hello_cb(gpointer data) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mra_serv_conn *mmp = data; g_return_if_fail(mmp != NULL); g_return_if_fail(mmp->acct != NULL); g_return_if_fail(mmp->gc != NULL); const char *username = purple_account_get_username(mmp->acct); const char *password = purple_account_get_password(mmp->acct); uint32_t status = STATUS_ONLINE; purple_connection_update_progress(mmp->gc, _("Connecting"), 3, 3); mra_net_send_auth(mmp, username, password, status); } /************************************************************************************************** Callback for 'login' function **************************************************************************************************/ void mra_login_cb(gpointer data, uint32_t status, char *message) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mra_serv_conn *mmp = data; g_return_if_fail(mmp != NULL); g_return_if_fail(mmp->gc != NULL); if (status != MRA_LOGIN_SUCCESSFUL) { purple_debug_error("mra", "[%s] got error\n", __func__); /* FIXME */ gchar *tmp; tmp = g_strdup_printf(_("Connection problem:\n%s"), message); purple_connection_error_reason(mmp->gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); g_free(tmp); mra_close(mmp->gc); } else { purple_connection_update_progress(mmp->gc, _("Connecting"), 3, 3); mmp->authorized = TRUE; purple_debug_info("mra", "mra_login is OK\n"); /* FIXME */ } } /************************************************************************************************** Logout callback **************************************************************************************************/ void mra_logout_cb(gpointer data, char *reason) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mra_serv_conn *mmp = data; g_return_if_fail(mmp != NULL); g_return_if_fail(mmp->acct != NULL); g_return_if_fail(mmp->gc != NULL); const char *username = purple_account_get_username(mmp->acct); purple_debug_error("mra", "[%s] got reason: %s\n", __func__, reason); /* FIXME */ gchar *tmp; tmp = g_strdup_printf(_("Account %s is used on another computer or device.\n"), username); purple_connection_error_reason(mmp->gc, PURPLE_CONNECTION_ERROR_NAME_IN_USE, tmp); g_free(tmp); } /************************************************************************************************** Callback for 'user_info' function **************************************************************************************************/ void mra_user_info_cb(gpointer data, mra_user_info *user_info) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ UNUSED(data); UNUSED(user_info); } /************************************************************************************************** Callback for 'contact list' function **************************************************************************************************/ void mra_contact_list_cb(gpointer data, uint32_t status, size_t group_cnt, mra_group *groups, size_t contact_cnt, mra_contact *contacts) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ UNUSED(status); mra_serv_conn *mmp = data; size_t i; char *group; PurpleGroup *g = NULL; PurpleBuddy *buddy; g_return_if_fail(mmp != NULL); g_return_if_fail(mmp->acct != NULL); g_return_if_fail(mmp->groups != NULL); g_return_if_fail(mmp->users != NULL); g_return_if_fail(mmp->users_is_authorized != NULL); mmp->groups_list = groups; mmp->contacts_list = contacts; // proceed all groups for (i = 0; i < group_cnt; i++) { purple_debug_info("mra", "[%s] group %s (%d)\n", __func__, groups[i].name, groups[i].id); /* FIXME */ if (groups[i].removed || groups[i].name == NULL || *groups[i].name == '\0') { continue; } // insert group into groups hash g_hash_table_insert(mmp->groups, g_strdup_printf("%d", groups[i].id), groups[i].name); // add group into pidgin, if not exists if ((purple_find_group(groups[i].name)) == NULL) { g = purple_group_new(groups[i].name); purple_blist_add_group(g, NULL); } } // proceed all users for (i = 0; i < contact_cnt; i++) { purple_debug_info("mra", "[%s] user %s (%d)\n", __func__, contacts[i].email, contacts[i].id); /* FIXME */ buddy = purple_find_buddy(mmp->acct, contacts[i].email); if (contacts[i].removed || contacts[i].skip_user || contacts[i].email == NULL || *contacts[i].email == '\0') { if (contacts[i].skip_user) { continue; } if (buddy != NULL) { purple_blist_remove_buddy(buddy); } continue; } if (!(contacts[i].intflags & CONTACT_INTFLAG_NOT_AUTHORIZED)) { g_hash_table_insert(mmp->users_is_authorized, contacts[i].email, "TRUE"); purple_debug_info("mra", "[%s] users_is_authorized = %s\n", __func__, contacts[i].email); /* FIXME */ } g_hash_table_insert(mmp->users, contacts[i].email, g_strdup_printf("%d", contacts[i].id)); // add user into pidgin, if user not found if (buddy == NULL) { // get group name by id group = g_hash_table_lookup(mmp->groups, g_strdup_printf("%d", contacts[i].group_id)); // get group by name g = purple_find_group(group); // add group into pidgin, if not exists if (g == NULL) { if (groups[contacts[i].group_id].name != NULL && *groups[contacts[i].group_id].name != '\0') { g = purple_group_new(groups[contacts[i].group_id].name); purple_blist_add_group(g, NULL); } else { g = purple_group_new(_("Buddies")); } } purple_debug_info("mra", "[%s] group %s\n", __func__, g->name); /* FIXME */ // create new buddy buddy = purple_buddy_new(mmp->acct, contacts[i].email, contacts[i].nickname); purple_debug_info("mra", "[%s] buddy %s\n", __func__, buddy->name); /* FIXME */ // add buddy into pidgin purple_blist_add_buddy(buddy, NULL, g, NULL); } // set buddy status if (contacts[i].nickname != NULL && *contacts[i].nickname != '\0') { purple_blist_alias_buddy(buddy, contacts[i].nickname); } else { purple_blist_alias_buddy(buddy, contacts[i].email); } mra_contact_set_status(mmp, contacts[i].email, contacts[i].status); } } /************************************************************************************************** Callback for 'user_status' function **************************************************************************************************/ void mra_user_status_cb(gpointer data, char *email, uint32_t status) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mra_serv_conn *mmp = data; g_return_if_fail(mmp != NULL); mra_contact_set_status(mmp, email, status); } /************************************************************************************************** Callback for 'auth_request accepted' function **************************************************************************************************/ void mra_auth_request_add_cb(gpointer data) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mra_auth_request *auth_request = data; g_return_if_fail(auth_request != NULL); g_return_if_fail(auth_request->mmp != NULL); // send auth user answer mra_net_send_authorize_user(auth_request->mmp, auth_request->email); // send 'add user into group' packet. group = 0 <- TODO (is it neccecary?) mra_net_send_add_user(auth_request->mmp, auth_request->email, auth_request->email, 0, 0); g_free(auth_request->email); g_free(auth_request); } /************************************************************************************************** Callback for 'auth_request canceled' function **************************************************************************************************/ void mra_auth_request_cancel_cb(gpointer data) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mra_auth_request *auth_request = data; g_return_if_fail(auth_request != NULL); // TODO: remove this callback in future?! g_free(auth_request->email); g_free(auth_request); } /************************************************************************************************** Callback for 'auth_request' function **************************************************************************************************/ void mra_auth_request_cb(gpointer data, char *from, char *message) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mra_serv_conn *mmp = data; g_return_if_fail(mmp != NULL); g_return_if_fail(mmp->acct != NULL); mra_auth_request *auth_request = g_new0(mra_auth_request, 1); auth_request->mmp = mmp; auth_request->email = g_strdup(from); purple_account_request_authorization(mmp->acct, from, NULL, NULL, message, purple_find_buddy(mmp->acct, from) != NULL, mra_auth_request_add_cb, mra_auth_request_cancel_cb, auth_request); } /************************************************************************************************** Callback for 'typing_notify' function **************************************************************************************************/ void mra_typing_notify_cb(gpointer data, char *from) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mra_serv_conn *mmp = data; g_return_if_fail(mmp != NULL); g_return_if_fail(mmp->gc != NULL); serv_got_typing(mmp->gc, from, TYPING_TIMEOUT, PURPLE_TYPING); } /************************************************************************************************** Callback for 'mail_notify' function **************************************************************************************************/ void mra_mail_notify_cb(gpointer data, uint32_t status) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ char buff[128]; mra_serv_conn *mmp = data; g_return_if_fail(mmp != NULL); g_return_if_fail(mmp->gc != NULL); g_return_if_fail(mmp->acct != NULL); // skip notify if no such setting if (!purple_account_get_check_mail(mmp->acct)) return; if (status < 1) return; sprintf(buff, "Dear %s.\nYou have %u unread mail(s) in your mailbox", mmp->acct->username, status); purple_notify_message(mmp->gc, PURPLE_NOTIFY_MSG_INFO, "New Mail", buff, NULL, NULL, NULL); } /************************************************************************************************** Callback for 'message' function **************************************************************************************************/ void mra_message_cb(gpointer data, char *from, char *message, char *message_rtf, time_t time, uint32_t type) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ UNUSED(message_rtf); UNUSED(type); mra_serv_conn *mmp = data; g_return_if_fail(mmp != NULL); g_return_if_fail(mmp->acct != NULL); PurpleConversation *conv; // PurpleBuddyIcon *icon; // TODO: add buddy icon here conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, from, mmp->acct); if (conv) { purple_debug_info("mra", "[%s] conversation was found\n", __func__); /* FIXME */ purple_conversation_set_name(conv, from); } else { purple_debug_info("mra", "[%s] conversation not found\n", __func__); /* FIXME */ conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, mmp->acct, from); } serv_got_im(mmp->gc, from, purple_markup_escape_text(message, strlen(message)), 0, time); } /************************************************************************************************** Connection result **************************************************************************************************/ void mra_connect_result(gpointer data, gint status, char *error) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ UNUSED(data); purple_debug_error("mra", "[%s] connect result: %d (%s)\n", __func__, status, error); /* FIXME */ } /************************************************************************************************** Connect to server callback **************************************************************************************************/ void mra_connect_cb(gpointer data, gint source, const gchar *error_message) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ PurpleConnection *gc = data; g_return_if_fail(gc != NULL); mra_serv_conn *mmp = gc->proto_data; g_return_if_fail(mmp != NULL); g_return_if_fail(mmp->acct != NULL); const char *username = purple_account_get_username(mmp->acct); // Don't need to cancel connection any more since it is established. mmp->connect_data = NULL; // return error if connection is invalid if (!PURPLE_CONNECTION_IS_VALID(gc)) { purple_debug_error("mra", "purple connection is invalid\n"); /* FIXME */ close(source); return; } // return error if no source if (source < 0) { purple_debug_error("mra", "source < 0\n"); gchar *tmp; tmp = g_strdup_printf(_("Could not establish a connection with the server:\n%s"), error_message); purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); g_free(tmp); return; } // fill proto data mmp->fd = source; mmp->connected = TRUE; mmp->name = g_strdup_printf("%s:%d", purple_account_get_string(gc->account, "host", MRA_HOST), purple_account_get_int(gc->account, "port", MRA_PORT)); purple_connection_set_display_name(gc, username); purple_connection_set_state(gc, PURPLE_CONNECTED); purple_debug_info("mra", "[%s] Connected\n", __func__); /* FIXME */ purple_debug_info("mra", "[%s] Trying to login user...\n", __func__); /* FIXME */ // set handler for incoming data mmp->tx_handler = purple_input_add(mmp->fd, PURPLE_INPUT_READ, (PurpleInputFunction) mra_net_read_cb, mmp); // set all callbacks mmp->callback_hello = mra_hello_cb; mmp->callback_login = mra_login_cb; mmp->callback_logout = mra_logout_cb; mmp->callback_user_info = mra_user_info_cb; mmp->callback_contact_list = mra_contact_list_cb; mmp->callback_user_status = mra_user_status_cb; mmp->callback_auth_request = mra_auth_request_cb; mmp->callback_typing_notify = mra_typing_notify_cb; mmp->callback_message = mra_message_cb; mmp->callback_anketa_info = mra_anketa_info_cb; mmp->callback_mail_notify = mra_mail_notify_cb; // send 'hello' packet mra_net_send_hello(mmp); } /************************************************************************************************** Send message **************************************************************************************************/ int mra_send_im(PurpleConnection *gc, const char *to, const char *message, PurpleMessageFlags flags) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ UNUSED(flags); g_return_val_if_fail(gc != NULL, 0); mra_serv_conn *mmp = gc->proto_data; g_return_val_if_fail(mmp != NULL, 0); char *message_plain = purple_unescape_html(message); gboolean ret = FALSE; purple_debug_info("mra", "[%s] send message {%s} to {%s}\n", __func__, message, to);/* FIXME */ ret = mra_net_send_message(mmp, to, message_plain, 0); g_free(message_plain); if (ret) { return 1; } return 0; } /************************************************************************************************** Set info **************************************************************************************************/ void mra_set_info(PurpleConnection *gc, const char *rawinfo) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ UNUSED(gc); UNUSED(rawinfo); // mra_serv_conn *mmp = gc->proto_data; } /************************************************************************************************** Send typing **************************************************************************************************/ unsigned int mra_send_typing(PurpleConnection *gc, const char *to, PurpleTypingState state) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ g_return_val_if_fail(gc != NULL, 0); mra_serv_conn *mmp = gc->proto_data; g_return_val_if_fail(mmp != NULL, 0); if (state == PURPLE_TYPING) { if (mra_net_send_typing(mmp, to)) { return 1; } } return 0; } /************************************************************************************************** Set status **************************************************************************************************/ void mra_set_status(PurpleAccount *acct, PurpleStatus *status) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ g_return_if_fail(acct != NULL); PurpleConnection *gc = purple_account_get_connection(acct); g_return_if_fail(gc != NULL); mra_serv_conn *mmp = gc->proto_data; g_return_if_fail(mmp != NULL); const gchar *status_id; uint32_t mra_status; if (!purple_status_is_active(status)) return; if (!purple_account_is_connected(acct)) return; status_id = purple_status_get_id(status); if (!strcmp(status_id, MRA_STATUS_ID_ONLINE)) { mra_status = STATUS_ONLINE; } else if (!strcmp(status_id, MRA_STATUS_ID_AWAY)) { mra_status = STATUS_AWAY; } else if (!strcmp(status_id, MRA_STATUS_ID_INVISIBLE)) { mra_status = STATUS_FLAG_INVISIBLE | STATUS_ONLINE; } else { mra_status = STATUS_ONLINE; } mra_net_send_status(mmp, mra_status); } /************************************************************************************************** Add buddy confirmed **************************************************************************************************/ void mra_add_buddy_ok_cb(mra_add_buddy_req *data, char *msg) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ PurpleConnection *pc; PurpleBuddy *buddy; PurpleGroup *group; mra_serv_conn *mmp; gchar *email; gchar *alias; g_return_if_fail(data != NULL); g_return_if_fail(data->pc != NULL); g_return_if_fail(data->buddy != NULL); g_return_if_fail(data->group != NULL); pc = data->pc; buddy = data->buddy; group = data->group; g_free(data); mmp = pc->proto_data; if (mmp == NULL || mmp->users_is_authorized == NULL) { return; } email = strdup(purple_buddy_get_name(buddy)); alias = strdup(purple_buddy_get_alias(buddy)); if (g_hash_table_lookup(mmp->users_is_authorized, email) == NULL) { g_hash_table_insert(mmp->users_is_authorized, email, "TRUE"); purple_debug_info("mra", "[%s] users_is_authorized = %s\n", __func__, email); /* FIXME */ } mra_net_send_add_user(mmp, email, alias, 0, 0); mra_net_send_message(mmp, purple_buddy_get_name(buddy), msg, MESSAGE_FLAG_AUTHORIZE); g_free(email); g_free(alias); } /************************************************************************************************** Add buddy canceled **************************************************************************************************/ void mra_add_buddy_cancel_cb(mra_add_buddy_req *data, char *msg) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ UNUSED(msg); g_return_if_fail(data != NULL); // Remove from local list purple_blist_remove_buddy(data->buddy); g_free(data); } /************************************************************************************************** Add buddy **************************************************************************************************/ void mra_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ const char *email; mra_add_buddy_req *data; if (gc == NULL) { return; } if (buddy == NULL) { purple_debug_info("mra", "[%s] I can't add user because I have no buddy!\n", __func__); /* FIXME */ return; } if (group == NULL) { purple_debug_info("mra", "[%s] I can't add user because I have no group!\n", __func__); /* FIXME */ return; } email = purple_buddy_get_name(buddy); /* if (!mra_email_is_valid(email)) { gchar *buf; buf = g_strdup_printf(_("Unable to add the buddy %s because the username is invalid. Usernames must be valid email addresses."), email); if (!purple_conv_present_error(email, purple_connection_get_account(gc), buf)) { purple_notify_error(gc, NULL, _("Unable to Add"), buf); } g_free(buf); // Remove from local list purple_blist_remove_buddy(buddy); return; } */ data = g_new0(mra_add_buddy_req, 1); data->pc = gc; data->buddy = buddy; data->group = group; purple_request_input(gc, NULL, _("Authorization Request Message:"), NULL, _("Please authorize me!"), TRUE, FALSE, NULL, _("_OK"), G_CALLBACK(mra_add_buddy_ok_cb), _("_Cancel"), G_CALLBACK(mra_add_buddy_cancel_cb), purple_connection_get_account(gc), email, NULL, data); } /************************************************************************************************** Remove buddy **************************************************************************************************/ void mra_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ UNUSED(group); g_return_if_fail(gc != NULL); g_return_if_fail(buddy != NULL); mra_serv_conn *mmp = gc->proto_data; gpointer buddy_user_id; uint32_t user_id; uint32_t group_id = 0; char *email; char *name; g_return_if_fail(mmp != NULL); g_return_if_fail(mmp->users != NULL); email = (char *) purple_buddy_get_name(buddy); if (email == NULL) { purple_debug_info("mra", "[%s] I can't remove user because I can't find email!\n", __func__); /* FIXME */ return; } name = (char *) purple_buddy_get_alias(buddy); if (name == NULL) { purple_debug_info("mra", "[%s] I can't remove user because I can't find name!\n", __func__); /* FIXME */ return; } buddy_user_id = g_hash_table_lookup(mmp->users, email); if (buddy_user_id == NULL) { purple_debug_info("mra", "[%s] I can't remove user because I can't find user_id!\n", __func__); /* FIXME */ return; } user_id = atol(buddy_user_id); purple_debug_info("mra", "[%s] Remove user %s (%s), user_id: %d\n", __func__, email, name, user_id); /* FIXME */ mra_net_send_change_user(mmp, user_id, group_id, email, name, CONTACT_FLAG_REMOVED); } /************************************************************************************************** Alias buddy **************************************************************************************************/ void mra_alias_buddy(PurpleConnection *gc, const char *name, const char *alias) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ purple_debug_info("mra", "[%s] name: %s, alias: %s\n", __func__, name, alias); /* FIXME */ g_return_if_fail(gc != NULL); g_return_if_fail(alias != NULL); mra_serv_conn *mmp = gc->proto_data; PurpleBuddy *buddy; gpointer buddy_user_id; uint32_t user_id; uint32_t group_id = 0; g_return_if_fail(mmp != NULL); g_return_if_fail(mmp->acct != NULL); g_return_if_fail(mmp->users != NULL); buddy = purple_find_buddy(mmp->acct, name); if (buddy == NULL) { purple_debug_info("mra", "[%s] I can't rename buddy because I can't find name!\n", __func__); /* FIXME */ return; } buddy_user_id = g_hash_table_lookup(mmp->users, name); if (buddy_user_id == NULL) { purple_debug_info("mra", "[%s] I can't remove user because I can't find user_id!\n", __func__); /* FIXME */ return; } user_id = atol(buddy_user_id); purple_debug_info("mra", "[%s] Rename user %s (%d) to '%s'\n", __func__, name, user_id, alias); /* FIXME */ // purple_blist_alias_buddy(buddy, alias); mra_net_send_change_user(mmp, user_id, group_id, (char *) name, (char *) alias, 0); } /************************************************************************************************** Get Anleta Info **************************************************************************************************/ void mra_get_anketa(PurpleConnection *gc, const char *who) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ g_return_if_fail(gc != NULL); mra_serv_conn *mmp = gc->proto_data; g_return_if_fail(mmp != NULL); mra_net_send_anketa_info(mmp, who); } /************************************************************************************************** Connect to server **************************************************************************************************/ void mra_login(PurpleAccount *acct) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ gchar *server = NULL; int port = 0; const char *username = NULL; g_return_if_fail(acct != NULL); PurpleConnection *gc = purple_account_get_connection(acct); g_return_if_fail(gc != NULL); username = purple_account_get_username(acct); mra_serv_conn *mmp; purple_debug_info("mra", "[%s] Try to connect to server\n", __func__); /* FIXME */ gc->proto_data = mmp = g_new0(mra_serv_conn, 1); mmp->fd = -1; mmp->gc = gc; mmp->acct = acct; mmp->connected = FALSE; mmp->authorized = FALSE; mmp->seq = 0; mmp->users = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); mmp->users_is_authorized = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); mmp->groups = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); mmp->tx_buf = (char *) malloc(MRA_BUF_LEN + 1); mmp->tx_len = 0; mmp->tx_handler = 0; mmp->rx_buf = (char *) malloc(MRA_BUF_LEN + 1); mmp->rx_len = 0; mmp->groups_list = NULL; mmp->contacts_list = NULL; purple_connection_update_progress(gc, _("Connecting"), 1, 3); server = g_strdup(purple_account_get_string(acct, "host", MRA_HOST)); port = purple_account_get_int(acct, "port", MRA_PORT); /* // return error if username is invalid if (!mra_email_is_valid(username)) { purple_debug_error("mra", "[%s] email '%s' is invalid\n", __func__, username); purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, _("Username is invalid")); } else if (strcmp(server, "mrim.mail.ru") == 0) { */ if (strcmp(server, "mrim.mail.ru") == 0) { purple_debug_info("mra", "[%s] Get server to connect to: %s:%u\n", __func__, server, port); /* FIXME */ mra_get_connection_server(mmp, server, port); } else { purple_debug_info("mra", "[%s] Connect directly to server %s:%u\n", __func__, server, port); /* FIXME */ mmp->connect_data = purple_proxy_connect(gc, acct, server, port, mra_connect_cb, gc); if (mmp->connect_data == NULL) { purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Connection problem")); } } g_free(server); } /************************************************************************************************** Close connection **************************************************************************************************/ void mra_close(PurpleConnection *gc) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mra_serv_conn *mmp; g_return_if_fail(gc != NULL); mmp = gc->proto_data; g_return_if_fail(mmp != NULL); if (mmp->ping_timer) { purple_timeout_remove(mmp->ping_timer); } if (mmp->connect_data != NULL) { purple_proxy_connect_cancel(mmp->connect_data); } if (mmp->fd) { close(mmp->fd); } if (mmp->tx_handler) { purple_input_remove(mmp->tx_handler); } if (mmp->users) { g_hash_table_destroy(mmp->users); } if (mmp->users_is_authorized) { g_hash_table_destroy(mmp->users_is_authorized); } if (mmp->groups) { g_hash_table_destroy(mmp->groups); } if (mmp->groups_list) { g_free(mmp->groups_list); } if (mmp->contacts_list) { g_free(mmp->contacts_list); } if (mmp) { g_free(mmp); } gc->proto_data = NULL; purple_connection_set_protocol_data(gc, NULL); purple_prefs_disconnect_by_handle(gc); purple_debug_error("mra", "[%s] connection was closed\n", __func__); /* FIXME */ } /************************************************************************************************** Rerequest auth **************************************************************************************************/ void mra_rerequest_auth(PurpleBlistNode *node, gpointer ignored) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ UNUSED(ignored); PurpleBuddy *buddy; PurpleGroup *group; PurpleConnection *gc; mra_serv_conn *mmp; const char *email; mra_add_buddy_req *data; buddy = (PurpleBuddy *) node; g_return_if_fail(buddy != NULL); group = purple_buddy_get_group(buddy); g_return_if_fail(group != NULL); gc = purple_account_get_connection(purple_buddy_get_account(buddy)); g_return_if_fail(gc != NULL); mmp = gc->proto_data; g_return_if_fail(mmp != NULL); email = purple_buddy_get_name(buddy); data = g_new0(mra_add_buddy_req, 1); data->pc = gc; data->buddy = buddy; data->group = group; purple_request_input(gc, NULL, _("Authorization Request Message:"), NULL, _("Please authorize me!"), TRUE, FALSE, NULL, _("_OK"), G_CALLBACK(mra_add_buddy_ok_cb), _("_Cancel"), NULL, purple_connection_get_account(gc), email, NULL, data); } /************************************************************************************************** Buddy menu **************************************************************************************************/ GList *mra_buddy_menu(PurpleBuddy *buddy) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ PurpleConnection *gc; mra_serv_conn *mmp; GList *menu; PurpleMenuAction *act; char *email; char *authorized; char *user_id; g_return_val_if_fail(buddy != NULL, NULL); gc = purple_account_get_connection(purple_buddy_get_account(buddy)); g_return_val_if_fail(gc != NULL, NULL); menu = NULL; mmp = gc->proto_data; g_return_val_if_fail(mmp != NULL, NULL); g_return_val_if_fail(mmp->users != NULL, NULL); g_return_val_if_fail(mmp->users_is_authorized != NULL, NULL); email = (char *) purple_buddy_get_name(buddy); authorized = g_hash_table_lookup(mmp->users_is_authorized, email); user_id = g_hash_table_lookup(mmp->users, email); if (authorized == NULL && user_id == NULL) { purple_debug_info("mra", "[%s] user %s is not authorized\n", __func__, email); /* FIXME */ act = purple_menu_action_new(_("Re-request Authorization"), PURPLE_CALLBACK(mra_rerequest_auth), NULL, NULL); menu = g_list_prepend(menu, act); } menu = g_list_reverse(menu); return menu; } /************************************************************************************************** Add buddy menu **************************************************************************************************/ GList *mra_blist_node_menu(PurpleBlistNode *node) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ if (PURPLE_BLIST_NODE_IS_BUDDY(node)) { return mra_buddy_menu((PurpleBuddy *) node); } else { return NULL; } } /************************************************************************************************** Add statuses types **************************************************************************************************/ GList *mra_statuses(PurpleAccount *acct) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ UNUSED(acct); GList *types = NULL; PurpleStatusType *status; //Online people have a status message and also a date when it was set status = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE, "ONLINE", _("Online"), FALSE, TRUE, FALSE, "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), "message_date", _("Message changed"), purple_value_new(PURPLE_TYPE_STRING), NULL); types = g_list_append(types, status); //Away people have a status message and also a date when it was set status = purple_status_type_new_with_attrs(PURPLE_STATUS_AWAY, "AWAY", _("Away"), FALSE, TRUE, FALSE, "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), "message_date", _("Message changed"), purple_value_new(PURPLE_TYPE_STRING), NULL); types = g_list_append(types, status); //Unavailable people have a status message and also a date when it was set status = purple_status_type_new_with_attrs(PURPLE_STATUS_UNAVAILABLE, "UNAVIALABLE", _("Unavailable"), FALSE, TRUE, FALSE, "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), "message_date", _("Message changed"), purple_value_new(PURPLE_TYPE_STRING), NULL); types = g_list_append(types, status); //Offline people dont have messages status = purple_status_type_new_full(PURPLE_STATUS_OFFLINE, "OFFLINE", _("Offline"), FALSE, TRUE, FALSE); types = g_list_append(types, status); return types; } /************************************************************************************************** Set mail.ru agent status callback **************************************************************************************************/ void mra_set_status_cb(PurplePluginAction *action) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ UNUSED(action); } /************************************************************************************************** Get anketa info **************************************************************************************************/ void mra_anketa_info_cb(gpointer data, const char *who, mra_anketa_info *anketa) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mra_serv_conn *mmp = data; g_return_if_fail(mmp != NULL); g_return_if_fail(mmp->gc != NULL); PurpleNotifyUserInfo *user_info; user_info = purple_notify_user_info_new(); purple_notify_user_info_add_section_break(user_info); purple_notify_user_info_prepend_pair(user_info, "Phone", anketa->phone); purple_notify_user_info_prepend_pair(user_info, "Location", anketa->location); purple_notify_user_info_prepend_pair(user_info, "Birthday", anketa->birthday); purple_notify_user_info_prepend_pair(user_info, "Sex", ((anketa->sex == 1) ? "Male" : (anketa->sex == 2) ? "Female" : "" )); purple_notify_user_info_prepend_pair(user_info, "Lastname", anketa->lastname); purple_notify_user_info_prepend_pair(user_info, "Firstname", anketa->firstname); purple_notify_user_info_prepend_pair(user_info, "Nickname", anketa->nickname); purple_notify_user_info_prepend_pair(user_info, "Domain", anketa->domain); purple_notify_user_info_prepend_pair(user_info, "Username", anketa->username); purple_notify_user_info_prepend_pair(user_info, "E-Mail", who); purple_notify_userinfo(mmp->gc, who, user_info, 0, 0); purple_notify_user_info_destroy(user_info); } /************************************************************************************************** Actions to provide additional features **************************************************************************************************/ GList *mra_actions(PurplePlugin *plugin, gpointer context) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ UNUSED(plugin); UNUSED(context); GList *m = NULL; // PurplePluginAction *act; // act = purple_plugin_action_new(_("Set Mail.ru Agent status..."), mra_set_status_cb); // m = g_list_append(m, act); return m; } /************************************************************************************************** List of icons **************************************************************************************************/ static const char *mra_list_icon(PurpleAccount *account, PurpleBuddy *buddy) { UNUSED(account); UNUSED(buddy); return "mra"; } /************************************************************************************************** List of emblems **************************************************************************************************/ const char *mra_list_emblem(PurpleBuddy *buddy) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ PurpleConnection *gc; mra_serv_conn *mmp; char *email; char *authorized; char *user_id; g_return_val_if_fail(buddy != NULL, NULL); gc = purple_account_get_connection(purple_buddy_get_account(buddy)); g_return_val_if_fail(gc != NULL, NULL); g_return_val_if_fail(gc->state == PURPLE_CONNECTED, NULL); mmp = gc->proto_data; g_return_val_if_fail(mmp != NULL, NULL); g_return_val_if_fail(mmp->users != NULL, NULL); g_return_val_if_fail(mmp->users_is_authorized != NULL, NULL); email = (char *) purple_buddy_get_name(buddy); authorized = g_hash_table_lookup(mmp->users_is_authorized, email); user_id = g_hash_table_lookup(mmp->users, email); purple_debug_info("mra", "[%s] get %s emblem: %s, id: %s\n", __func__, email, authorized, user_id); /* FIXME */ if (authorized == NULL && user_id == NULL) { purple_debug_info("mra", "[%s] user %s is not authorized\n", __func__, email); /* FIXME */ return "not-authorized"; } return NULL; } /************************************************************************************************** Status text **************************************************************************************************/ char *mra_status_text(PurpleBuddy *buddy) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ PurplePresence *presence; PurpleStatus *status; char *text; char *tmp; g_return_val_if_fail(buddy != NULL, NULL); presence = purple_buddy_get_presence(buddy); g_return_val_if_fail(presence != NULL, NULL); status = purple_presence_get_active_status(presence); g_return_val_if_fail(status != NULL, NULL); tmp = purple_utf8_salvage(purple_status_get_name(status)); text = g_markup_escape_text(tmp, -1); g_free(tmp); return text; } /************************************************************************************************** Load plugin **************************************************************************************************/ gboolean plugin_load(PurplePlugin *plugin) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ UNUSED(plugin); return TRUE; } /************************************************************************************************** Unload plugin **************************************************************************************************/ gboolean plugin_unload(PurplePlugin *plugin) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ UNUSED(plugin); return TRUE; } /************************************************************************************************** Get account text table **************************************************************************************************/ static GHashTable * mra_get_account_text_table(PurpleAccount *acct) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ UNUSED(acct); GHashTable *table; table = g_hash_table_new(g_str_hash, g_str_equal); g_hash_table_insert(table, "login_label", (gpointer)_("Email Address...")); return table; } /************************************************************************************************** Info about Mail.ru Agent protocol - list of functions for actions **************************************************************************************************/ static PurplePluginProtocolInfo prpl_info = { OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, NULL, // user_splits NULL, // protocol_options {"jpg",0,0,50,50,-1,PURPLE_ICON_SCALE_SEND}, // icon_spec mra_list_icon, // list_icon mra_list_emblem, // list_emblems mra_status_text, // status_text NULL, // tooltip_text mra_statuses, // status_types mra_blist_node_menu, // blist_node_menu NULL, // chat_info NULL, // chat_info_defaults mra_login, // login mra_close, // close mra_send_im, // send_im mra_set_info, // set_info mra_send_typing, // send_typing mra_get_anketa, // get_info mra_set_status, // set_status NULL, // set_idle NULL, // change_passwd mra_add_buddy, // add_buddy NULL, // add_buddies mra_remove_buddy, // remove_buddy NULL, // remove_buddies NULL, // add_permit NULL, // add_deny NULL, // rem_permit NULL, // rem_deny NULL, // set_permit_deny NULL, // join_chat NULL, // reject chat invite NULL, // get_chat_name NULL, // chat_invite NULL, // chat_leave NULL, // chat_whisper NULL, // chat_send NULL, // keepalive NULL, // register_user NULL, // get_cb_info NULL, // get_cb_away mra_alias_buddy, // alias_buddy NULL, // group_buddy NULL, // rename_group NULL, // buddy_free NULL, // convo_closed NULL, // normalize NULL, // set_buddy_icon NULL, // remove_group NULL, // get_cb_real_name NULL, // set_chat_topic NULL, // find_blist_chat NULL, // roomlist_get_list NULL, // roomlist_cancel NULL, // roomlist_expand_category NULL, // can_receive_file NULL, // send_file NULL, // new_xfer NULL, // offline_message NULL, // whiteboard_prpl_ops NULL, // send_raw NULL, // roomlist_room_serialize NULL, // unregister_user NULL, // send_attention NULL, // attention_types sizeof(PurplePluginProtocolInfo), // struct_size mra_get_account_text_table, // get_account_text_table NULL, // initiate_media #if PURPLE_MAJOR_VERSION >= 2 && PURPLE_MINOR_VERSION >= 7 NULL, // can_do_media NULL, // get_moods NULL, // set_public_alias NULL // get_public_alias #else NULL // can_do_media #endif }; /************************************************************************************************** Initialize plugin **************************************************************************************************/ static void plugin_init(PurplePlugin *plugin) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ this_plugin = plugin; // initialize variables and structs PurpleAccountOption *option; PurplePluginInfo *info = plugin->info; PurplePluginProtocolInfo *prpl_info = info->extra_info; // user defined variable: server to connect (mrim14.mail.ru) option = purple_account_option_string_new(_("Server"), "host", MRA_HOST); prpl_info->protocol_options = g_list_append(prpl_info->protocol_options, option); // user defined variable: port to connect (2041) option = purple_account_option_int_new(_("Port"), "port", MRA_PORT); prpl_info->protocol_options = g_list_append(prpl_info->protocol_options, option); } /************************************************************************************************** Info about plugin **************************************************************************************************/ static PurplePluginInfo info = { PURPLE_PLUGIN_MAGIC, // purple plugin magic PURPLE_MAJOR_VERSION, // major version of purple PURPLE_MINOR_VERSION, // minor version of purple PURPLE_PLUGIN_PROTOCOL, // type NULL, // ui_requirement 0, // flags NULL, // dependencies PURPLE_PRIORITY_DEFAULT, // priority "prpl-mra", // id "Mail.ru Agent", // name "0.1", // version "Connects to the Mail.ru Agent protocol", // summary "Connects to the Mail.ru Agent protocol", // description "Vladimir Rudnyh ", // author "http://agent.mail.ru/", // homepage plugin_load, // load plugin_unload, // unload NULL, // destroy NULL, // ui_info &prpl_info, // extra_info NULL, // prefs_info mra_actions, // actions NULL, // padding NULL, NULL, NULL }; // and now we will go and initialize our plugin PURPLE_INIT_PLUGIN(mra, plugin_init, info); pidgin-mra-20100304/src/libmra.h0000664000000000000000000001235411773017044014713 0ustar rootroot/* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Special thanx to Aleksey B. Copyright (C) 2010, Vladimir Rudnyh */ #ifndef _MRA_H_ #define _MRA_H_ #define VERSION_TXT "pidgin-mra 0.1.4" #define MRA_HOST "mrim.mail.ru" #define MRA_PORT 2042 #define MRA_BUF_LEN 65536 #define MAX_GROUP 20 #define TYPING_TIMEOUT 10 /* This one is needed to prevent "implicit declaration of function ‘strptime’" warning */ #define _GNU_SOURCE /* This one is used to prevent "unused parameter X" warnings */ #define UNUSED(expr) do { (void)(expr); } while (0) #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef struct _mra_user_info { uint32_t weather_city; uint32_t messages_total; uint32_t messages_unread; char *mrim_nickname; char *client_endpoint; } mra_user_info; typedef struct _mra_anketa_info { char *username; char *domain; char *nickname; char *firstname; char *lastname; unsigned short sex; char *birthday; unsigned int city_id; char *location; unsigned short zodiak; unsigned short bmounth; unsigned short bday; unsigned short country_id; char *phone; unsigned short age; } mra_anketa_info; typedef struct _mra_contact { uint32_t id; uint32_t status; gchar *email; gchar *nickname; uint32_t flags; uint32_t group_id; uint32_t intflags; gboolean removed; gboolean skip_user; } mra_contact; typedef struct _mra_group { uint32_t id; gchar *name; uint32_t flags; gboolean removed; } mra_group; typedef struct _mra_auth_request { gpointer mmp; char *email; } mra_auth_request; typedef struct _mra_add_buddy_req { PurpleConnection *pc; PurpleBuddy *buddy; PurpleGroup *group; } mra_add_buddy_req; #include "proto.h" #include "mra_net.h" #define MRA_STATUS_ID_OFFLINE "OFFLINE" #define MRA_STATUS_ID_ONLINE "ONLINE" #define MRA_STATUS_ID_AWAY "AWAY" #define MRA_STATUS_ID_UNDETERMINATED "UNKNOWN" #define MRA_STATUS_ID_INVISIBLE "UNVISIBLE" gboolean mra_email_is_valid(const char *); void mra_get_connection_server_cb(PurpleUtilFetchUrlData *, gpointer, const gchar *, gsize, const gchar *); void mra_get_connection_server(gpointer, const char *, int); void mra_load_avatar_cb(PurpleUtilFetchUrlData *, gpointer, const gchar *, gsize, const gchar *); void mra_load_avatar(gpointer, const char *); void mra_contact_set_status(gpointer, char *, uint32_t); void mra_hello_cb(gpointer); void mra_login_cb(gpointer, uint32_t, char *); void mra_logout_cb(gpointer, char *); void mra_user_info_cb(gpointer, mra_user_info *); void mra_contact_list_cb(gpointer, uint32_t, size_t, mra_group *, size_t, mra_contact *); void mra_user_status_cb(gpointer, char *, uint32_t); void mra_auth_request_add_cb(gpointer data); void mra_auth_request_cancel_cb(gpointer data); void mra_auth_request_cb(gpointer, char *, char *); void mra_typing_notify_cb(gpointer, char *); void mra_message_cb(gpointer, char *, char *, char *, time_t, uint32_t); void mra_anketa_info_cb(gpointer, const char *, mra_anketa_info *); void mra_mail_notify_cb(gpointer, uint32_t); void mra_connect_cb(gpointer, gint, const gchar *); int mra_send_im(PurpleConnection *, const char *, const char *, PurpleMessageFlags); unsigned int mra_send_typing(PurpleConnection *, const char *, PurpleTypingState); void mra_set_status(PurpleAccount *, PurpleStatus *); void mra_add_buddy_ok_cb(mra_add_buddy_req *, char *); void mra_add_buddy_cancel_cb(mra_add_buddy_req *, char *); void mra_add_buddy(PurpleConnection *, PurpleBuddy *, PurpleGroup *); void mra_remove_buddy(PurpleConnection *, PurpleBuddy *, PurpleGroup *); void mra_alias_buddy(PurpleConnection *, const char *, const char *); void mra_login(PurpleAccount *); void mra_close(PurpleConnection *); void mra_get_anketa(PurpleConnection *, const char *); void mra_rerequest_auth(PurpleBlistNode *, gpointer); GList *mra_buddy_menu(PurpleBuddy *); GList *mra_blist_node_menu(PurpleBlistNode *); GList *mra_statuses(PurpleAccount *); void mra_set_status_cb(PurplePluginAction *); GList *mra_actions(PurplePlugin *, gpointer); const char *mralist_emblem(PurpleBuddy *); char *mra_status_text(PurpleBuddy *); gboolean plugin_load(PurplePlugin *); gboolean plugin_unload(PurplePlugin *); #endif /* _MRA_H_ */ pidgin-mra-20100304/src/mra_net.c0000664000000000000000000015615211773017044015072 0ustar rootroot/* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Special thanx to Aleksey B. Copyright (C) 2010, Vladimir Rudnyh */ #include "libmra.h" #include /////////////////////////////////////XXX/////////////////////////////////////////////////////////// #define LPS_DEBUG(c, s) (unsigned char) c[s+3], (unsigned char) c[s+2], (unsigned char) c[s+1], (unsigned char) c[s] char *debug_data(char *data, size_t len) { size_t i; char *buffer = NULL; if (!data) { buffer = strdup("error: data pointer is NULL"); } if (!len) { buffer = strdup("error: zero length"); } if (len > 1048576) { buffer = strdup("error: length exceeds 1M"); } if (buffer) { return buffer; } if (len < 44) { buffer = (char * ) malloc(2 * len + 1); for (i = 0; i < len; i++) { sprintf(buffer + 2 * i + 8, "%02x", (unsigned char) data[i]); } } else { size_t edge = len - 44; buffer = (char * ) malloc(2 * len + 9); sprintf(buffer, "%02x%02x%02x%02x-", LPS_DEBUG(data, 0)); // magic sprintf(buffer + 9, "%02x%02x%02x%02x-", LPS_DEBUG(data, 4)); // proto sprintf(buffer + 18, "%02x%02x%02x%02x-", LPS_DEBUG(data, 8)); // seq sprintf(buffer + 27, "%02x%02x%02x%02x-", LPS_DEBUG(data, 12)); // msg sprintf(buffer + 36, "%02x%02x%02x%02x-", LPS_DEBUG(data, 16)); // dlen sprintf(buffer + 45, "%02x%02x%02x%02x-", LPS_DEBUG(data, 20)); // from sprintf(buffer + 54, "%02x%02x%02x%02x ", LPS_DEBUG(data, 24)); // fromport for (i = 0; i < edge; i++) sprintf(buffer + 2 * i + 63, "%02x", (unsigned char) data[44 + i]); } return buffer; } char *debug_plain(char *data, size_t len) { size_t i; char *buffer; if (!data || len == 0) return "error"; buffer = (char * ) malloc(2 * len + 1); for (i = 0; i < len; i++) { sprintf(buffer + 2 * i, "%02x", (unsigned char) data[i]); } return buffer; } /////////////////////////////////////XXX/////////////////////////////////////////////////////////// /************************************************************************************************** Check pointer **************************************************************************************************/ char *check_p(gpointer data, char *p, char *m, char type) { mra_serv_conn *mmp = data; size_t diff = m - p; if ((type != 'u' && type != 's' && type != 'z') || (type != 'z' && diff < sizeof(u_int))) { purple_debug_info("mra", "[%s] Can't parse data\n", __func__); /* FIXME */ purple_connection_error_reason(mmp->gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Can't parse incoming data")); mra_close(mmp->gc); return NULL; } if (type == 'u') { return p + sizeof(uint32_t); } else if (type == 's') { return p + LPSLENGTH(p) + sizeof(uint32_t); } else { while (p < m) { if (*(p++)=='\0') { return p; } } } return NULL; } /************************************************************************************************** Convert cp1251 string to utf8 **************************************************************************************************/ char *cp1251_to_utf8(const char *text) { gsize br = strlen(text); gsize bw = br * 2; GError *err = NULL; gchar *res; char *conv; const char *p; char *q; conv = g_malloc0(strlen(text) + 1); for (p = text, q = conv; *p; p++) { *q++ = *p; } res = g_convert(conv, strlen(conv), "UTF-8", "WINDOWS-1251", &br, &bw, &err); if(!res) { purple_debug_info("mra", "[%s] Covertion CP1251->UTF8 failed: %s\n", __func__, err->message); /* FIXME */ return conv; } g_free(conv); return res; } /************************************************************************************************** Convert utf8 string to cp1251 **************************************************************************************************/ char *utf8_to_cp1251(const char *text) { gsize br = strlen(text); gsize bw = br * 2; GError *err = NULL; char *conv; conv = g_convert(text, strlen(text), "WINDOWS-1251", "UTF-8", &br, &bw, &err); if(!conv) { purple_debug_info("mra", "[%s] Covertion UTF8->CP1251 failed: %s\n", __func__, err->message); /* FIXME */ return g_strdup(text); } return conv; } /************************************************************************************************** Add '\r' before '\n' **************************************************************************************************/ char *to_crlf(const char *text) { size_t n = 0; const gchar * p; gchar * res; gchar * r; for (p = text; *p; p++) { if(*p == '\n' && *(p - 1) != '\r') n++; } res = (gchar *) g_malloc0(strlen(text) + n + 1); for (p = text, r = res; *p; p++) { if (*p == '\n' && *(p - 1) != '\r') { *r++ = '\r'; } *r++ = *p; } return res; } /************************************************************************************************** Convert string to LPS **************************************************************************************************/ char *mra_net_mklps(const char *sz) { uint32_t len; char *lps = LPSALLOC(strlen(sz)); len = strlen(sz); *((uint32_t *)lps) = len; memcpy(lps + sizeof(uint32_t), sz, strlen(sz)); return lps; } /************************************************************************************************** Convert LPS to string **************************************************************************************************/ char *mra_net_mksz(char *lps) { uint32_t len; char *sz = (char *) malloc(1 + LPSLENGTH(lps)); len = *((uint32_t *)lps); memcpy(sz, lps + sizeof(uint32_t), len); *(sz + len) = 0; return sz; } /************************************************************************************************** Fill client->server header **************************************************************************************************/ void mra_net_fill_cs_header(mrim_packet_header_t *head, uint32_t seq, uint32_t msg, uint32_t len) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ head->proto = PROTO_VERSION; head->magic = CS_MAGIC; head->seq = seq; head->msg = msg; head->dlen = len; head->from = 0; head->fromport = 0; } /************************************************************************************************** Add data to output buffer **************************************************************************************************/ void mra_net_send(gpointer conn, gpointer data, size_t len) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mra_serv_conn *mmp = conn; if(!len || !data) return; mmp->tx_buf = (char *) g_realloc(mmp->tx_buf, mmp->tx_len + len); memcpy(mmp->tx_buf + mmp->tx_len, data, len); mmp->tx_len += len; } /************************************************************************************************** Send all data to server and clear buffer **************************************************************************************************/ gboolean mra_net_send_flush(gpointer conn) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ int ret = 0; char *ddata = NULL; mra_serv_conn *mmp = conn; ret = write(mmp->fd, mmp->tx_buf, mmp->tx_len); ddata = debug_data(mmp->tx_buf, mmp->tx_len); purple_debug_info("mra", "[%s] bytes sent: %d\n", __func__, ret); /* FIXME */ purple_debug_info("mra", "send: %s\n", ddata); /* FIXME */ if (ddata) { g_free(ddata); } if (ret < 0) { return FALSE; } else { mmp->tx_buf = '\0'; mmp->tx_len = 0; return TRUE; } } /************************************************************************************************** Ping timer callback **************************************************************************************************/ gboolean mra_net_ping_timeout_cb(mra_serv_conn *mmp) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ if (mra_net_send_ping(mmp)) return TRUE; else return FALSE; } /************************************************************************************************** Send 'ping' packet **************************************************************************************************/ gboolean mra_net_send_ping(mra_serv_conn *mmp) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mrim_packet_header_t head; mra_net_fill_cs_header(&head, mmp->seq++, MRIM_CS_PING, 0); mra_net_send(mmp, &head, sizeof(head)); return mra_net_send_flush(mmp); } /************************************************************************************************** Send 'hello' packet **************************************************************************************************/ gboolean mra_net_send_hello(mra_serv_conn *mmp) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mrim_packet_header_t head; mra_net_fill_cs_header(&head, mmp->seq++, MRIM_CS_HELLO, 0); mra_net_send(mmp, &head, sizeof(head)); return mra_net_send_flush(mmp); } /************************************************************************************************** Send 'authentificate' packet **************************************************************************************************/ gboolean mra_net_send_auth(mra_serv_conn *mmp, const char *username, const char *password, uint32_t status) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mrim_packet_header_t head; char *username_lps; char *password_lps; char *desc_lps; uint32_t dw = 0; size_t i; gboolean ret = FALSE; // convert username, password and desc to LPS username_lps = mra_net_mklps(username); password_lps = mra_net_mklps(password); desc_lps = mra_net_mklps(VERSION_TXT); mra_net_fill_cs_header(&head, mmp->seq++, MRIM_CS_LOGIN2, LPSSIZE(username_lps) + LPSSIZE(password_lps) + LPSSIZE(desc_lps) + sizeof(uint32_t) * 6); mra_net_send(mmp, &head, sizeof(head)); mra_net_send(mmp, username_lps, LPSSIZE(username_lps)); mra_net_send(mmp, password_lps, LPSSIZE(password_lps)); mra_net_send(mmp, &status, sizeof(status)); mra_net_send(mmp, desc_lps, LPSSIZE(desc_lps)); for (i = 0; i < 5; i++) { mra_net_send(mmp, &dw, sizeof(dw)); } ret = mra_net_send_flush(mmp); g_free(username_lps); g_free(password_lps); g_free(desc_lps); return ret; } /************************************************************************************************** Send 'receive ack' packet **************************************************************************************************/ gboolean mra_net_send_receive_ack(mra_serv_conn *mmp, char *from, uint32_t msg_id) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mrim_packet_header_t head; char *from_lps = mra_net_mklps(from); gboolean ret = FALSE; mra_net_fill_cs_header(&head, mmp->seq++, MRIM_CS_MESSAGE_RECV, LPSSIZE(from_lps) + sizeof(msg_id)); mra_net_send(mmp, &head, sizeof(head)); mra_net_send(mmp, from_lps, LPSSIZE(from_lps)); mra_net_send(mmp, &msg_id, sizeof(msg_id)); ret = mra_net_send_flush(mmp); g_free(from_lps); return ret; } /************************************************************************************************** Send 'message' packet **************************************************************************************************/ gboolean mra_net_send_message(mra_serv_conn *mmp, const char *to, const char *message, uint32_t flags) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mrim_packet_header_t head; char *to_lps; char *message_lps; char *message_rtf_lps; gboolean ret = FALSE; // purple_debug_info("mra", "[ %s ] to: %s\n", __func__, to); /* FIXME */ // purple_debug_info("mra", "[ %s ] message: %s\n", __func__, message); /* FIXME */ // purple_debug_info("mra", "[ %s ] flags: 0x%X\n", __func__, flags); /* FIXME */ to_lps = mra_net_mklps(to); message_lps = mra_net_mklps(to_crlf(utf8_to_cp1251(message))); message_rtf_lps = mra_net_mklps(to_crlf(utf8_to_cp1251(g_strdup(" ")))); mra_net_fill_cs_header(&head, mmp->seq++, MRIM_CS_MESSAGE, sizeof(uint32_t) + LPSSIZE(to_lps) + LPSSIZE(message_lps) + LPSSIZE(message_rtf_lps)); mra_net_send(mmp, &head, sizeof(head)); mra_net_send(mmp, &flags, sizeof(flags)); mra_net_send(mmp, to_lps, LPSSIZE(to_lps)); mra_net_send(mmp, message_lps, LPSSIZE(message_lps)); mra_net_send(mmp, message_rtf_lps, LPSSIZE(message_rtf_lps)); ret = mra_net_send_flush(mmp); g_free(to_lps); g_free(message_lps); g_free(message_rtf_lps); return ret; } /************************************************************************************************** Send 'typing' packet **************************************************************************************************/ gboolean mra_net_send_typing(mra_serv_conn *mmp, const char *to) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mrim_packet_header_t head; char *to_lps; char *message_lps; char *message_rtf_lps; uint32_t flags = MESSAGE_FLAG_NOTIFY; gboolean ret = FALSE; to_lps = mra_net_mklps(to); message_lps = mra_net_mklps(to_crlf(utf8_to_cp1251(" "))); message_rtf_lps = mra_net_mklps(to_crlf(utf8_to_cp1251(" "))); mra_net_fill_cs_header(&head, mmp->seq++, MRIM_CS_MESSAGE, sizeof(uint32_t) + LPSSIZE(to_lps) + LPSSIZE(message_lps) + LPSSIZE(message_rtf_lps)); mra_net_send(mmp, &head, sizeof(head)); mra_net_send(mmp, &flags, sizeof(flags)); mra_net_send(mmp, to_lps, LPSSIZE(to_lps)); mra_net_send(mmp, message_lps, LPSSIZE(message_lps)); mra_net_send(mmp, message_rtf_lps, LPSSIZE(message_rtf_lps)); ret = mra_net_send_flush(mmp); g_free(to_lps); g_free(message_lps); g_free(message_rtf_lps); return ret; } /************************************************************************************************** Send 'remove offline message' packet **************************************************************************************************/ gboolean mra_net_send_delete_offline(mra_serv_conn *mmp, char *uidl) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mrim_packet_header_t head; mra_net_fill_cs_header(&head, mmp->seq++, MRIM_CS_DELETE_OFFLINE_MESSAGE, 8); mra_net_send(mmp, &head, sizeof(head)); mra_net_send(mmp, uidl, 8); return mra_net_send_flush(mmp); } /************************************************************************************************** Send 'auth request accepted' packet **************************************************************************************************/ gboolean mra_net_send_authorize_user(mra_serv_conn *mmp, char *email) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mrim_packet_header_t head; char *email_lps; gboolean ret = FALSE; purple_debug_info("mra", "[%s] email: %s\n", __func__, email); /* FIXME */ email_lps = mra_net_mklps(email); mra_net_fill_cs_header(&head, ++mmp->seq, MRIM_CS_AUTHORIZE, LPSSIZE(email_lps)); mra_net_send(mmp, &head, sizeof(head)); mra_net_send(mmp, email_lps, LPSSIZE(email_lps)); ret = mra_net_send_flush(mmp); g_free(email_lps); return ret; } /************************************************************************************************** Send 'add user into contact list' packet **************************************************************************************************/ gboolean mra_net_send_add_user(mra_serv_conn *mmp, char *email, char *name, uint32_t group_id, uint32_t flags) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mrim_packet_header_t head; char *email_lps; char *name_lps; char *zero_lps; gboolean ret = FALSE; email_lps = mra_net_mklps(email); name_lps = mra_net_mklps(utf8_to_cp1251(name)); zero_lps = mra_net_mklps(" "); mra_net_fill_cs_header(&head, mmp->seq++, MRIM_CS_ADD_CONTACT, sizeof(flags) + sizeof(group_id) + LPSSIZE(email_lps) + LPSSIZE(name_lps) + LPSSIZE(zero_lps)); mra_net_send(mmp, &head, sizeof(head)); mra_net_send(mmp, &flags, sizeof(flags)); mra_net_send(mmp, &group_id, sizeof(group_id)); mra_net_send(mmp, email_lps, LPSSIZE(email_lps)); mra_net_send(mmp, name_lps, LPSSIZE(name_lps)); mra_net_send(mmp, zero_lps, LPSSIZE(zero_lps)); ret = mra_net_send_flush(mmp); g_free(email_lps); g_free(name_lps); g_free(zero_lps); return ret; } /************************************************************************************************** Send 'change user' packet **************************************************************************************************/ gboolean mra_net_send_change_user(mra_serv_conn *mmp, uint32_t user_id, uint32_t group_id, char *email, char *name, uint32_t flags) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mrim_packet_header_t head; char *email_lps; char *name_lps; char *zero_lps; gboolean ret = FALSE; email_lps = mra_net_mklps(email); name_lps = mra_net_mklps(utf8_to_cp1251(name)); zero_lps = mra_net_mklps(" "); mra_net_fill_cs_header(&head, mmp->seq++, MRIM_CS_MODIFY_CONTACT, sizeof(user_id) + sizeof(flags) + sizeof(group_id) + LPSSIZE(email_lps) + LPSSIZE(name_lps) + LPSSIZE(zero_lps)); mra_net_send(mmp, &head, sizeof(head)); mra_net_send(mmp, &user_id, sizeof(user_id)); mra_net_send(mmp, &flags, sizeof(flags)); mra_net_send(mmp, &group_id, sizeof(group_id)); mra_net_send(mmp, email_lps, LPSSIZE(email_lps)); mra_net_send(mmp, name_lps, LPSSIZE(name_lps)); mra_net_send(mmp, zero_lps, LPSSIZE(zero_lps)); ret = mra_net_send_flush(mmp); g_free(email_lps); g_free(name_lps); g_free(zero_lps); return ret; } /************************************************************************************************** Send 'set status' packet **************************************************************************************************/ gboolean mra_net_send_status(mra_serv_conn *mmp, uint32_t status) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ mrim_packet_header_t head; mra_net_fill_cs_header(&head, mmp->seq++, MRIM_CS_CHANGE_STATUS, sizeof(status)); mra_net_send(mmp, &head, sizeof(head)); mra_net_send(mmp, &status, sizeof(status)); return mra_net_send_flush(mmp); } /************************************************************************************************** Send 'anketa info' packet **************************************************************************************************/ gboolean mra_net_send_anketa_info(mra_serv_conn *mmp, const char *who) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ char *c; char *user = NULL; char *domain = NULL; char *user_lps; char *domain_lps; size_t user_len; size_t domain_len; uint32_t param = 0; gboolean ret = FALSE; mrim_packet_header_t head; if ((c = strchr(who, '@')) == 0) return FALSE; user_len = c - who; domain_len = strlen(who) - user_len - 1; user = (char *) malloc(user_len + 1); domain = (char *) malloc(domain_len + 1); strncpy(user, who, user_len); strncpy(domain, who + user_len + 1, domain_len); user[user_len] = 0; domain[domain_len] = 0; user_lps = mra_net_mklps(user); domain_lps = mra_net_mklps(domain); if (domain) { g_free(domain); } if (user) { g_free(user); } mra_net_fill_cs_header(&head, mmp->seq++, MRIM_CS_WP_REQUEST, LPSSIZE(user_lps) + LPSSIZE(domain_lps) + 2 * sizeof(param)); mra_net_send(mmp, &head, sizeof(head)); param = MRIM_CS_WP_REQUEST_PARAM_USER; mra_net_send(mmp, ¶m, sizeof(param)); mra_net_send(mmp, user_lps, LPSSIZE(user_lps)); param = MRIM_CS_WP_REQUEST_PARAM_DOMAIN; mra_net_send(mmp, ¶m, sizeof(param)); mra_net_send(mmp, domain_lps, LPSSIZE(domain_lps)); ret = mra_net_send_flush(mmp); g_free(user_lps); g_free(domain_lps); return ret; } /************************************************************************************************** Read data from socket **************************************************************************************************/ void mra_net_read_cb(gpointer data, gint source, PurpleInputCondition cond) { purple_debug_info("mra", "== %s ==\n", __func__); UNUSED(source); UNUSED(cond); mra_serv_conn *mmp = data; int len; char *buf; char *ddata = NULL; // increase buffer size mmp->rx_buf = g_realloc(mmp->rx_buf, mmp->rx_len + MRA_BUF_LEN + 1); // read data from socket buf = mmp->rx_buf + mmp->rx_len; len = read(mmp->fd, buf, MRA_BUF_LEN); mmp->rx_len = mmp->rx_len + len; ddata = debug_data(mmp->rx_buf, len); purple_debug_info("mra", "[%s] bytes readed: %d\n", __func__, len); /* FIXME */ purple_debug_info("mra", "read: %s\n", ddata); /* FIXME */ if (ddata) { g_free(ddata); } if (len < 0 && errno == EAGAIN) { // read more return; } else if (len < 0) { // connection was lost gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"), g_strerror(errno)); purple_connection_error_reason(mmp->gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); g_free(tmp); return; } else if (len == 0) { // server closed the connection purple_connection_error_reason(mmp->gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Server closed the connection")); return; } // proceed received data while we can do it =) while (mra_net_read_proceed(mmp)); } /************************************************************************************************** Proceed data from socket **************************************************************************************************/ gboolean mra_net_read_proceed(gpointer data) { purple_debug_info("mra", "== %s ==\n", __func__); mra_serv_conn *mmp = data; mrim_packet_header_t *head; size_t packet_len = 0; char *answer; char *next_packet; char *ddata = NULL; // return if no data if (mmp->rx_len == 0) { return FALSE; } // check if data length in input buffer is greater, than MRIM packet header size if (mmp->rx_len < sizeof(mrim_packet_header_t)) { purple_debug_info("mra", "[%s] need more data to procced\n", __func__); /* FIXME */ return FALSE; } // detach MRIM packet header from readed data head = (mrim_packet_header_t *) mmp->rx_buf; // check if we have correct magic if (head->magic != CS_MAGIC) { purple_debug_info("mra", "[%s] wrong magic: 0x%08x\n", __func__, (uint32_t) head->magic); /* FIXME */ purple_debug_info("mra", "data: %s\n", debug_plain(mmp->rx_buf, mmp->rx_len)); /* FIXME */ //TODO: we need to cut wrong data from input buffer here purple_connection_error_reason(mmp->gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Received data is not MRIM packet")); return FALSE; } packet_len = sizeof(mrim_packet_header_t) + head->dlen; purple_debug_info("mra", "[%s] received packet is 0x%08x (length: %d, buf len: %d)\n", __func__, (uint32_t) head->msg, packet_len, mmp->rx_len); /* FIXME */ ddata = debug_data(mmp->rx_buf, packet_len); purple_debug_info("mra", "read: %s\n", ddata); /* FIXME */ if (ddata) { g_free(ddata); } // check if we received full packet if (mmp->rx_len < packet_len) { purple_debug_info("mra", "[%s] need more data to procced\n", __func__); /* FIXME */ return FALSE; } // get answer value answer = mmp->rx_buf + sizeof(mrim_packet_header_t); // proceed packet switch(head->msg) { case MRIM_CS_HELLO_ACK: // 'hello' packet mra_net_read_hello(mmp, answer, head->dlen); break; case MRIM_CS_LOGIN_ACK: // 'login successful' packet mra_net_read_login_successful(mmp, answer, head->dlen); break; case MRIM_CS_LOGIN_REJ: // 'login failed' packet mra_net_read_login_failed(mmp, answer, head->dlen); break; case MRIM_CS_LOGOUT: // 'logout' packet mra_net_read_logout(mmp, answer, head->dlen); break; case MRIM_CS_USER_INFO: // 'user info' packet mra_net_read_user_info(mmp, answer, head->dlen); break; case MRIM_CS_CONTACT_LIST2: // 'contact list' packet mra_net_read_contact_list(mmp, answer, head->dlen); break; case MRIM_CS_USER_STATUS: // 'user change status' packet mra_net_read_user_status(mmp, answer, head->dlen); break; case MRIM_CS_MESSAGE_ACK: // 'receive message' packet mra_net_read_message(mmp, answer, head->dlen); break; case MRIM_CS_MESSAGE_STATUS: // 'message status' packet mra_net_read_message_status(mmp, answer, head->dlen); break; case MRIM_CS_OFFLINE_MESSAGE_ACK: // 'receive offline message' packet mra_net_read_message_offline(mmp, answer, head->dlen); break; case MRIM_CS_ADD_CONTACT_ACK: // 'add new contact ack' packet mra_net_read_add_contact_ack(mmp, answer, head->dlen); break; case MRIM_CS_MODIFY_CONTACT_ACK: // 'add new contact ack' packet mra_net_read_modify_contact_ack(mmp, answer, head->dlen); break; case MRIM_CS_AUTHORIZE_ACK: // 'add new user auth request ack' packet mra_net_read_auth_ack(mmp, answer, head->dlen); break; case MRIM_CS_ANKETA_INFO: // 'anketa info' packet mra_net_read_anketa_info(mmp, answer, head->dlen); break; case MRIM_CS_MAILBOX_STATUS: // 'mailbox_status' packet mra_net_read_mailbox_status(mmp, answer, head->dlen); break; default: // unknown packet purple_debug_info("mra", "[%s] packet type is unknown\n", __func__); /* FIXME */ } // if we have more data in incoming buffer if (mmp->rx_len > packet_len) { // cut proceeded packet purple_debug_info("mra", "[%s] rx_len is %d\n", __func__, mmp->rx_len); /* FIXME */ purple_debug_info("mra", "[%s] packet_len is %d\n", __func__, packet_len); /* FIXME */ next_packet = mmp->rx_buf + packet_len; mmp->rx_len = mmp->rx_len - packet_len; purple_debug_info("mra", "[%s] rx_len is %d now\n", __func__, mmp->rx_len); /* FIXME */ memmove(mmp->rx_buf, next_packet, mmp->rx_len); mmp->rx_buf = g_realloc(mmp->rx_buf, mmp->rx_len); /* XXX */ purple_debug_info("mra", "[%s] where are data in buffer left: %d\n", __func__, mmp->rx_len); /* FIXME */ return TRUE; } else { // else just empty buffer mmp->rx_len = 0; mmp->rx_buf = g_realloc(mmp->rx_buf, MRA_BUF_LEN + 1); /* XXX */ } return FALSE; } /************************************************************************************************** Read 'hello' packet **************************************************************************************************/ void mra_net_read_hello(gpointer data, char *answer, size_t len) { purple_debug_info("mra", "== %s ==\n", __func__); UNUSED(len); mra_serv_conn *mmp = data; uint32_t ping_timeout; // get ping timeout value ping_timeout = *(uint32_t *) answer; // check if ping timeout value is correct if (ping_timeout <= 0 || ping_timeout > 3600) { purple_debug_info("mra", "[%s] wrong ping timeout value: %d\n", __func__, ping_timeout); /* FIXME */ purple_connection_error_reason(mmp->gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Wrong ping interval value")); return; } purple_debug_info("mra", "[%s] %d\n", __func__, ping_timeout); /* FIXME */ // start ping timer mmp->ping_timer = purple_timeout_add(ping_timeout * 1000, (GSourceFunc) mra_net_ping_timeout_cb, mmp); // 'hello' callback mmp->callback_hello(mmp); } /************************************************************************************************** Read 'login successful' packet **************************************************************************************************/ void mra_net_read_login_successful(gpointer data, char *answer, size_t len) { purple_debug_info("mra", "== %s ==\n", __func__); UNUSED(answer); UNUSED(len); mra_serv_conn *mmp = data; mmp->callback_login(mmp, MRA_LOGIN_SUCCESSFUL, NULL); } /************************************************************************************************** Read 'login failed' packet **************************************************************************************************/ void mra_net_read_login_failed(gpointer data, char *answer, size_t len) { purple_debug_info("mra", "== %s ==\n", __func__); UNUSED(len); mra_serv_conn *mmp = data; gchar *reason; reason = cp1251_to_utf8(mra_net_mksz(answer)); mmp->callback_login(mmp, MRA_LOGIN_FAILED, reason); g_free(reason); } /************************************************************************************************** Read 'logout' packet **************************************************************************************************/ void mra_net_read_logout(gpointer data, char *answer, size_t len) { purple_debug_info("mra", "== %s ==\n", __func__); UNUSED(len); mra_serv_conn *mmp = data; gchar *reason; reason = cp1251_to_utf8(mra_net_mksz(answer)); mmp->callback_logout(mmp, reason); g_free(reason); } /************************************************************************************************** Read 'user info' packet **************************************************************************************************/ void mra_net_read_user_info(gpointer data, char *answer, size_t len) { purple_debug_info("mra", "== %s ==\n", __func__); mra_serv_conn *mmp = data; mra_user_info *user_info = (mra_user_info *) malloc(sizeof(mra_user_info)); char *key; char *val; while(len) { key = mra_net_mksz(answer); len -= LPSSIZE(answer); answer += LPSSIZE(answer); val = mra_net_mksz(answer); len -= LPSSIZE(answer); answer += LPSSIZE(answer); if (strcmp(key, "WEATHER.CITY") == 0) { user_info->weather_city = atol(val); } else if (strcmp(key, "MESSAGES.TOTAL") == 0) { user_info->messages_total = atol(val); } else if (strcmp(key, "MESSAGES.UNREAD") == 0) { user_info->messages_unread = atol(val); } else if (strcmp(key, "MRIM.NICKNAME") == 0) { user_info->mrim_nickname = g_strdup(val); } else if (strcmp(key, "client.endpoint") == 0) { user_info->client_endpoint = g_strdup(val); } else { purple_debug_info("mra", "[%s] WARNING! Unknown key. %s = %s\n", __func__, key, val); /* FIXME */ } } mmp->callback_user_info(mmp, user_info); } /************************************************************************************************** Read 'contact list' packet **************************************************************************************************/ void mra_net_read_contact_list(gpointer data, char *answer, size_t len) { purple_debug_info("mra", "== %s ==\n", __func__); mra_serv_conn *mmp = data; mra_group *groups = NULL; mra_contact *contacts = NULL; size_t i, j; char *p; uint32_t status; uint32_t groups_count; char *group_mask; char *contact_mask; const char *known_group_mask = "us"; const char *known_contact_mask = "uussuu"; uint32_t flags; uint32_t intflags; uint32_t user_status; char *name; char *email; uint32_t group_id; uint32_t contact_group_id; size_t group_cnt = 0; size_t contact_cnt = 0; p = answer; // get status of contact list loading status = LPSLENGTH(p); p += sizeof(uint32_t); purple_debug_info("mra", "[%s] contacts read status: %d\n", __func__, status); /* FIXME */ // return error to callback if something wrong if (status != GET_CONTACTS_OK) { mmp->callback_contact_list(mmp, status, 0, NULL, 0, NULL); return; } // get groups count check_p(mmp, p, answer, 'u'); groups_count = LPSLENGTH(p); p += sizeof(uint32_t); purple_debug_info("mra", "[%s] groups count: %d\n", __func__, groups_count); /* FIXME */ // get group mask check_p(mmp, p, answer, 's'); group_mask = mra_net_mksz(p); p += LPSLENGTH(p) + sizeof(uint32_t); purple_debug_info("mra", "[%s] group mask: %s\n", __func__, group_mask); /* FIXME */ // get contact mask check_p(mmp, p, answer, 's'); contact_mask = mra_net_mksz(p); p += LPSLENGTH(p) + sizeof(uint32_t); purple_debug_info("mra", "[%s] contact mask: %s\n", __func__, contact_mask); /* FIXME */ // check if we know group and contact masks if (strncmp(contact_mask, known_contact_mask, strlen(known_contact_mask)) || strncmp(group_mask, known_group_mask, strlen(known_group_mask))) { purple_debug_info("mra", "[%s] contact or group mask is unknown\n", __func__); /* FIXME */ mmp->callback_contact_list(mmp, GET_CONTACTS_INTERR, 0, NULL, 0, NULL); return; } // get all groups data for(i = 0; i < groups_count; i++) { // get group flags check_p(mmp, p, answer, 'u'); flags = *(uint32_t *) p; p += sizeof(uint32_t); // get group name check_p(mmp, p, answer, 's'); name = cp1251_to_utf8(mra_net_mksz(p)); p += LPSLENGTH(p) + sizeof(uint32_t); // check all data j = strlen(known_group_mask); while (j < strlen(group_mask)) p = check_p(mmp, p, answer, group_mask[j++]); purple_debug_info("mra", "[%s] group %s, id %d, flags: %08x\n", __func__, name, i, flags); /* FIXME */ // push group into groups array if group is active flags &= 0x00FFFFFF; groups = (mra_group *) g_realloc(groups, (i + 1) * sizeof(mra_group)); groups[i].id = i; groups[i].name = g_strdup(name); groups[i].flags = flags; groups[i].removed = FALSE; if(flags & CONTACT_FLAG_REMOVED) { purple_debug_info("mra", "[%s] is enabled\n", __func__); /* FIXME */ groups[i].flags = TRUE; } } // get all contacts data while (p < answer + len) { // get contact flags check_p(mmp, p, answer, 'u'); flags = *(uint32_t *) p; p += sizeof(uint32_t); // get contact group check_p(mmp, p, answer, 'u'); group_id = *(uint32_t *) p; p += sizeof(uint32_t); // get contact address check_p(mmp, p, answer, 's'); email = mra_net_mksz(p); p += LPSLENGTH(p) + sizeof(uint32_t); // get contact nickname check_p(mmp, p, answer, 's'); name = cp1251_to_utf8(mra_net_mksz(p)); p += LPSLENGTH(p) + sizeof(uint32_t); // get contact internal flags check_p(mmp, p, answer, 'u'); intflags = *(uint32_t *) p; p += sizeof(uint32_t); // get contact status check_p(mmp, p, answer, 'u'); user_status = *(uint32_t *) p; p += sizeof(uint32_t); // check all data j = strlen(known_contact_mask); while (j < strlen(contact_mask)) p = check_p(mmp, p, answer, contact_mask[j++]); purple_debug_info("mra", "[%s] contact %s (%s), flags: 0x%08x, intflags: 0x%08x, id: %d, group: %d, status: 0x%08x\n", __func__, name, email, flags, intflags, contact_cnt + MAX_GROUP, group_id, user_status); /* FIXME */ // skip contact if something wrong with email if (strstr(email, "@") == NULL) { purple_debug_info("mra", "[%s] email is very strange. we will skip it until we don't know, what to do\n", __func__); /* FIXME */ continue; } for (i = 0; i < contact_cnt; i++) { if (strcmp(email, contacts[i].email) == 0) { purple_debug_info("mra", "[%s] skip user %s\n", __func__, email); /* FIXME */ contacts[i].skip_user = TRUE; if (contacts[i].removed && !(flags & CONTACT_FLAG_REMOVED || flags & CONTACT_FLAG_SHADOW)) { contacts[i].removed = FALSE; } } } // set default contact group contact_group_id = 0; // search for contact group for (i = 0; i < group_cnt; i++) { if (groups[i].id == group_id) { contact_group_id = group_id; } } purple_debug_info("mra", "[%s] is enabled (id: %d)\n", __func__, contact_cnt + MAX_GROUP); /* FIXME */ contacts = (mra_contact *) g_realloc(contacts, (contact_cnt + 1) * sizeof(mra_contact)); contacts[contact_cnt].id = contact_cnt + MAX_GROUP; contacts[contact_cnt].email = g_strdup(email); contacts[contact_cnt].nickname = g_strdup(name); contacts[contact_cnt].flags = flags; contacts[contact_cnt].group_id = contact_group_id; contacts[contact_cnt].intflags = intflags; contacts[contact_cnt].status = user_status; contacts[contact_cnt].skip_user = FALSE; contacts[contact_cnt].removed = FALSE; if (flags & CONTACT_FLAG_REMOVED || flags & CONTACT_FLAG_SHADOW) { contacts[contact_cnt].removed = TRUE; } contact_cnt++; g_free(email); g_free(name); } g_free(group_mask); g_free(contact_mask); mmp->callback_contact_list(mmp, status, group_cnt, groups, contact_cnt, contacts); } /************************************************************************************************** Read 'user status' packet **************************************************************************************************/ void mra_net_read_user_status(gpointer data, char *answer, uint32_t len) { purple_debug_info("mra", "== %s ==\n", __func__); UNUSED(len); mra_serv_conn *mmp = data; uint32_t status; char *email; // get status and email status = *(uint32_t *) answer; answer += sizeof(uint32_t); email = mra_net_mksz(answer); purple_debug_info("mra", "[%s] contact %s new status: 0x%08x\n", __func__, email, status); /* FIXME */ // callback for user status change mmp->callback_user_status(mmp, email, status); g_free(email); } /************************************************************************************************** Read 'message' packet **************************************************************************************************/ void mra_net_read_message(gpointer data, char *answer, uint32_t len) { purple_debug_info("mra", "== %s ==\n", __func__); UNUSED(len); mra_serv_conn *mmp = data; uint32_t msg_id; uint32_t flags; char *from; char *message; char *message_rtf; // parse data msg_id = *(uint32_t *) answer; answer += sizeof(uint32_t); flags = *(uint32_t *) answer; answer += sizeof(uint32_t); from = mra_net_mksz(answer); answer += LPSSIZE(answer); message = cp1251_to_utf8(mra_net_mksz(answer)); message_rtf = mra_net_mksz(answer); purple_debug_info("mra", "[%s] message received from %s (flags: 0x%08x)\n", __func__, from, flags); /* FIXME */ purple_debug_info("mra", "[%s] message is: %s\n", __func__, message); /* FIXME */ // send receive ack if needed if (!(flags & MESSAGE_FLAG_NORECV)) { purple_debug_info("mra", "[%s] need to send receive ack\n", __func__); /* FIXME */ mra_net_send_receive_ack(mmp, from, msg_id); } // proceed message if (flags & MESSAGE_FLAG_AUTHORIZE) { // authorization request purple_debug_info("mra", "[%s] this is authorize request\n", __func__); /* FIXME */ mmp->callback_auth_request(mmp, from, message); } else if (flags & MESSAGE_FLAG_SYSTEM) { // system message purple_debug_info("mra", "[%s] this is system message\n", __func__); /* FIXME */ mmp->callback_message(mmp, from, message, message_rtf, time(NULL), MRA_MESSAGE_TYPE_SYSTEM); } else if (flags & MESSAGE_FLAG_CONTACT) { // contacts list purple_debug_info("mra", "[%s] this is contacts list\n", __func__); /* FIXME */ mmp->callback_message(mmp, from, message, message_rtf, time(NULL), MRA_MESSAGE_TYPE_CONTACTS); } else if (flags & MESSAGE_FLAG_NOTIFY) { // typing notify purple_debug_info("mra", "[%s] this is typing notify\n", __func__); /* FIXME */ mmp->callback_typing_notify(mmp, from); } else { // casual message purple_debug_info("mra", "[%s] this is just a message\n", __func__); /* FIXME */ mmp->callback_message(mmp, from, message, message_rtf, time(NULL), MRA_MESSAGE_TYPE_MESSAGE); } g_free(from); g_free(message); g_free(message_rtf); } /************************************************************************************************** Read 'message status' packet **************************************************************************************************/ void mra_net_read_message_status(gpointer data, char *answer, uint32_t len) { purple_debug_info("mra", "== %s ==\n", __func__); UNUSED(len); mra_serv_conn *mmp = data; uint32_t status; gchar *buf; status = *(uint32_t *) answer; answer += sizeof(uint32_t); if (status > 0) { switch (status) { case MESSAGE_REJECTED_NOUSER: buf = g_strdup_printf("Message is not delivered: user not found."); break; case MESSAGE_REJECTED_INTERR: buf = g_strdup_printf("Message is not delivered: internal server error."); break; case MESSAGE_REJECTED_LIMIT_EXCEEDED: buf = g_strdup_printf("Message is not delivered: offline messages limit exceeded."); break; case MESSAGE_REJECTED_TOO_LARGE: buf = g_strdup_printf("Message is not delivered: message is too large."); break; case MESSAGE_REJECTED_DENY_OFFMSG: buf = g_strdup_printf("Message is not delivered: user does not accept offline messages."); break; default: buf = g_strdup_printf("Message is not delivered: unknown error."); } purple_notify_error(purple_account_get_connection(mmp->acct), NULL, _("Unable to deliver message"), buf); g_free(buf); } purple_debug_info("mra", "[%s] message status received: 0x%X\n", __func__, status); /* FIXME */ } /************************************************************************************************** Read 'message offline' packet **************************************************************************************************/ void mra_net_read_message_offline(gpointer data, char *answer, uint32_t len) { purple_debug_info("mra", "== %s ==\n", __func__); UNUSED(len); mra_serv_conn *mmp = data; char *text; char uidl[8]; char *message; char message_rtf[1] = " "; char *p; char *from; char *date; char *sflags; char *boundary; uint32_t flags; struct tm tm; time_t time; char *oldlocale; from = (char *) g_malloc0(190); date = (char *) g_malloc0(190); sflags = (char *) g_malloc0(190); boundary = (char *) g_malloc0(190); memcpy(uidl, answer, 8); text = mra_net_mksz(answer + 8); p = text; while (*p) { if (strncmp(p, "From:", 5) == 0) { strncpy(from, p + 6, strchr(p, '\n') - p - 6); purple_debug_info("mra", "[%s] from: %s\n", __func__, from); } if (strncmp(p, "Date:", 5) == 0) { strncpy(date, p + 6, strchr(p, '\n') - p - 6); purple_debug_info("mra", "[%s] date: %s\n", __func__, date); } if (strncmp(p, "X-MRIM-Flags:", 13) == 0) { strncpy(sflags, p + 14, strchr(p, '\n') - p - 14); purple_debug_info("mra", "[%s] flags: %s\n", __func__, sflags); } if (strncmp(p, "Boundary:", 9) == 0) { strcpy(boundary, "\n--"); strncpy(boundary + 3, p + 10, strchr(p, '\n') - p - 10); strcat(boundary, "--"); purple_debug_info("mra", "[%s] boundary: %s\n", __func__, boundary); } if (strncmp(p, "\n", 1) == 0) { p++; break; } p = strchr(p, '\n') + 1; } if (sscanf(sflags, "%X", &flags) != 1) { flags = 0; } purple_debug_info("mra", "[%s] parsed flags: 0x%08x\n", __func__, flags); oldlocale = setlocale(LC_TIME, NULL); setlocale(LC_TIME, "C"); strptime(date, "%a, %d %b %Y %H:%M:%S", &tm); setlocale(LC_TIME, oldlocale); time = mktime(&tm); purple_debug_info("mra", "[%s] time: %d\n", __func__, (u_int) time); if(!p) { purple_debug_info("mra", "[%s] invalid message!\n", __func__); return; } message = p; p = strstr(message, boundary); if (p) { *p = '\0'; } message = cp1251_to_utf8(message); purple_debug_info("mra", "[%s] message received from %s (flags: 0x%08x)\n", __func__, from, flags); /* FIXME */ purple_debug_info("mra", "[%s] message is: %s\n", __func__, message); /* FIXME */ if (flags & MESSAGE_FLAG_AUTHORIZE) { // authorization request purple_debug_info("mra", "[%s] this is authorize request\n", __func__); /* FIXME */ mmp->callback_auth_request(mmp, from, message); } else { // message purple_debug_info("mra", "[%s] this is offline message\n", __func__); /* FIXME */ mmp->callback_message(mmp, from, message, message_rtf, time, MRA_MESSAGE_TYPE_MESSAGE); } g_free(text); g_free(message); g_free(from); g_free(date); g_free(sflags); g_free(boundary); mra_net_send_delete_offline(mmp, uidl); } /************************************************************************************************** Read 'add new contact ack' packet **************************************************************************************************/ void mra_net_read_add_contact_ack(gpointer data, char *answer, uint32_t len) { purple_debug_info("mra", "== %s ==\n", __func__); UNUSED(len); mra_serv_conn *mmp = data; uint32_t status; uint32_t user_id; gchar *buf; // get status status = *(uint32_t *) answer; answer += sizeof(status); // get fields_num user_id = *(uint32_t *) answer; answer += sizeof(user_id); if (status > 0) { switch (status) { case CONTACT_OPER_ERROR: buf = g_strdup_printf("User is not added: unknown error."); break; case CONTACT_OPER_INTERR: buf = g_strdup_printf("User is not added: internal server error."); break; case CONTACT_OPER_NO_SUCH_USER: buf = g_strdup_printf("User is not added: unknown user."); break; case CONTACT_OPER_INVALID_INFO: buf = g_strdup_printf("User is not added: invalid data."); break; case CONTACT_OPER_USER_EXISTS: buf = g_strdup_printf("User is not added: user is already exists."); break; case CONTACT_OPER_GROUP_LIMIT: buf = g_strdup_printf("User is not added: group limit."); break; default: buf = g_strdup_printf("Message is not delivered: unknown error."); } purple_notify_error(purple_account_get_connection(mmp->acct), NULL, _("Unable to add user"), buf); g_free(buf); } purple_debug_info("mra", "[%s] contact add ack received\n", __func__); /* FIXME */ } /************************************************************************************************** Read 'modify contact ack' packet **************************************************************************************************/ void mra_net_read_modify_contact_ack(gpointer data, char *answer, uint32_t len) { purple_debug_info("mra", "== %s ==\n", __func__); UNUSED(data); UNUSED(answer); UNUSED(len); purple_debug_info("mra", "[%s] contact modify ack received\n", __func__); /* FIXME */ } /************************************************************************************************** Read 'auth ack' packet **************************************************************************************************/ void mra_net_read_auth_ack(gpointer data, char *answer, uint32_t len) { purple_debug_info("mra", "== %s ==\n", __func__); UNUSED(data); UNUSED(answer); UNUSED(len); purple_debug_info("mra", "[%s] add contact auth ack received\n", __func__); /* FIXME */ } /************************************************************************************************** Read 'anketa info' packet **************************************************************************************************/ void mra_net_read_anketa_info(gpointer data, char *answer, uint32_t len) { purple_debug_info("mra", "== %s ==\n", __func__); /* FIXME */ UNUSED(len); uint32_t i = 0; mra_serv_conn *mmp = data; uint32_t status; uint32_t fields_num; uint32_t max_rows; uint32_t server_time; mra_anketa_info mai; memset(&mai, 0, sizeof(mai)); // get status status = *(uint32_t *) answer; answer += sizeof(status); // get fields_num fields_num = *(uint32_t *) answer; answer += sizeof(fields_num); // get max_rows max_rows = *(uint32_t *) answer; answer += sizeof(max_rows); // get server_time server_time = *(uint32_t *) answer; answer += sizeof(server_time); for (i = 0; i < fields_num; i++) { uint32_t j; char *key = NULL; char *val = NULL; char *answer_temp; for (j = 0, answer_temp = answer; j < fields_num; j++) answer_temp += LPSSIZE(answer_temp); key = cp1251_to_utf8(mra_net_mksz(answer)); val = cp1251_to_utf8(mra_net_mksz(answer_temp)); answer += LPSSIZE(answer); if (strcmp(key, "Username") == 0) { mai.username = g_strdup(val); } else if (strcmp(key, "Domain") == 0) { mai.domain = g_strdup(val); } else if (strcmp(key, "Nickname") == 0) { mai.nickname = g_strdup(val); } else if (strcmp(key, "FirstName") == 0) { mai.firstname = g_strdup(val); } else if (strcmp(key, "LastName") == 0) { mai.lastname = g_strdup(val); } else if (strcmp(key, "Sex") == 0) { mai.sex = atoi(val); } else if (strcmp(key, "Birthday") == 0) { mai.birthday = g_strdup(val); } else if (strcmp(key, "City_id") == 0) { mai.city_id = atoi(val); } else if (strcmp(key, "Location") == 0) { mai.location = g_strdup(val); } else if (strcmp(key, "Zodiac") == 0) { mai.zodiak = atoi(val); } else if (strcmp(key, "BMonth") == 0) { mai.bmounth = atoi(val); } else if (strcmp(key, "BDay") == 0) { mai.bday = atoi(val); } else if (strcmp(key, "Country_id") == 0) { mai.country_id = atoi(val); } else if (strcmp(key, "Phone") == 0) { mai.phone = g_strdup(val); } else if (strcmp(key, "mrim_status") == 0) { } if (key) { g_free(key); } if (val) { g_free(val); } } char *who = (char *) malloc(strlen(mai.username) + strlen(mai.domain) + 2); sprintf(who, "%s@%s", mai.username, mai.domain); mmp->callback_anketa_info(mmp, who, &mai); if (who) { g_free(who); } g_free(mai.phone); g_free(mai.location); g_free(mai.birthday); g_free(mai.lastname); g_free(mai.firstname); g_free(mai.nickname); g_free(mai.domain); g_free(mai.username); } /************************************************************************************************** Read 'mailbox status' packet **************************************************************************************************/ void mra_net_read_mailbox_status(gpointer data, char *answer, uint32_t len) { purple_debug_info("mra", "== %s ==\n", __func__); UNUSED(len); mra_serv_conn *mmp = data; uint32_t status; status = *(uint32_t *) answer; answer += sizeof(uint32_t); mmp->callback_mail_notify(mmp, status); } pidgin-mra-20100304/src/mra_net.h0000664000000000000000000001241711773017044015072 0ustar rootroot/* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Special thanx to Aleksey B. Copyright (C) 2010, Vladimir Rudnyh */ #ifndef _MRA_NET_H_ #define _MRA_NET_H_ #define MRA_LOGIN_SUCCESSFUL 0x0000 #define MRA_LOGIN_FAILED 0x0001 #define MRA_MESSAGE_TYPE_MESSAGE 0x0001 #define MRA_MESSAGE_TYPE_SYSTEM 0x0002 #define MRA_MESSAGE_TYPE_CONTACTS 0x0003 #define LPSLENGTH(s) (*((uint32_t *)(s))) #define LPSSIZE(s) (LPSLENGTH(s) + sizeof(uint32_t)) #define LPSALLOC(c) ((char *) malloc((c) + sizeof(uint32_t))) typedef struct _mra_serv_conn { PurpleAccount *acct; PurpleConnection *gc; PurpleProxyConnectData *connect_data; gint fd; gchar *name; GHashTable *users; GHashTable *users_is_authorized; GHashTable *groups; gboolean connected; gboolean authorized; mra_user_info *user_info; char *mra_server; unsigned int mra_port; unsigned int seq; char *tx_buf; unsigned int tx_len; guint tx_handler; char *rx_buf; unsigned int rx_len; mra_group *groups_list; mra_contact *contacts_list; // handlers guint ping_timer; // callbacks void (*callback_hello)(gpointer); // hello void (*callback_login)(gpointer, uint32_t, gchar*); // auth void (*callback_logout)(gpointer, gchar*); // auth void (*callback_user_info)(gpointer, mra_user_info*); // user info void (*callback_contact_list)(gpointer, uint32_t, size_t, mra_group*, size_t, mra_contact*); // contact list void (*callback_user_status)(gpointer, char*, uint32_t); // user status void (*callback_auth_request)(gpointer, char*, char*); // auth request void (*callback_typing_notify)(gpointer, char*); // typing notify void (*callback_message)(gpointer, char*, char*, char*, time_t, uint32_t); // message void (*callback_anketa_info)(gpointer, const char *, mra_anketa_info *); // anketa info void (*callback_mail_notify)(gpointer, uint32_t); // new mails notify } mra_serv_conn; char *check_p(gpointer, char *, char *, char); char *cp1251_to_utf8(const char *); char *utf8_to_cp1251(const char *); char *to_crlf(const char *); char *mra_net_mklps(const char *); char *mra_net_mksz(char *); void mra_net_fill_cs_header(mrim_packet_header_t *, uint32_t, uint32_t, uint32_t); void mra_net_send(gpointer, gpointer, size_t); gboolean mra_net_send_flush(gpointer); gboolean mra_net_ping_timeout_cb(mra_serv_conn *); gboolean mra_net_send_ping(mra_serv_conn *); gboolean mra_net_send_hello(mra_serv_conn *); gboolean mra_net_send_auth(mra_serv_conn *, const char *, const char *, uint32_t); gboolean mra_net_send_receive_ack(mra_serv_conn *, char *, uint32_t); gboolean mra_net_send_message(mra_serv_conn *, const char *, const char *, uint32_t); gboolean mra_net_send_typing(mra_serv_conn *, const char *); gboolean mra_net_send_authorize_user(mra_serv_conn *, char *); gboolean mra_net_send_add_user(mra_serv_conn *, char *, char *, uint32_t, uint32_t); gboolean mra_net_send_change_user(mra_serv_conn *, uint32_t, uint32_t, char *, char *, uint32_t); gboolean mra_net_send_status(mra_serv_conn *, uint32_t); gboolean mra_net_send_anketa_info(mra_serv_conn *, const char *); void mra_net_read_cb(gpointer, gint, PurpleInputCondition); gboolean mra_net_read_proceed(gpointer); void mra_net_read_hello(gpointer, char *, size_t); void mra_net_read_login_successful(gpointer, char *, size_t); void mra_net_read_login_failed(gpointer, char *, size_t); void mra_net_read_logout(gpointer, char *, size_t); void mra_net_read_user_info(gpointer, char *, size_t); void mra_net_read_contact_list(gpointer, char *, size_t); void mra_net_read_user_status(gpointer, char *, uint32_t); void mra_net_read_message(gpointer, char *, uint32_t); void mra_net_read_message_status(gpointer, char *, uint32_t); void mra_net_read_message_offline(gpointer, char *, uint32_t); void mra_net_read_add_contact_ack(gpointer, char *, uint32_t); void mra_net_read_modify_contact_ack(gpointer, char *, uint32_t); void mra_net_read_auth_ack(gpointer, char *, uint32_t); void mra_net_read_anketa_info(gpointer, char *, uint32_t); void mra_net_read_mailbox_status(gpointer, char *, uint32_t); #endif /* _MRA_NET_H_ */ pidgin-mra-20100304/Makefile0000664000000000000000000000344011773017044014141 0ustar rootrootLIBDIR ?= /usr/lib DATADIR ?= /usr/share LINUX_COMPILER = gcc LIBPURPLE_CFLAGS = -I/usr/include/libpurple -DPURPLE_PLUGINS -DENABLE_NLS GLIB_CFLAGS = $(shell pkg-config --cflags glib-2.0) #Standard stuff here MRA_SOURCES = \ src/mra_net.c \ src/libmra.c all: release ifdef DESTDIR install: install -d -m 0755 ${DESTDIR}${LIBDIR}/purple-2/ install -d -m 0755 ${DESTDIR}${DATADIR}/pixmaps/pidgin/protocols/16/ install -d -m 0755 ${DESTDIR}${DATADIR}/pixmaps/pidgin/protocols/22/ install -d -m 0755 ${DESTDIR}${DATADIR}/pixmaps/pidgin/protocols/48/ install libmra.so ${DESTDIR}${LIBDIR}/purple-2/ install img/mra16.png ${DESTDIR}${DATADIR}/pixmaps/pidgin/protocols/16/mra.png install img/mra22.png ${DESTDIR}${DATADIR}/pixmaps/pidgin/protocols/22/mra.png install img/mra48.png ${DESTDIR}${DATADIR}/pixmaps/pidgin/protocols/48/mra.png uninstall: rm -f ${DESTDIR}${LIBDIR}/purple-2/libmra.so rm -f ${DESTDIR}${DATADIR}/pixmaps/pidgin/protocols/16/mra.png rm -f ${DESTDIR}${DATADIR}/pixmaps/pidgin/protocols/22/mra.png rm -f ${DESTDIR}${DATADIR}/pixmaps/pidgin/protocols/48/mra.png else install: install libmra.so ${LIBDIR}/purple-2/ install img/mra16.png ${DATADIR}/pixmaps/pidgin/protocols/16/mra.png install img/mra22.png ${DATADIR}/pixmaps/pidgin/protocols/22/mra.png install img/mra48.png ${DATADIR}/pixmaps/pidgin/protocols/48/mra.png uninstall: rm -f ${LIBDIR}/purple-2/libmra.so rm -f ${DATADIR}/pixmaps/pidgin/protocols/16/mra.png rm -f ${DATADIR}/pixmaps/pidgin/protocols/22/mra.png rm -f ${DATADIR}/pixmaps/pidgin/protocols/48/mra.png endif clean: rm -f libmra.so libmra.so: ${MRA_SOURCES} ${LINUX_COMPILER} ${LIBPURPLE_CFLAGS} -Wall -Wextra -pthread ${GLIB_CFLAGS} -I. -g3 -O2 -pipe ${MRA_SOURCES} -o libmra.so -shared -fPIC -DPIC release: libmra.so pidgin-mra-20100304/fedora/0000775000000000000000000000000011773017044013740 5ustar rootrootpidgin-mra-20100304/fedora/pidgin-mra.spec0000664000000000000000000000173311773017044016647 0ustar rootrootName: pidgin-mra Version: git20101118 Release: 1%{?dist} Summary: Mail.ru Agent protocol plugin for Pidgin IM Group: Applications/Communications License: GPLv3+ URL: https://github.com/dreadatour/pidgin-mra Source0: %{name}-%{version}.tar.bz2 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: glib2-devel BuildRequires: libpurple-devel Requires: pidgin Requires: libpurple %description This is Mail.ru Agent protocol plugin for Pidgin IM %prep %setup -q chmod 0644 src/*.c src/*.h img/*.png chmod 0644 ChangeLog COPYING INSTALL Makefile README TODO %build make %{?_smp_mflags} LIBDIR=%{_libdir} %install rm -rf %{buildroot} make LIBDIR=%{_libdir} DESTDIR=%{buildroot} install %clean rm -rf %{buildroot} %files %defattr(-,root,root,-) %doc ChangeLog COPYING README TODO %{_libdir}/purple-2/*.so %{_datadir}/pixmaps/pidgin/protocols/*/mra.png %changelog * Thu Nov 18 2010 Alexei Panov - git20101118-1 - Initial build pidgin-mra-20100304/fedora/make-source-archive0000775000000000000000000000037411773017044017524 0ustar rootroot#!/bin/bash APP_NAME=pidgin-mra APP_VERSION=git`date +%Y%m%d` cd ../.. cp -f -r ./$APP_NAME ./$APP_NAME-$APP_VERSION rm -rf ./$APP_NAME-$APP_VERSION/.git tar cfj $APP_NAME-$APP_VERSION.tar.bz2 ./$APP_NAME-$APP_VERSION rm -rf ./$APP_NAME-$APP_VERSION pidgin-mra-20100304/README0000664000000000000000000000017711773017044013365 0ustar rootrootThis is Mail.ru Agent protocol plugin for Pidgin IM Changes ~~~~~~~ 0.1.4 - User avatars added - Mrim server request added