summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Xfire/docs/LICENSE.txt340
-rw-r--r--protocols/Xfire/docs/README.txt10
-rw-r--r--protocols/Xfire/docs/xfirelib.txt22
-rw-r--r--protocols/Xfire/res/Kopie von resource.rc300
-rw-r--r--protocols/Xfire/res/d_xfire.icobin0 -> 4286 bytes
-rw-r--r--protocols/Xfire/res/icon.icobin0 -> 766 bytes
-rw-r--r--protocols/Xfire/res/resource.rc300
-rw-r--r--protocols/Xfire/res/true.icobin0 -> 4286 bytes
-rw-r--r--protocols/Xfire/res/x_fire16x16.icobin0 -> 1150 bytes
-rw-r--r--protocols/Xfire/res/xfire away.icobin0 -> 1150 bytes
-rw-r--r--protocols/Xfire/res/xfire offline.icobin0 -> 1150 bytes
-rw-r--r--protocols/Xfire/res/xfire online.icobin0 -> 1150 bytes
-rw-r--r--protocols/Xfire/src/Jamfile152
-rw-r--r--protocols/Xfire/src/SHA1.cpp263
-rw-r--r--protocols/Xfire/src/SHA1.h116
-rw-r--r--protocols/Xfire/src/Xfire_avatar_loader.cpp86
-rw-r--r--protocols/Xfire/src/Xfire_avatar_loader.h58
-rw-r--r--protocols/Xfire/src/Xfire_base.cpp567
-rw-r--r--protocols/Xfire/src/Xfire_base.h81
-rw-r--r--protocols/Xfire/src/Xfire_game.cpp487
-rw-r--r--protocols/Xfire/src/Xfire_game.h194
-rw-r--r--protocols/Xfire/src/Xfire_gamelist.cpp312
-rw-r--r--protocols/Xfire/src/Xfire_gamelist.h75
-rw-r--r--protocols/Xfire/src/Xfire_icon_mng.cpp216
-rw-r--r--protocols/Xfire/src/Xfire_icon_mng.h70
-rw-r--r--protocols/Xfire/src/Xfire_proxy.cpp96
-rw-r--r--protocols/Xfire/src/Xfire_proxy.h8
-rw-r--r--protocols/Xfire/src/Xfire_voicechat.cpp380
-rw-r--r--protocols/Xfire/src/Xfire_voicechat.h114
-rw-r--r--protocols/Xfire/src/addgamedialog.cpp867
-rw-r--r--protocols/Xfire/src/addgamedialog.h28
-rw-r--r--protocols/Xfire/src/all_statusmsg.cpp398
-rw-r--r--protocols/Xfire/src/all_statusmsg.h7
-rw-r--r--protocols/Xfire/src/authpacket.cpp47
-rw-r--r--protocols/Xfire/src/authpacket.h54
-rw-r--r--protocols/Xfire/src/baseProtocol.h272
-rw-r--r--protocols/Xfire/src/buddyinfo.cpp64
-rw-r--r--protocols/Xfire/src/buddyinfo.h52
-rw-r--r--protocols/Xfire/src/buddylist.cpp373
-rw-r--r--protocols/Xfire/src/buddylist.h100
-rw-r--r--protocols/Xfire/src/buddylistgames2packet.cpp39
-rw-r--r--protocols/Xfire/src/buddylistgames2packet.h46
-rw-r--r--protocols/Xfire/src/buddylistgamespacket.cpp144
-rw-r--r--protocols/Xfire/src/buddylistgamespacket.h61
-rw-r--r--protocols/Xfire/src/buddylistnamespacket.cpp104
-rw-r--r--protocols/Xfire/src/buddylistnamespacket.h61
-rw-r--r--protocols/Xfire/src/buddylistonlinepacket.cpp85
-rw-r--r--protocols/Xfire/src/buddylistonlinepacket.h53
-rw-r--r--protocols/Xfire/src/clanbuddylistnamespacket.cpp112
-rw-r--r--protocols/Xfire/src/clanbuddylistnamespacket.h64
-rw-r--r--protocols/Xfire/src/claninvitationpacket.cpp138
-rw-r--r--protocols/Xfire/src/claninvitationpacket.h61
-rw-r--r--protocols/Xfire/src/client.cpp296
-rw-r--r--protocols/Xfire/src/client.h96
-rw-r--r--protocols/Xfire/src/clientinformationpacket.cpp77
-rw-r--r--protocols/Xfire/src/clientinformationpacket.h55
-rw-r--r--protocols/Xfire/src/clientloginpacket.cpp120
-rw-r--r--protocols/Xfire/src/clientloginpacket.h71
-rw-r--r--protocols/Xfire/src/clientversionpacket.cpp52
-rw-r--r--protocols/Xfire/src/clientversionpacket.h54
-rw-r--r--protocols/Xfire/src/dummyxfiregameresolver.cpp49
-rw-r--r--protocols/Xfire/src/dummyxfiregameresolver.h69
-rw-r--r--protocols/Xfire/src/friendsoffriendlist.cpp111
-rw-r--r--protocols/Xfire/src/friendsoffriendlist.h64
-rw-r--r--protocols/Xfire/src/gameinfopacket.cpp85
-rw-r--r--protocols/Xfire/src/gameinfopacket.h56
-rw-r--r--protocols/Xfire/src/getbuddyinfo.cpp56
-rw-r--r--protocols/Xfire/src/getbuddyinfo.h55
-rw-r--r--protocols/Xfire/src/iniupdater.cpp128
-rw-r--r--protocols/Xfire/src/iniupdater.h10
-rw-r--r--protocols/Xfire/src/invitebuddypacket.cpp93
-rw-r--r--protocols/Xfire/src/invitebuddypacket.h66
-rw-r--r--protocols/Xfire/src/inviterequestpacket.cpp51
-rw-r--r--protocols/Xfire/src/inviterequestpacket.h60
-rw-r--r--protocols/Xfire/src/loginfailedpacket.cpp38
-rw-r--r--protocols/Xfire/src/loginfailedpacket.h47
-rw-r--r--protocols/Xfire/src/loginsuccesspacket.cpp74
-rw-r--r--protocols/Xfire/src/loginsuccesspacket.h51
-rw-r--r--protocols/Xfire/src/m8.h9
-rw-r--r--protocols/Xfire/src/main.cpp3754
-rw-r--r--protocols/Xfire/src/messageackpacket.cpp75
-rw-r--r--protocols/Xfire/src/messageackpacket.h61
-rw-r--r--protocols/Xfire/src/messagepacket.cpp92
-rw-r--r--protocols/Xfire/src/messagepacket.h63
-rw-r--r--protocols/Xfire/src/monitoredobj.cpp41
-rw-r--r--protocols/Xfire/src/monitoredobj.h49
-rw-r--r--protocols/Xfire/src/options.cpp1270
-rw-r--r--protocols/Xfire/src/otherloginpacket.cpp37
-rw-r--r--protocols/Xfire/src/otherloginpacket.h46
-rw-r--r--protocols/Xfire/src/packetlistener.h41
-rw-r--r--protocols/Xfire/src/packetreader.cpp163
-rw-r--r--protocols/Xfire/src/packetreader.h57
-rw-r--r--protocols/Xfire/src/passworddialog.cpp59
-rw-r--r--protocols/Xfire/src/passworddialog.h4
-rw-r--r--protocols/Xfire/src/processbuddyinfo.cpp111
-rw-r--r--protocols/Xfire/src/processbuddyinfo.h7
-rw-r--r--protocols/Xfire/src/pwd_dlg.cpp53
-rw-r--r--protocols/Xfire/src/pwd_dlg.h4
-rw-r--r--protocols/Xfire/src/recvbuddychangednick.cpp48
-rw-r--r--protocols/Xfire/src/recvbuddychangednick.h52
-rw-r--r--protocols/Xfire/src/recvdidpacket.cpp35
-rw-r--r--protocols/Xfire/src/recvdidpacket.h43
-rw-r--r--protocols/Xfire/src/recvoldversionpacket.cpp42
-rw-r--r--protocols/Xfire/src/recvoldversionpacket.h48
-rw-r--r--protocols/Xfire/src/recvprefspacket.cpp107
-rw-r--r--protocols/Xfire/src/recvprefspacket.h81
-rw-r--r--protocols/Xfire/src/recvremovebuddypacket.cpp39
-rw-r--r--protocols/Xfire/src/recvremovebuddypacket.h56
-rw-r--r--protocols/Xfire/src/recvstatusmessagepacket.cpp80
-rw-r--r--protocols/Xfire/src/recvstatusmessagepacket.h57
-rw-r--r--protocols/Xfire/src/resource.h173
-rw-r--r--protocols/Xfire/src/searchbuddy.cpp77
-rw-r--r--protocols/Xfire/src/searchbuddy.h55
-rw-r--r--protocols/Xfire/src/searching4games.cpp741
-rw-r--r--protocols/Xfire/src/sendacceptinvitationpacket.cpp47
-rw-r--r--protocols/Xfire/src/sendacceptinvitationpacket.h51
-rw-r--r--protocols/Xfire/src/senddenyinvitationpacket.cpp27
-rw-r--r--protocols/Xfire/src/senddenyinvitationpacket.h43
-rw-r--r--protocols/Xfire/src/sendgameserverpacket.cpp50
-rw-r--r--protocols/Xfire/src/sendgameserverpacket.h49
-rw-r--r--protocols/Xfire/src/sendgamestatus2packet.cpp74
-rw-r--r--protocols/Xfire/src/sendgamestatus2packet.h56
-rw-r--r--protocols/Xfire/src/sendgamestatuspacket.cpp69
-rw-r--r--protocols/Xfire/src/sendgamestatuspacket.h56
-rw-r--r--protocols/Xfire/src/sendkeepalivepacket.cpp56
-rw-r--r--protocols/Xfire/src/sendkeepalivepacket.h48
-rw-r--r--protocols/Xfire/src/sendmessagepacket.cpp103
-rw-r--r--protocols/Xfire/src/sendmessagepacket.h77
-rw-r--r--protocols/Xfire/src/sendnickchangepacket.cpp49
-rw-r--r--protocols/Xfire/src/sendnickchangepacket.h51
-rw-r--r--protocols/Xfire/src/sendremovebuddypacket.cpp46
-rw-r--r--protocols/Xfire/src/sendremovebuddypacket.h46
-rw-r--r--protocols/Xfire/src/sendsidpacket.cpp71
-rw-r--r--protocols/Xfire/src/sendsidpacket.h58
-rw-r--r--protocols/Xfire/src/sendstatusmessagepacket.cpp43
-rw-r--r--protocols/Xfire/src/sendstatusmessagepacket.h52
-rw-r--r--protocols/Xfire/src/sendtypingpacket.cpp103
-rw-r--r--protocols/Xfire/src/sendtypingpacket.h79
-rw-r--r--protocols/Xfire/src/services.cpp81
-rw-r--r--protocols/Xfire/src/services.h18
-rw-r--r--protocols/Xfire/src/setnickname.cpp46
-rw-r--r--protocols/Xfire/src/setnickname.h4
-rw-r--r--protocols/Xfire/src/socket.cpp272
-rw-r--r--protocols/Xfire/src/socket.h67
-rw-r--r--protocols/Xfire/src/socketexception.h45
-rw-r--r--protocols/Xfire/src/stdafx.cpp8
-rw-r--r--protocols/Xfire/src/stdafx.h36
-rw-r--r--protocols/Xfire/src/testclient/Jamfile5
-rw-r--r--protocols/Xfire/src/testclient/test.cpp310
-rw-r--r--protocols/Xfire/src/testclient/test.h60
-rw-r--r--protocols/Xfire/src/tools.cpp1077
-rw-r--r--protocols/Xfire/src/tools.h99
-rw-r--r--protocols/Xfire/src/userdetails.cpp449
-rw-r--r--protocols/Xfire/src/variables.cpp168
-rw-r--r--protocols/Xfire/src/variables.h11
-rw-r--r--protocols/Xfire/src/variablevalue.cpp204
-rw-r--r--protocols/Xfire/src/variablevalue.h65
-rw-r--r--protocols/Xfire/src/xdebug.h149
-rw-r--r--protocols/Xfire/src/xfireclanpacket.cpp79
-rw-r--r--protocols/Xfire/src/xfireclanpacket.h63
-rw-r--r--protocols/Xfire/src/xfirefoundbuddys.cpp92
-rw-r--r--protocols/Xfire/src/xfirefoundbuddys.h65
-rw-r--r--protocols/Xfire/src/xfiregame.cpp27
-rw-r--r--protocols/Xfire/src/xfiregame.h42
-rw-r--r--protocols/Xfire/src/xfiregameresolver.cpp27
-rw-r--r--protocols/Xfire/src/xfiregameresolver.h52
-rw-r--r--protocols/Xfire/src/xfirepacket.cpp145
-rw-r--r--protocols/Xfire/src/xfirepacket.h53
-rw-r--r--protocols/Xfire/src/xfirepacketcontent.cpp30
-rw-r--r--protocols/Xfire/src/xfirepacketcontent.h47
-rw-r--r--protocols/Xfire/src/xfireparse.cpp49
-rw-r--r--protocols/Xfire/src/xfireparse.h37
-rw-r--r--protocols/Xfire/src/xfireprefpacket.cpp50
-rw-r--r--protocols/Xfire/src/xfireprefpacket.h52
-rw-r--r--protocols/Xfire/src/xfirerecvpacketcontent.cpp26
-rw-r--r--protocols/Xfire/src/xfirerecvpacketcontent.h45
-rw-r--r--protocols/Xfire/src/xfiresendpacketcontent.cpp27
-rw-r--r--protocols/Xfire/src/xfiresendpacketcontent.h43
-rw-r--r--protocols/Xfire/src/xfireutils.cpp44
-rw-r--r--protocols/Xfire/src/xfireutils.h40
-rw-r--r--protocols/Xfire/xfire.vcxproj280
-rw-r--r--protocols/Xfire/xfire.vcxproj.filters548
182 files changed, 23732 insertions, 0 deletions
diff --git a/protocols/Xfire/docs/LICENSE.txt b/protocols/Xfire/docs/LICENSE.txt
new file mode 100644
index 0000000000..b8602677e0
--- /dev/null
+++ b/protocols/Xfire/docs/LICENSE.txt
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 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.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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 St, Fifth Floor, Boston, MA 02110-1301 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.
+
+ <signature of Ty Coon>, 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.
diff --git a/protocols/Xfire/docs/README.txt b/protocols/Xfire/docs/README.txt
new file mode 100644
index 0000000000..2f2ab07512
--- /dev/null
+++ b/protocols/Xfire/docs/README.txt
@@ -0,0 +1,10 @@
+More informations and help:
+
+English Miranda forum:
+http://forums.miranda-im.org/showthread.php?17607-Xfire-Protocol-Discussion
+
+German Miranda forum:
+http://forum.miranda-im.de/index.php?topic=7055.0
+
+Latest version:
+http://addons.miranda-im.org/details.php?action=viewfile&id=3701 \ No newline at end of file
diff --git a/protocols/Xfire/docs/xfirelib.txt b/protocols/Xfire/docs/xfirelib.txt
new file mode 100644
index 0000000000..971953ba23
--- /dev/null
+++ b/protocols/Xfire/docs/xfirelib.txt
@@ -0,0 +1,22 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
diff --git a/protocols/Xfire/res/Kopie von resource.rc b/protocols/Xfire/res/Kopie von resource.rc
new file mode 100644
index 0000000000..f94085600b
--- /dev/null
+++ b/protocols/Xfire/res/Kopie von resource.rc
@@ -0,0 +1,300 @@
+#define IDC_STC23 1002
+#define IDC_EDT1 1006
+#define IDC_GRP9 1002
+#define IDC_CHK1 1001
+#define IDC_EDT2 1004
+#define IDC_SCANUPDATE 1003
+#define IDC_STC40 1010
+#define IDC_STC41 1011
+#define IDC_EDT3 1009
+#define IDC_EDT4 1006
+#define IDC_STC22 1001
+#define IDC_GRP12 1009
+#define IDC_GRP13 1004
+#define IDC_GRP14 1003
+#define IDC_STC25 1001
+#define IDC_STC26 1002
+#define IDC_STC33 1004
+#define IDC_STC9 1001
+#define IDC_STC19 1002
+#define IDC_STC20 1003
+#define IDC_STC21 1004
+#define IDC_STC24 1005
+#define IDC_STC28 1002
+#define IDC_STC29 1003
+#define IDC_STC30 1005
+#define IDC_STC31 1001
+#define IDC_STC32 1004
+#define IDC_GRP10 1001
+#define IDC_STC27 1002
+#define IDC_GRP11 1005
+#define IDC_STC15 1003
+#define IDC_STC34 1001
+#define IDC_IMG2 1002
+#define IDC_STC35 1003
+#define IDC_STC14 1001
+#define IDC_STC36 1001
+#define IDC_STC37 1003
+#define IDC_STC38 1005
+#define IDC_STC39 1008
+#define IDC_STC42 1002
+#define IDC_STC43 1004
+#define IDC_STC44 1006
+#define IDC_IMG1 1002
+
+#include "resource.h"
+#include "windows.h"
+
+ID_OP ICON DISCARDABLE "x_fire16x16.ico"
+IDI_TM ICON DISCARDABLE "d_xfire.ico"
+IDI_ONLINE ICON DISCARDABLE "xfire online.ico"
+IDI_OFFLINE ICON DISCARDABLE "xfire offline.ico"
+IDI_AWAY ICON DISCARDABLE "xfire away.ico"
+
+IDD_OPT DIALOGEX 0,0,318,252
+FONT 8,"MS Shell Dlg",0,0,1
+STYLE WS_CHILD|WS_VISIBLE|DS_FIXEDSYS
+EXSTYLE WS_EX_CONTROLPARENT
+BEGIN
+ CONTROL "",IDC_OPTIONSTAB,"SysTabControl32",WS_VISIBLE|WS_TABSTOP,1,1,316,250
+END
+
+IDD_OPTLOGIN DIALOGEX 0,0,304,235
+FONT 8,"MS Sans Serif",0,0,0
+STYLE WS_CHILD|WS_VISIBLE|DS_FIXEDSYS
+EXSTYLE WS_EX_CONTROLPARENT
+BEGIN
+ CONTROL "",IDC_LOGIN,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL,66,12,100,13,WS_EX_CLIENTEDGE
+ CONTROL "",IDC_PASSWORD,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL|ES_PASSWORD,66,31,100,13,WS_EX_CLIENTEDGE
+ CONTROL "Password:",IDC_STATIC,"Static",WS_CHILD|WS_VISIBLE|WS_GROUP|SS_RIGHT,8,33,56,9
+ CONTROL "Loginname:",IDC_STATIC,"Static",WS_CHILD|WS_VISIBLE|WS_GROUP|SS_RIGHT,16,14,48,9
+ CONTROL "XFire",IDC_GROUPMAIN,"Button",WS_CHILD|WS_VISIBLE|WS_GROUP|BS_GROUPBOX,2,1,300,46
+ CONTROL "Nick:",IDC_STC1,"Static",WS_CHILD|WS_VISIBLE|WS_GROUP|SS_RIGHT,8,88,58,9
+ CONTROL "",IDC_NICK,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL,68,86,100,13,WS_EX_CLIENTEDGE
+ CONTROL "Current Protocolversion:",IDC_STC16,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_RIGHT|0x00000800,178,217,94,11
+ CONTROL "",IDC_PVER,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY,274,217,24,11,WS_EX_CLIENTEDGE
+ CONTROL "",IDC_LASTGAME,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL|ES_CENTER,2,51,298,11
+ CONTROL "Note: You can only change these settings, if you are connected to Xfire.",IDC_STC22,"Static",WS_CHILD|WS_VISIBLE,6,73,290,11
+ CONTROL "Create a new Xfire account on website",IDC_URLNEWACC,"Hyperlink",WS_CHILD|WS_VISIBLE|WS_TABSTOP,170,14,126,9
+ CONTROL "Lost Password?",IDC_LOSTPW,"Hyperlink",WS_CHILD|WS_VISIBLE|WS_TABSTOP,170,33,124,9
+ CONTROL "Account options",IDC_GRP12,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,2,62,300,170
+ CONTROL "Show my friends",IDC_KONFIG_1,"Button",WS_CHILD|WS_VISIBLE|WS_DISABLED|WS_TABSTOP|BS_AUTOCHECKBOX,10,114,282,9
+ CONTROL "Game Status",IDC_GRP13,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,6,103,292,57
+ CONTROL "Show on my profile and miniprofile",IDC_KONFIG_2,"Button",WS_CHILD|WS_VISIBLE|WS_DISABLED|WS_TABSTOP|BS_AUTOCHECKBOX,10,125,282,9
+ CONTROL "Show my game server data",IDC_KONFIG_3,"Button",WS_CHILD|WS_VISIBLE|WS_DISABLED|WS_TABSTOP|BS_AUTOCHECKBOX,10,136,282,9
+ CONTROL "Other Activity",IDC_GRP14,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,6,162,292,35
+ CONTROL "Show my voice chat server to my friends",IDC_KONFIG_5,"Button",WS_CHILD|WS_VISIBLE|WS_DISABLED|WS_TABSTOP|BS_AUTOCHECKBOX,10,173,282,9
+ CONTROL "Show people when I type to them",IDC_KONFIG_6,"Button",WS_CHILD|WS_VISIBLE|WS_DISABLED|WS_TABSTOP|BS_AUTOCHECKBOX,10,184,282,9
+ CONTROL "Show nicknames when available",IDC_KONFIG_4,"Button",WS_CHILD|WS_VISIBLE|WS_DISABLED|WS_TABSTOP|BS_AUTOCHECKBOX,170,88,128,9
+ CONTROL "Show friends of my friends",IDC_KONFIG_7,"Button",WS_CHILD|WS_VISIBLE|WS_DISABLED|WS_TABSTOP|BS_AUTOCHECKBOX,10,147,282,9
+END
+
+IDD_OPTFEAT DIALOGEX 0,0,304,235
+FONT 8,"MS Sans Serif",0,0,0
+STYLE WS_CHILD|WS_VISIBLE|DS_FIXEDSYS
+EXSTYLE WS_EX_CONTROLPARENT
+BEGIN
+ CONTROL "Options",IDC_GRP1,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,2,1,300,133
+ CONTROL "More options",IDC_GRP5,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,2,136,300,98
+ CONTROL "Gameicon:",IDC_STC6,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_RIGHT,4,203,144,11
+ CONTROL "",IDC_CBGICO,"ComboBox",WS_CHILD|WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWNLIST,152,203,106,301
+ CONTROL "Voiceicon:",IDC_STC8,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_RIGHT,4,217,144,11
+ CONTROL "",IDC_CBVICO,"ComboBox",WS_CHILD|WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWNLIST,152,217,106,301
+ CONTROL "Display Error and Infomessage:",IDC_STC12,"Static",WS_CHILD|WS_VISIBLE|SS_RIGHT,4,190,144,9
+ CONTROL "",IDC_NOMSG,"ComboBox",WS_CHILD|WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWNLIST,152,188,106,61
+ CONTROL "Tree1",IDC_TREE,"SysTreeView32",WS_VISIBLE|WS_BORDER|WS_TABSTOP|TVS_FULLROWSELECT|TVS_SHOWSELALWAYS|TVS_DISABLEDRAGDROP|TVS_LINESATROOT|TVS_HASLINES|TVS_HASBUTTONS,6,11,292,120
+ CONTROL "Main group for clan groups:",IDC_STC25,"Static",WS_CHILD|WS_VISIBLE|SS_RIGHT,4,175,144,9
+ CONTROL "",IDC_CLANGROUP,"ComboBox",WS_CHILD|WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWNLIST,152,173,106,61
+ CONTROL "Automatically scan for games:",IDC_STC26,"Static",WS_CHILD|WS_VISIBLE|SS_RIGHT,4,145,144,9
+ CONTROL "",IDC_SCANUPDATECB,"ComboBox",WS_CHILD|WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWNLIST,152,144,106,61
+ CONTROL "",IDC_FOFGROUP,"ComboBox",WS_CHILD|WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWNLIST,152,158,106,61
+ CONTROL "Main group for Friends of Friends:",IDC_STC33,"Static",WS_CHILD|WS_VISIBLE|SS_RIGHT,4,160,144,9
+END
+
+IDD_OPTFEAT2 DIALOGEX 0,0,304,242
+FONT 8,"MS Sans Serif",0,0,0
+STYLE WS_CHILD|WS_VISIBLE|DS_FIXEDSYS
+EXSTYLE WS_EX_CONTROLPARENT
+BEGIN
+ CONTROL "Files",IDC_GRP6,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,2,94,300,102
+ CONTROL "xfire_games.ini",IDC_CHKG,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,8,105,80,9
+ CONTROL "icons.dll",IDC_CHKI,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,8,136,80,9
+ CONTROL "Blocked User List",IDC_GRP8,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,2,1,300,91
+ CONTROL "",IDC_BLOCKUSER,"ListBox",WS_CHILD|WS_VISIBLE|WS_TABSTOP|LBS_NOINTEGRALHEIGHT|LBS_HASSTRINGS|LBS_NOTIFY,6,11,128,78,WS_EX_CLIENTEDGE
+ CONTROL "",IDC_REMUSER,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|0x00000040,138,42,16,15
+ CONTROL "This list contains all your blocked Xfire users. You can remove one, if you wanna allow him to send you a friend request.",IDC_STC9,"Static",WS_CHILD|WS_VISIBLE,160,12,136,74
+ CONTROL "You can simply block someone, if you right click on his friend request in clist and choose Block User ...",IDC_STC19,"Static",WS_CHILD|WS_VISIBLE,160,48,130,39
+ CONTROL "This file is used for the game search, game detection and gameid resolving. It contains all xfire supported games.",IDC_STC20,"Static",WS_CHILD|WS_VISIBLE,92,105,206,28
+ CONTROL "This file contains all original game icons. You can also activate the option for icon downloading, if you dont have it.",IDC_STC21,"Static",WS_CHILD|WS_VISIBLE,92,136,206,26
+ CONTROL "Be sure you put these files in following folder:",IDC_STC24,"Static",WS_CHILD|WS_VISIBLE,8,168,290,9
+ CONTROL "",IDC_FILESSHOULDBE,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY,8,179,290,13,WS_EX_CLIENTEDGE
+END
+
+IDD_OPTFEAT3 DIALOGEX 0,0,304,235
+FONT 8,"MS Sans Serif",0,0,0
+STYLE WS_CHILD|WS_VISIBLE|DS_FIXEDSYS
+EXSTYLE WS_EX_CONTROLPARENT
+BEGIN
+ CONTROL "Status Message",IDC_GRP1,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,2,1,300,214
+ CONTROL "Enable",IDC_ENABLESTSMSG,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,10,14,132,9
+ CONTROL "With this feature, following status message will be set on your other protocol plugins, if you are ingame. So your other buddy's can also see what you play. It will also change the status to occupied, if this option is enabled.",IDC_STC28,"Static",WS_CHILD|WS_VISIBLE,10,38,286,24
+ CONTROL "Following Variables are available: %myxfiregame%, %myxfirevoice%, %myxfireserverip%, %myxfirevoiceip%",IDC_STC29,"Static",WS_CHILD|WS_VISIBLE,10,96,286,19
+ CONTROL "",IDC_STATUSMSG,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_MULTILINE,8,131,286,70,WS_EX_CLIENTEDGE
+ CONTROL "Status message:",IDC_STC30,"Static",WS_CHILD|WS_VISIBLE,10,118,94,9
+ CONTROL "",IDC_STC31,"Static",WS_CHILD|WS_VISIBLE,6,203,134,9
+ CONTROL "Change the status to occupied or dnd",IDC_CHGSTATUS,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,142,14,154,9
+ CONTROL "The status message and status will be reset, if you close the game.",IDC_STC32,"Static",WS_CHILD|WS_VISIBLE,10,72,286,20
+ CONTROL "Prefer dnd when it is available",IDC_DNDFIRST,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,142,25,154,9
+END
+
+IDD_OPTFEAT4 DIALOGEX 0,0,304,235
+FONT 8,"MS Sans Serif",0,0,0
+STYLE WS_CHILD|WS_VISIBLE|DS_FIXEDSYS
+EXSTYLE WS_EX_CONTROLPARENT
+BEGIN
+ CONTROL "",IDC_LGAMELIST,"ListBox",WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_TABSTOP|LBS_NOINTEGRALHEIGHT|LBS_HASSTRINGS|LBS_SORT|LBS_NOTIFY,6,11,128,200,WS_EX_CLIENTEDGE
+ CONTROL "Games",IDC_GRP10,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,2,0,300,233
+ CONTROL "Game:",IDC_STC27,"Static",WS_CHILD|WS_VISIBLE,162,11,136,9
+ CONTROL "",IDC_GAMENAME,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,162,20,136,11
+ CONTROL "Dont detect this game as running",IDC_DONTDETECT,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,142,55,152,9
+ CONTROL "",IDC_GAMEICO,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_ICON,138,11,22,19
+ CONTROL "Options",IDC_GRP11,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,138,40,160,187
+ CONTROL "Apply",IDC_APPLY,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,142,206,72,17
+ CONTROL "Dont set status message for other protocols",IDC_NOSTATUSMSG,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,142,68,152,9
+ CONTROL "",IDC_TEXTSTATUS,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL|ES_CENTER,142,192,152,11
+ CONTROL "Add new game",IDC_ADDGAME,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,6,212,66,15
+ CONTROL "Remove",IDC_REMOVE,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,74,212,60,15
+ CONTROL "Dont show in start menu",IDC_NOTINSTARTMENU,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,142,81,152,9
+ CONTROL "(manual added)",IDC_MANADDED,"Static",NOT WS_VISIBLE|WS_CHILD,162,31,134,9
+ CONTROL "Extra Command Line Parameters:",IDC_STC15,"Static",WS_CHILD|WS_VISIBLE,142,99,150,9
+ CONTROL "",IDC_EXTRAPARAMS,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL,142,110,152,13,WS_EX_CLIENTEDGE
+ CONTROL "Edit ...",IDC_EDITGAME,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,222,206,72,17
+END
+
+IDD_UD DIALOGEX 0,0,223,159
+FONT 8,"MS Sans Serif",0,0,0
+STYLE WS_CHILD|WS_VISIBLE|DS_FIXEDSYS
+EXSTYLE WS_EX_CONTROLPARENT
+BEGIN
+ CONTROL "Username:",IDC_STC2,"Static",WS_CHILD|WS_VISIBLE,8,18,36,9
+ CONTROL "Nick:",IDC_STC3,"Static",WS_CHILD|WS_VISIBLE,8,9,32,9
+ CONTROL "Game",IDC_GRP2,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,2,44,220,32
+ CONTROL "Voicechat",IDC_GRP3,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,2,77,220,33
+ CONTROL "Name:",IDC_STC4,"Static",WS_CHILD|WS_VISIBLE,30,53,36,9
+ CONTROL "Unreal Tournament 2004",IDC_GAME,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,54,53,134,9
+ CONTROL "IP:",IDC_STC5,"Static",WS_CHILD|WS_VISIBLE,30,64,18,9
+ CONTROL "255.255.255.255",IDC_GIP,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,54,64,54,9
+ CONTROL "Port:",IDC_STC7,"Static",WS_CHILD|WS_VISIBLE,134,64,16,9
+ CONTROL "27770",IDC_GPORT,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,150,64,70,9
+ CONTROL "Unreal Tournament 2004",IDC_VNAME,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,54,88,132,9
+ CONTROL "Name:",IDC_STC10,"Static",WS_CHILD|WS_VISIBLE,30,88,22,9
+ CONTROL "IP:",IDC_STC11,"Static",WS_CHILD|WS_VISIBLE,30,99,18,9
+ CONTROL "255.255.255.255",IDC_VIP,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,54,99,54,9
+ CONTROL "Port:",IDC_STC13,"Static",WS_CHILD|WS_VISIBLE,134,99,16,9
+ CONTROL "27770",IDC_VPORT,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,150,99,70,9
+ CONTROL "Userdetails",IDC_GRP4,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,2,0,112,44
+ CONTROL "dufte",IDC_DNICK,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,46,9,64,9
+ CONTROL "dufte",IDC_DUSERNAME,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,46,18,66,9
+ CONTROL "",IDC_GAMEICO,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_ICON,6,53,22,19
+ CONTROL "",IDC_VOICEICO,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_ICON,6,88,22,19
+ CONTROL "Copy",IDC_COPYGAME,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,190,49,30,11
+ CONTROL "Copy",IDC_COPYVOICE,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,190,83,30,11
+ CONTROL "",IDC_PROFILIMG,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_BITMAP,0,112,222,44
+ CONTROL "",IDC_GAMEINFOLIST,"SysListView32",WS_CHILD|WS_VISIBLE|LVS_REPORT,116,1,106,43,WS_EX_CLIENTEDGE
+END
+
+IDD_PWDLG DIALOGEX 6,5,204,38
+CAPTION "Enter Password"
+FONT 8,"MS Sans Serif",0,0,1
+STYLE WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU|DS_CENTER|DS_MODALFRAME|DS_SETFONT|DS_FIXEDSYS
+EXSTYLE WS_EX_TOPMOST
+BEGIN
+ CONTROL "Password:",IDC_STC17,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_RIGHT,0,12,34,11
+ CONTROL "",IDC_PWNICK,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP,38,0,166,11,WS_EX_CLIENTEDGE
+ CONTROL "",IDC_PWSTRING,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP,38,12,166,11,WS_EX_CLIENTEDGE
+ CONTROL "Join",IDC_BTN4,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,144,25,60,11
+ CONTROL "Nick:",IDC_STC18,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_RIGHT,0,0,34,11
+END
+
+IDD_SETNICKNAME DIALOGEX 0,0,187,42
+CAPTION "Set Nickname"
+FONT 8,"MS Sans Serif",0,0,1
+STYLE WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU|DS_CENTER|DS_MODALFRAME|DS_SETFONT|DS_FIXEDSYS
+BEGIN
+ CONTROL "",IDC_NICKNAME,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL,5,5,177,12,WS_EX_CLIENTEDGE
+ CONTROL "OK",IDOK,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_DEFPUSHBUTTON,36,23,50,14
+ CONTROL "Cancel",IDCANCEL,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,102,23,50,14
+END
+
+IDD_UPDATE DIALOGEX 0,0,188,107
+CAPTION "New xfire_games.ini"
+FONT 8,"MS Sans Serif",0,0,1
+STYLE WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU|DS_CENTER|DS_MODALFRAME|DS_SETFONT|DS_FIXEDSYS
+BEGIN
+ CONTROL "There is a new XFire Gamelist online, do you want to update now?",IDC_STC34,"Static",WS_CHILD|WS_VISIBLE,30,5,154,19
+ CONTROL 14,IDC_IMG2,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_ICON,4,3,22,19
+ CONTROL "New supported Games:",IDC_STC35,"Static",WS_CHILD|WS_VISIBLE,6,29,124,9
+ CONTROL "Update",IDOK,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_DEFPUSHBUTTON,36,88,50,15
+ CONTROL "Cancel",IDCANCEL,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,102,88,50,15
+ CONTROL "",IDC_UPDATEGAMES,"Edit",WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_TABSTOP|ES_READONLY|ES_AUTOVSCROLL|ES_MULTILINE,6,40,178,44,WS_EX_CLIENTEDGE
+END
+
+IDD_ADDGAME DIALOGEX 0,0,196,205
+FONT 8,"MS Sans Serif",0,0,1
+STYLE WS_CHILD|WS_VISIBLE|DS_FIXEDSYS
+EXSTYLE WS_EX_CONTROLPARENT
+BEGIN
+ CONTROL "Add Game",IDOK,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,4,186,50,15
+ CONTROL "Cancel",IDCANCEL,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,142,186,50,15
+ CONTROL "",IDC_GAMELIST,"ListBox",WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_TABSTOP|LBS_NOINTEGRALHEIGHT|LBS_HASSTRINGS|LBS_SORT|LBS_NOTIFY,4,33,186,148,WS_EX_CLIENTEDGE
+ CONTROL "",IDC_PROGRESS,"msctls_progress32",WS_CHILD|WS_VISIBLE,6,96,184,13
+ CONTROL "",IDC_SEARCH,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP,4,14,186,13,WS_EX_CLIENTEDGE
+ CONTROL "Search:",IDC_STC14,"Static",WS_CHILD|WS_VISIBLE,4,3,186,9
+ CONTROL "Custom ...",IDC_CUSTOM,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,56,186,50,15
+END
+
+IDD_ADDGAME2 DIALOGEX 0,0,196,205
+FONT 8,"MS Sans Serif",0,0,1
+STYLE WS_CHILD|WS_VISIBLE|DS_FIXEDSYS
+EXSTYLE WS_EX_CONTROLPARENT
+BEGIN
+ CONTROL "Add Game",IDOK,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_DEFPUSHBUTTON,4,186,50,15
+ CONTROL "Cancel",IDCANCEL,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,142,186,50,15
+ CONTROL "Game name:",IDC_STC36,"Static",WS_CHILD|WS_VISIBLE,4,3,188,9
+ CONTROL "",IDC_ADD_NAME,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL,4,14,186,13,WS_EX_CLIENTEDGE
+ CONTROL "",IDC_ADD_DETECTEXE,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL,4,42,136,13,WS_EX_CLIENTEDGE
+ CONTROL "Game exe:",IDC_STC37,"Static",WS_CHILD|WS_VISIBLE,4,31,188,9
+ CONTROL "Browse ...",IDC_ADD_BROWSEDETECT,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,144,42,48,14
+ CONTROL "Launcher exe (optional):",IDC_STC38,"Static",WS_CHILD|WS_VISIBLE,4,59,188,9
+ CONTROL "",IDC_ADD_LAUNCHEREXE,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL,4,70,136,13,WS_EX_CLIENTEDGE
+ CONTROL "Browse ...",IDC_ADD_BROWSELAUNCHER,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,144,70,48,14
+ CONTROL "Game id:",IDC_STC39,"Static",WS_CHILD|WS_VISIBLE,4,86,52,9
+ CONTROL "",IDC_ADD_ID,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP,4,97,36,13,WS_EX_CLIENTEDGE
+ CONTROL "?",IDC_GAMEIDHELP,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,42,97,14,13
+ CONTROL "Send game id:",IDC_STC42,"Static",WS_CHILD|WS_VISIBLE,60,86,50,9
+ CONTROL "",IDC_ADD_SENDID,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP,60,97,36,13,WS_EX_CLIENTEDGE
+ CONTROL "?",IDC_SENDIDHELP,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,98,97,14,13
+ CONTROL "Statusmessage for Xfire, if this game will be started:",IDC_STC43,"Static",WS_CHILD|WS_VISIBLE,4,114,188,9
+ CONTROL "",IDC_ADD_STATUSMSG,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL|ES_MULTILINE,4,125,188,56,WS_EX_CLIENTEDGE
+ CONTROL "Parameter:",IDC_STC44,"Static",WS_CHILD|WS_VISIBLE,116,86,74,9
+ CONTROL "",IDC_ADD_CUSTOMPARAMS,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL,116,97,76,13,WS_EX_CLIENTEDGE
+END
+
+IDD_ADDGAMEMAIN DIALOGEX 0,0,199,219
+CAPTION "Add a new game"
+FONT 8,"MS Shell Dlg",0,0,1
+STYLE WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU|DS_CENTER|DS_MODALFRAME|DS_SETFONT|DS_FIXEDSYS
+BEGIN
+ CONTROL "",IDC_OPTIONSTAB,"SysTabControl32",WS_VISIBLE|WS_TABSTOP,1,1,198,218
+END
+
+IDD_SEARCHING DIALOGEX 6,5,198,41
+FONT 8,"MS Sans Serif",0,0,0
+STYLE WS_POPUP|WS_VISIBLE|WS_BORDER|DS_CENTER
+EXSTYLE WS_EX_TOPMOST
+BEGIN
+ CONTROL "Searching games ...",IDC_SEARCHINGLABL,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_CENTER,0,0,196,41
+ CONTROL 14,IDC_IMG1,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_ICON,2,1,46,37
+ CONTROL "",IDC_CURRENTGAME,"Static",WS_CHILD|WS_VISIBLE,44,29,150,9
+END
+
diff --git a/protocols/Xfire/res/d_xfire.ico b/protocols/Xfire/res/d_xfire.ico
new file mode 100644
index 0000000000..6855c0b9dd
--- /dev/null
+++ b/protocols/Xfire/res/d_xfire.ico
Binary files differ
diff --git a/protocols/Xfire/res/icon.ico b/protocols/Xfire/res/icon.ico
new file mode 100644
index 0000000000..0e767a56d8
--- /dev/null
+++ b/protocols/Xfire/res/icon.ico
Binary files differ
diff --git a/protocols/Xfire/res/resource.rc b/protocols/Xfire/res/resource.rc
new file mode 100644
index 0000000000..928c9d8383
--- /dev/null
+++ b/protocols/Xfire/res/resource.rc
@@ -0,0 +1,300 @@
+#define IDC_STC23 1002
+#define IDC_EDT1 1006
+#define IDC_GRP9 1002
+#define IDC_CHK1 1001
+#define IDC_EDT2 1004
+#define IDC_SCANUPDATE 1003
+#define IDC_STC40 1010
+#define IDC_STC41 1011
+#define IDC_EDT3 1009
+#define IDC_EDT4 1006
+#define IDC_STC22 1001
+#define IDC_GRP12 1009
+#define IDC_GRP13 1004
+#define IDC_GRP14 1003
+#define IDC_STC25 1001
+#define IDC_STC26 1002
+#define IDC_STC33 1004
+#define IDC_STC9 1001
+#define IDC_STC19 1002
+#define IDC_STC20 1003
+#define IDC_STC21 1004
+#define IDC_STC24 1005
+#define IDC_STC28 1002
+#define IDC_STC29 1003
+#define IDC_STC30 1005
+#define IDC_STC31 1001
+#define IDC_STC32 1004
+#define IDC_GRP10 1001
+#define IDC_STC27 1002
+#define IDC_GRP11 1005
+#define IDC_STC15 1003
+#define IDC_STC34 1001
+#define IDC_IMG2 1002
+#define IDC_STC35 1003
+#define IDC_STC14 1001
+#define IDC_STC36 1001
+#define IDC_STC37 1003
+#define IDC_STC38 1005
+#define IDC_STC39 1008
+#define IDC_STC42 1002
+#define IDC_STC43 1004
+#define IDC_STC44 1006
+#define IDC_IMG1 1002
+
+#include "..\src\resource.h"
+#include "windows.h"
+
+ID_OP ICON DISCARDABLE "x_fire16x16.ico"
+IDI_TM ICON DISCARDABLE "d_xfire.ico"
+IDI_ONLINE ICON DISCARDABLE "xfire online.ico"
+IDI_OFFLINE ICON DISCARDABLE "xfire offline.ico"
+IDI_AWAY ICON DISCARDABLE "xfire away.ico"
+
+IDD_OPT DIALOGEX 0,0,318,252
+FONT 8,"MS Shell Dlg",0,0,1
+STYLE WS_CHILD|WS_VISIBLE|DS_FIXEDSYS|DS_SETFONT
+EXSTYLE WS_EX_CONTROLPARENT
+BEGIN
+ CONTROL "",IDC_OPTIONSTAB,"SysTabControl32",WS_VISIBLE|WS_TABSTOP,1,1,316,250
+END
+
+IDD_OPTLOGIN DIALOGEX 0,0,304,235
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+STYLE WS_CHILD|WS_VISIBLE|DS_FIXEDSYS|DS_SETFONT
+EXSTYLE WS_EX_CONTROLPARENT
+BEGIN
+ CONTROL "",IDC_LOGIN,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL,66,12,100,13,WS_EX_CLIENTEDGE
+ CONTROL "",IDC_PASSWORD,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL|ES_PASSWORD,66,31,100,13,WS_EX_CLIENTEDGE
+ CONTROL "Password:",IDC_STATIC,"Static",WS_CHILD|WS_VISIBLE|WS_GROUP|SS_RIGHT,8,33,56,9
+ CONTROL "Loginname:",IDC_STATIC,"Static",WS_CHILD|WS_VISIBLE|WS_GROUP|SS_RIGHT,16,14,48,9
+ CONTROL "XFire",IDC_GROUPMAIN,"Button",WS_CHILD|WS_VISIBLE|WS_GROUP|BS_GROUPBOX,2,1,300,46
+ CONTROL "Nick:",IDC_STC1,"Static",WS_CHILD|WS_VISIBLE|WS_GROUP|SS_RIGHT,8,88,58,9
+ CONTROL "",IDC_NICK,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL,68,86,100,13,WS_EX_CLIENTEDGE
+ CONTROL "Current Protocolversion:",IDC_STC16,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_RIGHT|0x00000800,178,217,94,11
+ CONTROL "",IDC_PVER,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY,274,217,24,11,WS_EX_CLIENTEDGE
+ CONTROL "",IDC_LASTGAME,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL|ES_CENTER,2,51,298,11
+ CONTROL "Note: You can only change these settings, if you are connected to Xfire.",IDC_STC22,"Static",WS_CHILD|WS_VISIBLE,6,73,290,11
+ CONTROL "Create a new Xfire account on website",IDC_URLNEWACC,"Hyperlink",WS_CHILD|WS_VISIBLE|WS_TABSTOP,170,14,126,9
+ CONTROL "Lost Password?",IDC_LOSTPW,"Hyperlink",WS_CHILD|WS_VISIBLE|WS_TABSTOP,170,33,124,9
+ CONTROL "Account options",IDC_GRP12,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,2,62,300,170
+ CONTROL "Show my friends",IDC_KONFIG_1,"Button",WS_CHILD|WS_VISIBLE|WS_DISABLED|WS_TABSTOP|BS_AUTOCHECKBOX,10,114,282,9
+ CONTROL "Game Status",IDC_GRP13,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,6,103,292,57
+ CONTROL "Show on my profile and miniprofile",IDC_KONFIG_2,"Button",WS_CHILD|WS_VISIBLE|WS_DISABLED|WS_TABSTOP|BS_AUTOCHECKBOX,10,125,282,9
+ CONTROL "Show my game server data",IDC_KONFIG_3,"Button",WS_CHILD|WS_VISIBLE|WS_DISABLED|WS_TABSTOP|BS_AUTOCHECKBOX,10,136,282,9
+ CONTROL "Other Activity",IDC_GRP14,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,6,162,292,35
+ CONTROL "Show my voice chat server to my friends",IDC_KONFIG_5,"Button",WS_CHILD|WS_VISIBLE|WS_DISABLED|WS_TABSTOP|BS_AUTOCHECKBOX,10,173,282,9
+ CONTROL "Show people when I type to them",IDC_KONFIG_6,"Button",WS_CHILD|WS_VISIBLE|WS_DISABLED|WS_TABSTOP|BS_AUTOCHECKBOX,10,184,282,9
+ CONTROL "Show nicknames when available",IDC_KONFIG_4,"Button",WS_CHILD|WS_VISIBLE|WS_DISABLED|WS_TABSTOP|BS_AUTOCHECKBOX,170,88,128,9
+ CONTROL "Show friends of my friends",IDC_KONFIG_7,"Button",WS_CHILD|WS_VISIBLE|WS_DISABLED|WS_TABSTOP|BS_AUTOCHECKBOX,10,147,282,9
+END
+
+IDD_OPTFEAT DIALOGEX 0,0,304,235
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+STYLE WS_CHILD|WS_VISIBLE|DS_FIXEDSYS|DS_SETFONT
+EXSTYLE WS_EX_CONTROLPARENT
+BEGIN
+ CONTROL "Options",IDC_GRP1,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,2,1,300,133
+ CONTROL "More options",IDC_GRP5,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,2,136,300,98
+ CONTROL "Gameicon:",IDC_STC6,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_RIGHT,4,203,144,11
+ CONTROL "",IDC_CBGICO,"ComboBox",WS_CHILD|WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWNLIST,152,203,106,301
+ CONTROL "Voiceicon:",IDC_STC8,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_RIGHT,4,217,144,11
+ CONTROL "",IDC_CBVICO,"ComboBox",WS_CHILD|WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWNLIST,152,217,106,301
+ CONTROL "Display Error and Infomessage:",IDC_STC12,"Static",WS_CHILD|WS_VISIBLE|SS_RIGHT,4,190,144,9
+ CONTROL "",IDC_NOMSG,"ComboBox",WS_CHILD|WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWNLIST,152,188,106,61
+ CONTROL "Tree1",IDC_TREE,"SysTreeView32",WS_VISIBLE|WS_BORDER|WS_TABSTOP|TVS_FULLROWSELECT|TVS_SHOWSELALWAYS|TVS_DISABLEDRAGDROP|TVS_LINESATROOT|TVS_HASLINES|TVS_HASBUTTONS,6,11,292,120
+ CONTROL "Main group for clan groups:",IDC_STC25,"Static",WS_CHILD|WS_VISIBLE|SS_RIGHT,4,175,144,9
+ CONTROL "",IDC_CLANGROUP,"ComboBox",WS_CHILD|WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWNLIST,152,173,106,61
+ CONTROL "Automatically scan for games:",IDC_STC26,"Static",WS_CHILD|WS_VISIBLE|SS_RIGHT,4,145,144,9
+ CONTROL "",IDC_SCANUPDATECB,"ComboBox",WS_CHILD|WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWNLIST,152,144,106,61
+ CONTROL "",IDC_FOFGROUP,"ComboBox",WS_CHILD|WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWNLIST,152,158,106,61
+ CONTROL "Main group for Friends of Friends:",IDC_STC33,"Static",WS_CHILD|WS_VISIBLE|SS_RIGHT,4,160,144,9
+END
+
+IDD_OPTFEAT2 DIALOGEX 0,0,304,242
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+STYLE WS_CHILD|WS_VISIBLE|DS_FIXEDSYS|DS_SETFONT
+EXSTYLE WS_EX_CONTROLPARENT
+BEGIN
+ CONTROL "Files",IDC_GRP6,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,2,94,300,102
+ CONTROL "xfire_games.ini",IDC_CHKG,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,8,105,80,9
+ CONTROL "icons.dll",IDC_CHKI,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,8,136,80,9
+ CONTROL "Blocked User List",IDC_GRP8,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,2,1,300,91
+ CONTROL "",IDC_BLOCKUSER,"ListBox",WS_CHILD|WS_VISIBLE|WS_TABSTOP|LBS_NOINTEGRALHEIGHT|LBS_HASSTRINGS|LBS_NOTIFY,6,11,128,78,WS_EX_CLIENTEDGE
+ CONTROL "",IDC_REMUSER,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|0x00000040,138,42,16,15
+ CONTROL "This list contains all your blocked Xfire users. You can remove one, if you wanna allow him to send you a friend request.",IDC_STC9,"Static",WS_CHILD|WS_VISIBLE,160,12,136,74
+ CONTROL "You can simply block someone, if you right click on his friend request in clist and choose Block User ...",IDC_STC19,"Static",WS_CHILD|WS_VISIBLE,160,48,130,39
+ CONTROL "This file is used for the game search, game detection and gameid resolving. It contains all xfire supported games.",IDC_STC20,"Static",WS_CHILD|WS_VISIBLE,92,105,206,28
+ CONTROL "This file contains all original game icons. You can also activate the option for icon downloading, if you dont have it.",IDC_STC21,"Static",WS_CHILD|WS_VISIBLE,92,136,206,26
+ CONTROL "Be sure you put these files in following folder:",IDC_STC24,"Static",WS_CHILD|WS_VISIBLE,8,168,290,9
+ CONTROL "",IDC_FILESSHOULDBE,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY,8,179,290,13,WS_EX_CLIENTEDGE
+END
+
+IDD_OPTFEAT3 DIALOGEX 0,0,304,235
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+STYLE WS_CHILD|WS_VISIBLE|DS_FIXEDSYS|DS_SETFONT
+EXSTYLE WS_EX_CONTROLPARENT
+BEGIN
+ CONTROL "Status Message",IDC_GRP1,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,2,1,300,214
+ CONTROL "Enable",IDC_ENABLESTSMSG,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,10,14,132,9
+ CONTROL "With this feature, following status message will be set on your other protocol plugins, if you are ingame. So your other buddy's can also see what you play. It will also change the status to occupied, if this option is enabled.",IDC_STC28,"Static",WS_CHILD|WS_VISIBLE,10,38,286,24
+ CONTROL "Following Variables are available: %myxfiregame%, %myxfirevoice%, %myxfireserverip%, %myxfirevoiceip%",IDC_STC29,"Static",WS_CHILD|WS_VISIBLE,10,96,286,19
+ CONTROL "",IDC_STATUSMSG,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_MULTILINE,8,131,286,70,WS_EX_CLIENTEDGE
+ CONTROL "Status message:",IDC_STC30,"Static",WS_CHILD|WS_VISIBLE,10,118,94,9
+ CONTROL "",IDC_STC31,"Static",WS_CHILD|WS_VISIBLE,6,203,134,9
+ CONTROL "Change the status to occupied or dnd",IDC_CHGSTATUS,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,142,14,154,9
+ CONTROL "The status message and status will be reset, if you close the game.",IDC_STC32,"Static",WS_CHILD|WS_VISIBLE,10,72,286,20
+ CONTROL "Prefer dnd when it is available",IDC_DNDFIRST,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,142,25,154,9
+END
+
+IDD_OPTFEAT4 DIALOGEX 0,0,304,235
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+STYLE WS_CHILD|WS_VISIBLE|DS_FIXEDSYS|DS_SETFONT
+EXSTYLE WS_EX_CONTROLPARENT
+BEGIN
+ CONTROL "",IDC_LGAMELIST,"ListBox",WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_TABSTOP|LBS_NOINTEGRALHEIGHT|LBS_HASSTRINGS|LBS_SORT|LBS_NOTIFY,6,11,128,200,WS_EX_CLIENTEDGE
+ CONTROL "Games",IDC_GRP10,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,2,0,300,233
+ CONTROL "Game:",IDC_STC27,"Static",WS_CHILD|WS_VISIBLE,162,11,136,9
+ CONTROL "",IDC_GAMENAME,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,162,20,136,11
+ CONTROL "Dont detect this game as running",IDC_DONTDETECT,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,142,55,152,9
+ CONTROL "",IDC_GAMEICO,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_ICON,138,11,22,19
+ CONTROL "Options",IDC_GRP11,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,138,40,160,187
+ CONTROL "Apply",IDC_APPLY,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,142,206,72,17
+ CONTROL "Dont set status message for other protocols",IDC_NOSTATUSMSG,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,142,68,152,9
+ CONTROL "",IDC_TEXTSTATUS,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL|ES_CENTER,142,192,152,11
+ CONTROL "Add new game",IDC_ADDGAME,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,6,212,66,15
+ CONTROL "Remove",IDC_REMOVE,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,74,212,60,15
+ CONTROL "Dont show in start menu",IDC_NOTINSTARTMENU,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,142,81,152,9
+ CONTROL "(manual added)",IDC_MANADDED,"Static",NOT WS_VISIBLE|WS_CHILD,162,31,134,9
+ CONTROL "Extra Command Line Parameters:",IDC_STC15,"Static",WS_CHILD|WS_VISIBLE,142,99,150,9
+ CONTROL "",IDC_EXTRAPARAMS,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL,142,110,152,13,WS_EX_CLIENTEDGE
+ CONTROL "Edit ...",IDC_EDITGAME,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,222,206,72,17
+END
+
+IDD_UD DIALOGEX 0,0,223,159
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+STYLE WS_CHILD|WS_VISIBLE|DS_FIXEDSYS|DS_SETFONT
+EXSTYLE WS_EX_CONTROLPARENT
+BEGIN
+ CONTROL "Username:",IDC_STC2,"Static",WS_CHILD|WS_VISIBLE,8,18,36,9
+ CONTROL "Nick:",IDC_STC3,"Static",WS_CHILD|WS_VISIBLE,8,9,32,9
+ CONTROL "Game",IDC_GRP2,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,2,44,220,32
+ CONTROL "Voicechat",IDC_GRP3,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,2,77,220,33
+ CONTROL "Name:",IDC_STC4,"Static",WS_CHILD|WS_VISIBLE,30,53,36,9
+ CONTROL "Unreal Tournament 2004",IDC_GAME,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,54,53,134,9
+ CONTROL "IP:",IDC_STC5,"Static",WS_CHILD|WS_VISIBLE,30,64,18,9
+ CONTROL "255.255.255.255",IDC_GIP,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,54,64,54,9
+ CONTROL "Port:",IDC_STC7,"Static",WS_CHILD|WS_VISIBLE,134,64,16,9
+ CONTROL "27770",IDC_GPORT,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,150,64,70,9
+ CONTROL "Unreal Tournament 2004",IDC_VNAME,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,54,88,132,9
+ CONTROL "Name:",IDC_STC10,"Static",WS_CHILD|WS_VISIBLE,30,88,22,9
+ CONTROL "IP:",IDC_STC11,"Static",WS_CHILD|WS_VISIBLE,30,99,18,9
+ CONTROL "255.255.255.255",IDC_VIP,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,54,99,54,9
+ CONTROL "Port:",IDC_STC13,"Static",WS_CHILD|WS_VISIBLE,134,99,16,9
+ CONTROL "27770",IDC_VPORT,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,150,99,70,9
+ CONTROL "Userdetails",IDC_GRP4,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,2,0,112,44
+ CONTROL "dufte",IDC_DNICK,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,46,9,64,9
+ CONTROL "dufte",IDC_DUSERNAME,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,46,18,66,9
+ CONTROL "",IDC_GAMEICO,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_ICON,6,53,22,19
+ CONTROL "",IDC_VOICEICO,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_ICON,6,88,22,19
+ CONTROL "Copy",IDC_COPYGAME,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,190,49,30,11
+ CONTROL "Copy",IDC_COPYVOICE,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,190,83,30,11
+ CONTROL "",IDC_PROFILIMG,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_BITMAP,0,112,222,44
+ CONTROL "",IDC_GAMEINFOLIST,"SysListView32",WS_CHILD|WS_VISIBLE|LVS_REPORT,116,1,106,43,WS_EX_CLIENTEDGE
+END
+
+IDD_PWDLG DIALOGEX 6,5,204,38
+CAPTION "Enter Password"
+FONT 8,"MS Sans Serif",0,0,1
+STYLE WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU|DS_CENTER|DS_MODALFRAME|DS_SETFONT|DS_FIXEDSYS
+EXSTYLE WS_EX_TOPMOST
+BEGIN
+ CONTROL "Password:",IDC_STC17,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_RIGHT,0,12,34,11
+ CONTROL "",IDC_PWNICK,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP,38,0,166,11,WS_EX_CLIENTEDGE
+ CONTROL "",IDC_PWSTRING,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP,38,12,166,11,WS_EX_CLIENTEDGE
+ CONTROL "Join",IDC_BTN4,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,144,25,60,11
+ CONTROL "Nick:",IDC_STC18,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_RIGHT,0,0,34,11
+END
+
+IDD_SETNICKNAME DIALOGEX 0,0,187,42
+CAPTION "Set Nickname"
+FONT 8,"MS Sans Serif",0,0,1
+STYLE WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU|DS_CENTER|DS_MODALFRAME|DS_SETFONT|DS_FIXEDSYS
+BEGIN
+ CONTROL "",IDC_NICKNAME,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL,5,5,177,12,WS_EX_CLIENTEDGE
+ CONTROL "OK",IDOK,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_DEFPUSHBUTTON,36,23,50,14
+ CONTROL "Cancel",IDCANCEL,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,102,23,50,14
+END
+
+IDD_UPDATE DIALOGEX 0,0,188,107
+CAPTION "New xfire_games.ini"
+FONT 8,"MS Sans Serif",0,0,1
+STYLE WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU|DS_CENTER|DS_MODALFRAME|DS_SETFONT|DS_FIXEDSYS
+BEGIN
+ CONTROL "There is a new XFire Gamelist online, do you want to update now?",IDC_STC34,"Static",WS_CHILD|WS_VISIBLE,30,5,154,19
+ CONTROL 14,IDC_IMG2,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_ICON,4,3,22,19
+ CONTROL "New supported Games:",IDC_STC35,"Static",WS_CHILD|WS_VISIBLE,6,29,124,9
+ CONTROL "Update",IDOK,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_DEFPUSHBUTTON,36,88,50,15
+ CONTROL "Cancel",IDCANCEL,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,102,88,50,15
+ CONTROL "",IDC_UPDATEGAMES,"Edit",WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_TABSTOP|ES_READONLY|ES_AUTOVSCROLL|ES_MULTILINE,6,40,178,44,WS_EX_CLIENTEDGE
+END
+
+IDD_ADDGAME DIALOGEX 0,0,196,205
+FONT 8,"MS Sans Serif",0,0,1
+STYLE WS_CHILD|WS_VISIBLE|DS_FIXEDSYS|DS_SETFONT
+EXSTYLE WS_EX_CONTROLPARENT
+BEGIN
+ CONTROL "Add Game",IDOK,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,4,186,50,15
+ CONTROL "Cancel",IDCANCEL,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,142,186,50,15
+ CONTROL "",IDC_GAMELIST,"ListBox",WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_TABSTOP|LBS_NOINTEGRALHEIGHT|LBS_HASSTRINGS|LBS_SORT|LBS_NOTIFY,4,33,186,148,WS_EX_CLIENTEDGE
+ CONTROL "",IDC_PROGRESS,"msctls_progress32",WS_CHILD|WS_VISIBLE,6,96,184,13
+ CONTROL "",IDC_SEARCH,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP,4,14,186,13,WS_EX_CLIENTEDGE
+ CONTROL "Search:",IDC_STC14,"Static",WS_CHILD|WS_VISIBLE,4,3,186,9
+ CONTROL "Custom ...",IDC_CUSTOM,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,56,186,50,15
+END
+
+IDD_ADDGAME2 DIALOGEX 0,0,196,205
+FONT 8,"MS Sans Serif",0,0,1
+STYLE WS_CHILD|WS_VISIBLE|DS_FIXEDSYS|DS_SETFONT
+EXSTYLE WS_EX_CONTROLPARENT
+BEGIN
+ CONTROL "Add Game",IDOK,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_DEFPUSHBUTTON,4,186,50,15
+ CONTROL "Cancel",IDCANCEL,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,142,186,50,15
+ CONTROL "Game name:",IDC_STC36,"Static",WS_CHILD|WS_VISIBLE,4,3,188,9
+ CONTROL "",IDC_ADD_NAME,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL,4,14,186,13,WS_EX_CLIENTEDGE
+ CONTROL "",IDC_ADD_DETECTEXE,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL,4,42,136,13,WS_EX_CLIENTEDGE
+ CONTROL "Game exe:",IDC_STC37,"Static",WS_CHILD|WS_VISIBLE,4,31,188,9
+ CONTROL "Browse ...",IDC_ADD_BROWSEDETECT,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,144,42,48,14
+ CONTROL "Launcher exe (optional):",IDC_STC38,"Static",WS_CHILD|WS_VISIBLE,4,59,188,9
+ CONTROL "",IDC_ADD_LAUNCHEREXE,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL,4,70,136,13,WS_EX_CLIENTEDGE
+ CONTROL "Browse ...",IDC_ADD_BROWSELAUNCHER,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,144,70,48,14
+ CONTROL "Game id:",IDC_STC39,"Static",WS_CHILD|WS_VISIBLE,4,86,52,9
+ CONTROL "",IDC_ADD_ID,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP,4,97,36,13,WS_EX_CLIENTEDGE
+ CONTROL "?",IDC_GAMEIDHELP,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,42,97,14,13
+ CONTROL "Send game id:",IDC_STC42,"Static",WS_CHILD|WS_VISIBLE,60,86,50,9
+ CONTROL "",IDC_ADD_SENDID,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP,60,97,36,13,WS_EX_CLIENTEDGE
+ CONTROL "?",IDC_SENDIDHELP,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,98,97,14,13
+ CONTROL "Statusmessage for Xfire, if this game will be started:",IDC_STC43,"Static",WS_CHILD|WS_VISIBLE,4,114,188,9
+ CONTROL "",IDC_ADD_STATUSMSG,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL|ES_MULTILINE,4,125,188,56,WS_EX_CLIENTEDGE
+ CONTROL "Parameter:",IDC_STC44,"Static",WS_CHILD|WS_VISIBLE,116,86,74,9
+ CONTROL "",IDC_ADD_CUSTOMPARAMS,"Edit",WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL,116,97,76,13,WS_EX_CLIENTEDGE
+END
+
+IDD_ADDGAMEMAIN DIALOGEX 0,0,199,219
+CAPTION "Add a new game"
+FONT 8,"MS Shell Dlg",0,0,1
+STYLE WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU|DS_CENTER|DS_MODALFRAME|DS_SETFONT|DS_FIXEDSYS
+BEGIN
+ CONTROL "",IDC_OPTIONSTAB,"SysTabControl32",WS_VISIBLE|WS_TABSTOP,1,1,198,218
+END
+
+IDD_SEARCHING DIALOGEX 6,5,198,41
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+STYLE WS_POPUP|WS_VISIBLE|WS_BORDER|DS_CENTER
+EXSTYLE WS_EX_TOPMOST
+BEGIN
+ CONTROL "Searching games ...",IDC_SEARCHINGLABL,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_CENTER,0,0,196,41
+ CONTROL 14,IDC_IMG1,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_ICON,2,1,46,37
+ CONTROL "",IDC_CURRENTGAME,"Static",WS_CHILD|WS_VISIBLE,44,29,150,9
+END
+
diff --git a/protocols/Xfire/res/true.ico b/protocols/Xfire/res/true.ico
new file mode 100644
index 0000000000..c49a58dfa5
--- /dev/null
+++ b/protocols/Xfire/res/true.ico
Binary files differ
diff --git a/protocols/Xfire/res/x_fire16x16.ico b/protocols/Xfire/res/x_fire16x16.ico
new file mode 100644
index 0000000000..b93f1bef0c
--- /dev/null
+++ b/protocols/Xfire/res/x_fire16x16.ico
Binary files differ
diff --git a/protocols/Xfire/res/xfire away.ico b/protocols/Xfire/res/xfire away.ico
new file mode 100644
index 0000000000..cf473325cf
--- /dev/null
+++ b/protocols/Xfire/res/xfire away.ico
Binary files differ
diff --git a/protocols/Xfire/res/xfire offline.ico b/protocols/Xfire/res/xfire offline.ico
new file mode 100644
index 0000000000..008dd67e40
--- /dev/null
+++ b/protocols/Xfire/res/xfire offline.ico
Binary files differ
diff --git a/protocols/Xfire/res/xfire online.ico b/protocols/Xfire/res/xfire online.ico
new file mode 100644
index 0000000000..545aca993a
--- /dev/null
+++ b/protocols/Xfire/res/xfire online.ico
Binary files differ
diff --git a/protocols/Xfire/src/Jamfile b/protocols/Xfire/src/Jamfile
new file mode 100644
index 0000000000..a8bd2d8d8a
--- /dev/null
+++ b/protocols/Xfire/src/Jamfile
@@ -0,0 +1,152 @@
+SubDir TOP src ;
+
+LOCATE_TARGET = bin ;
+Library libxfirelib :
+ SHA1.cpp
+ socket.cpp
+ packetreader.cpp
+ client.cpp
+ xfirepacket.cpp
+ xfirepacketcontent.cpp
+ clientinformationpacket.cpp
+ xfireutils.cpp
+ clientversionpacket.cpp
+ authpacket.cpp
+ xfireparse.cpp
+ variablevalue.cpp
+ clientloginpacket.cpp
+ loginfailedpacket.cpp
+ loginsuccesspacket.cpp
+ messagepacket.cpp
+ buddylistonlinepacket.cpp
+ buddylistnamespacket.cpp
+ buddylistgamespacket.cpp
+ buddylistgames2packet.cpp
+ buddylist.cpp
+ otherloginpacket.cpp
+ messageackpacket.cpp
+ invitebuddypacket.cpp
+ inviterequestpacket.cpp
+ xfirerecvpacketcontent.cpp
+ recvdidpacket.cpp
+ recvprefspacket.cpp
+ xfiresendpacketcontent.cpp
+ recvstatusmessagepacket.cpp
+ sendstatusmessagepacket.cpp
+ sendmessagepacket.cpp
+ sendacceptinvitationpacket.cpp
+ sendgamestatuspacket.cpp
+ sendgameserverpacket.cpp
+ senddenyinvitationpacket.cpp
+ recvremovebuddypacket.cpp
+ sendremovebuddypacket.cpp
+ sendnickchangepacket.cpp
+ sendkeepalivepacket.cpp
+ xfiregame.cpp
+ recvoldversionpacket.cpp
+ xfiregameresolver.cpp
+ dummyxfiregameresolver.cpp
+ monitoredobj.cpp
+ sendgamestatus2packet.cpp
+ ;
+
+InstallLib $(LIBDIR) : libxfirelib$(SUFLIB) ;
+#InstallFile $(DESTDIR) : sendkeepalivepacket.h ;
+
+
+##########
+## IsElem, DoInstall copied from Crystal Space Installation !
+########
+#============================================================================
+# Helper rules
+# Copyright (C)2003 by Matze Braun <matzebraun@users.sourceforge.net>
+# Copyright (C)2004 by Eric Sunshine <sunshine@sunshineco.com>
+#
+# This library is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Library General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This library 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 Library General Public
+# License for more details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this library; if not, write to the Free Software Foundation,
+# Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+#============================================================================
+
+
+## IsElem element : list
+## Returns "true" if the element is in the list. Otherwise nothing is
+## returned.
+rule IsElem
+{
+ local i ;
+
+ for i in $(>)
+ {
+ if $(i) = $(<)
+ {
+ return "true" ;
+ }
+ }
+
+ return ;
+}
+
+rule DoInstall
+{
+ InstallFile /usr/local/include/xfirelib : $(1) ;
+}
+
+
+## Recurse [ rule ] : types [ : prefix ]
+## Recursively scan current directory, $(SUBDIR), for files matching 'types'
+## and invoke 'rule' for each file which matches one of the 'types'.
+## 'types' is a list of file extensions (with the leading dot). 'rule' will
+## be invoked with two arguments: (1) the basename of the file including the
+## extension, (2) a list of the path components from the current directory
+## to the file's directory. When 'rule' is invoked, it will see a $(SUBDIR)
+## value of the directory containing the file (as if the rule had been
+## invoked from within the file's directory). 'prefix' is an optional list
+## of path components which will be prepended to rule's second argument.
+## Returns the list of visited files. It is legal to omit 'rule', if you
+## are interested only in obtaining the list of files matching 'types'.
+rule Recurse
+{
+ local innerrule = $(1) ;
+ local types = $(2) ;
+ local prefix = $(3) ;
+ local files = [ GLOB $(SUBDIR) : * ] ;
+ local visited ;
+
+ local i ;
+ for i in $(files)
+ {
+ if [ IsElem $(i:S) : $(types) ]
+ {
+ visited += [ FDirName $(prefix) $(i:BS) ] ;
+ if $(innerrule)
+ {
+ $(innerrule) $(i:BS) : $(prefix) ;
+ }
+ }
+ else
+ {
+ if ! [ IsElem $(i:BS) : $(DOT) $(DOTDOT) ]
+ {
+ local SUBDIR = $(i) ; # Called rules see this new temporary value.
+ visited += [ Recurse $(innerrule) : $(types) : $(prefix) $(i:BS) ] ;
+ }
+ }
+ }
+ return $(visited) ;
+}
+
+
+
+
+Recurse DoInstall : .h ;
diff --git a/protocols/Xfire/src/SHA1.cpp b/protocols/Xfire/src/SHA1.cpp
new file mode 100644
index 0000000000..f296b563cd
--- /dev/null
+++ b/protocols/Xfire/src/SHA1.cpp
@@ -0,0 +1,263 @@
+/*
+ 100% free public domain implementation of the SHA-1 algorithm
+ by Dominik Reichl <dominik.reichl@t-online.de>
+
+ Version 1.5 - 2005-01-01
+ - 64-bit compiler compatibility added
+ - Made variable wiping optional (define SHA1_WIPE_VARIABLES)
+ - Removed unnecessary variable initializations
+ - ROL32 improvement for the Microsoft compiler (using _rotl)
+
+ ======== Test Vectors (from FIPS PUB 180-1) ========
+
+ SHA1("abc") =
+ A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
+
+ SHA1("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq") =
+ 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
+
+ SHA1(A million repetitions of "a") =
+ 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
+*/
+
+#include "stdafx.h"
+
+#include "SHA1.h"
+
+#define SHA1_MAX_FILE_BUFFER 8000
+
+// Rotate x bits to the left
+#ifndef ROL32
+#ifdef _MSC_VER
+#define ROL32(_val32, _nBits) _rotl(_val32, _nBits)
+#else
+#define ROL32(_val32, _nBits) (((_val32)<<(_nBits))|((_val32)>>(32-(_nBits))))
+#endif
+#endif
+
+#ifdef SHA1_LITTLE_ENDIAN
+#define SHABLK0(i) (m_block->l[i] = \
+ (ROL32(m_block->l[i],24) & 0xFF00FF00) | (ROL32(m_block->l[i],8) & 0x00FF00FF))
+#else
+#define SHABLK0(i) (m_block->l[i])
+#endif
+
+#define SHABLK(i) (m_block->l[i&15] = ROL32(m_block->l[(i+13)&15] ^ m_block->l[(i+8)&15] \
+ ^ m_block->l[(i+2)&15] ^ m_block->l[i&15],1))
+
+// SHA-1 rounds
+#define _R0(v,w,x,y,z,i) { z+=((w&(x^y))^y)+SHABLK0(i)+0x5A827999+ROL32(v,5); w=ROL32(w,30); }
+#define _R1(v,w,x,y,z,i) { z+=((w&(x^y))^y)+SHABLK(i)+0x5A827999+ROL32(v,5); w=ROL32(w,30); }
+#define _R2(v,w,x,y,z,i) { z+=(w^x^y)+SHABLK(i)+0x6ED9EBA1+ROL32(v,5); w=ROL32(w,30); }
+#define _R3(v,w,x,y,z,i) { z+=(((w|x)&y)|(w&x))+SHABLK(i)+0x8F1BBCDC+ROL32(v,5); w=ROL32(w,30); }
+#define _R4(v,w,x,y,z,i) { z+=(w^x^y)+SHABLK(i)+0xCA62C1D6+ROL32(v,5); w=ROL32(w,30); }
+
+
+CSHA1::CSHA1()
+{
+ m_block = (SHA1_WORKSPACE_BLOCK *)m_workspace;
+
+ Reset();
+}
+
+CSHA1::~CSHA1()
+{
+ Reset();
+}
+
+void CSHA1::Reset()
+{
+ // SHA1 initialization constants
+ m_state[0] = 0x67452301;
+ m_state[1] = 0xEFCDAB89;
+ m_state[2] = 0x98BADCFE;
+ m_state[3] = 0x10325476;
+ m_state[4] = 0xC3D2E1F0;
+
+ m_count[0] = 0;
+ m_count[1] = 0;
+}
+
+void CSHA1::Transform(UINT_32 *state, UINT_8 *buffer)
+{
+ // Copy state[] to working vars
+ UINT_32 a = state[0], b = state[1], c = state[2], d = state[3], e = state[4];
+
+ memcpy(m_block, buffer, 64);
+
+ // 4 rounds of 20 operations each. Loop unrolled.
+ _R0(a,b,c,d,e, 0); _R0(e,a,b,c,d, 1); _R0(d,e,a,b,c, 2); _R0(c,d,e,a,b, 3);
+ _R0(b,c,d,e,a, 4); _R0(a,b,c,d,e, 5); _R0(e,a,b,c,d, 6); _R0(d,e,a,b,c, 7);
+ _R0(c,d,e,a,b, 8); _R0(b,c,d,e,a, 9); _R0(a,b,c,d,e,10); _R0(e,a,b,c,d,11);
+ _R0(d,e,a,b,c,12); _R0(c,d,e,a,b,13); _R0(b,c,d,e,a,14); _R0(a,b,c,d,e,15);
+ _R1(e,a,b,c,d,16); _R1(d,e,a,b,c,17); _R1(c,d,e,a,b,18); _R1(b,c,d,e,a,19);
+ _R2(a,b,c,d,e,20); _R2(e,a,b,c,d,21); _R2(d,e,a,b,c,22); _R2(c,d,e,a,b,23);
+ _R2(b,c,d,e,a,24); _R2(a,b,c,d,e,25); _R2(e,a,b,c,d,26); _R2(d,e,a,b,c,27);
+ _R2(c,d,e,a,b,28); _R2(b,c,d,e,a,29); _R2(a,b,c,d,e,30); _R2(e,a,b,c,d,31);
+ _R2(d,e,a,b,c,32); _R2(c,d,e,a,b,33); _R2(b,c,d,e,a,34); _R2(a,b,c,d,e,35);
+ _R2(e,a,b,c,d,36); _R2(d,e,a,b,c,37); _R2(c,d,e,a,b,38); _R2(b,c,d,e,a,39);
+ _R3(a,b,c,d,e,40); _R3(e,a,b,c,d,41); _R3(d,e,a,b,c,42); _R3(c,d,e,a,b,43);
+ _R3(b,c,d,e,a,44); _R3(a,b,c,d,e,45); _R3(e,a,b,c,d,46); _R3(d,e,a,b,c,47);
+ _R3(c,d,e,a,b,48); _R3(b,c,d,e,a,49); _R3(a,b,c,d,e,50); _R3(e,a,b,c,d,51);
+ _R3(d,e,a,b,c,52); _R3(c,d,e,a,b,53); _R3(b,c,d,e,a,54); _R3(a,b,c,d,e,55);
+ _R3(e,a,b,c,d,56); _R3(d,e,a,b,c,57); _R3(c,d,e,a,b,58); _R3(b,c,d,e,a,59);
+ _R4(a,b,c,d,e,60); _R4(e,a,b,c,d,61); _R4(d,e,a,b,c,62); _R4(c,d,e,a,b,63);
+ _R4(b,c,d,e,a,64); _R4(a,b,c,d,e,65); _R4(e,a,b,c,d,66); _R4(d,e,a,b,c,67);
+ _R4(c,d,e,a,b,68); _R4(b,c,d,e,a,69); _R4(a,b,c,d,e,70); _R4(e,a,b,c,d,71);
+ _R4(d,e,a,b,c,72); _R4(c,d,e,a,b,73); _R4(b,c,d,e,a,74); _R4(a,b,c,d,e,75);
+ _R4(e,a,b,c,d,76); _R4(d,e,a,b,c,77); _R4(c,d,e,a,b,78); _R4(b,c,d,e,a,79);
+
+ // Add the working vars back into state
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+ state[4] += e;
+
+ // Wipe variables
+#ifdef SHA1_WIPE_VARIABLES
+ a = b = c = d = e = 0;
+#endif
+}
+
+// Use this function to hash in binary data and strings
+void CSHA1::Update(UINT_8 *data, UINT_32 len)
+{
+ UINT_32 i, j;
+
+ j = (m_count[0] >> 3) & 63;
+
+ if((m_count[0] += len << 3) < (len << 3)) m_count[1]++;
+
+ m_count[1] += (len >> 29);
+
+ if((j + len) > 63)
+ {
+ i = 64 - j;
+ memcpy(&m_buffer[j], data, i);
+ Transform(m_state, m_buffer);
+
+ for( ; i + 63 < len; i += 64) Transform(m_state, &data[i]);
+
+ j = 0;
+ }
+ else i = 0;
+
+ memcpy(&m_buffer[j], &data[i], len - i);
+}
+
+// Hash in file contents
+bool CSHA1::HashFile(char *szFileName)
+{
+ unsigned long ulFileSize, ulRest, ulBlocks;
+ unsigned long i;
+ UINT_8 uData[SHA1_MAX_FILE_BUFFER];
+ FILE *fIn;
+
+ if(szFileName == NULL) return false;
+
+ fIn = fopen(szFileName, "rb");
+ if(fIn == NULL) return false;
+
+ fseek(fIn, 0, SEEK_END);
+ ulFileSize = (unsigned long)ftell(fIn);
+ fseek(fIn, 0, SEEK_SET);
+
+ if(ulFileSize != 0)
+ {
+ ulBlocks = ulFileSize / SHA1_MAX_FILE_BUFFER;
+ ulRest = ulFileSize % SHA1_MAX_FILE_BUFFER;
+ }
+ else
+ {
+ ulBlocks = 0;
+ ulRest = 0;
+ }
+
+ for(i = 0; i < ulBlocks; i++)
+ {
+ fread(uData, 1, SHA1_MAX_FILE_BUFFER, fIn);
+ Update((UINT_8 *)uData, SHA1_MAX_FILE_BUFFER);
+ }
+
+ if(ulRest != 0)
+ {
+ fread(uData, 1, ulRest, fIn);
+ Update((UINT_8 *)uData, ulRest);
+ }
+
+ fclose(fIn); fIn = NULL;
+ return true;
+}
+
+void CSHA1::Final()
+{
+ UINT_32 i;
+ UINT_8 finalcount[8];
+
+ for(i = 0; i < 8; i++)
+ finalcount[i] = (UINT_8)((m_count[((i >= 4) ? 0 : 1)]
+ >> ((3 - (i & 3)) * 8) ) & 255); // Endian independent
+
+ Update((UINT_8 *)"\200", 1);
+
+ while ((m_count[0] & 504) != 448)
+ Update((UINT_8 *)"\0", 1);
+
+ Update(finalcount, 8); // Cause a SHA1Transform()
+
+ for(i = 0; i < 20; i++)
+ {
+ m_digest[i] = (UINT_8)((m_state[i >> 2] >> ((3 - (i & 3)) * 8) ) & 255);
+ }
+
+ // Wipe variables for security reasons
+#ifdef SHA1_WIPE_VARIABLES
+ i = 0;
+ memset(m_buffer, 0, 64);
+ memset(m_state, 0, 20);
+ memset(m_count, 0, 8);
+ memset(finalcount, 0, 8);
+ Transform(m_state, m_buffer);
+#endif
+}
+
+// Get the final hash as a pre-formatted string
+void CSHA1::ReportHash(char *szReport, unsigned char uReportType)
+{
+ unsigned char i;
+ char szTemp[16];
+
+ if(szReport == NULL) return;
+
+ if(uReportType == REPORT_HEX)
+ {
+ sprintf(szTemp, "%02X", m_digest[0]);
+ strcat(szReport, szTemp);
+
+ for(i = 1; i < 20; i++)
+ {
+ sprintf(szTemp, " %02X", m_digest[i]);
+ strcat(szReport, szTemp);
+ }
+ }
+ else if(uReportType == REPORT_DIGIT)
+ {
+ sprintf(szTemp, "%u", m_digest[0]);
+ strcat(szReport, szTemp);
+
+ for(i = 1; i < 20; i++)
+ {
+ sprintf(szTemp, " %u", m_digest[i]);
+ strcat(szReport, szTemp);
+ }
+ }
+ else strcpy(szReport, "Error: Unknown report type!");
+}
+
+// Get the raw message digest
+void CSHA1::GetHash(UINT_8 *puDest)
+{
+ memcpy(puDest, m_digest, 20);
+}
+
diff --git a/protocols/Xfire/src/SHA1.h b/protocols/Xfire/src/SHA1.h
new file mode 100644
index 0000000000..b95a00970f
--- /dev/null
+++ b/protocols/Xfire/src/SHA1.h
@@ -0,0 +1,116 @@
+/*
+ 100% free public domain implementation of the SHA-1 algorithm
+ by Dominik Reichl <dominik.reichl@t-online.de>
+
+ Version 1.5 - 2005-01-01
+ - 64-bit compiler compatibility added
+ - Made variable wiping optional (define SHA1_WIPE_VARIABLES)
+ - Removed unnecessary variable initializations
+ - ROL32 improvement for the Microsoft compiler (using _rotl)
+
+ ======== Test Vectors (from FIPS PUB 180-1) ========
+
+ SHA1("abc") =
+ A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
+
+ SHA1("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq") =
+ 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
+
+ SHA1(A million repetitions of "a") =
+ 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
+*/
+
+#ifndef ___SHA1_HDR___
+#define ___SHA1_HDR___
+//#define UINT_8 unsigned char
+//#define UINT_32 unsigned long
+
+#include <stdio.h> // Needed for file access
+#include <memory.h> // Needed for memset and memcpy
+#include <string.h> // Needed for strcat and strcpy
+#include <iostream>
+
+#ifdef _MSC_VER
+#include <stdlib.h>
+#endif
+
+// If you're compiling big endian, just comment out the following line
+#define SHA1_LITTLE_ENDIAN
+
+// #define or #undef this, if you want the CSHA1 class to wipe all
+// temporary variables after processing
+#define SHA1_WIPE_VARIABLES
+
+/////////////////////////////////////////////////////////////////////////////
+// Define 8- and 32-bit variables
+
+#ifndef UINT_32
+
+#ifdef _MSC_VER
+
+#define UINT_8 unsigned __int8
+#define UINT_32 unsigned __int32
+
+#else
+
+#define UINT_8 unsigned char
+
+#if (ULONG_MAX == 0xFFFFFFFF)
+#define UINT_32 unsigned long
+#else
+#define UINT_32 unsigned int
+#endif
+
+#endif
+#endif
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Declare SHA1 workspace
+
+typedef union
+{
+ UINT_8 c[64];
+ UINT_32 l[16];
+} SHA1_WORKSPACE_BLOCK;
+
+class CSHA1
+{
+public:
+ // Two different formats for ReportHash(...)
+ enum
+ {
+ REPORT_HEX = 0,
+ REPORT_DIGIT = 1
+ };
+
+ // Constructor and Destructor
+ CSHA1();
+ ~CSHA1();
+
+ UINT_32 m_state[5];
+ UINT_32 m_count[2];
+ UINT_8 m_buffer[64];
+ UINT_8 m_digest[20];
+
+ void Reset();
+
+ // Update the hash value
+ void Update(UINT_8 *data, UINT_32 len);
+ bool HashFile(char *szFileName);
+
+ // Finalize hash and report
+ void Final();
+ void ReportHash(char *szReport, unsigned char uReportType = REPORT_HEX);
+ void GetHash(UINT_8 *puDest);
+
+private:
+ // Private SHA-1 transformation
+ void Transform(UINT_32 *state, UINT_8 *buffer);
+
+ // Member variables
+ UINT_8 m_workspace[64];
+ SHA1_WORKSPACE_BLOCK *m_block; // SHA1 pointer to the byte array above
+};
+
+#endif
diff --git a/protocols/Xfire/src/Xfire_avatar_loader.cpp b/protocols/Xfire/src/Xfire_avatar_loader.cpp
new file mode 100644
index 0000000000..e1fe2fdd01
--- /dev/null
+++ b/protocols/Xfire/src/Xfire_avatar_loader.cpp
@@ -0,0 +1,86 @@
+#include "stdafx.h"
+#include "Xfire_avatar_loader.h"
+
+Xfire_avatar_loader::Xfire_avatar_loader(xfirelib::Client* client) {
+ threadrunning=FALSE;
+ this->client=client;
+ InitializeCriticalSection(&this->avatarMutex);
+}
+
+Xfire_avatar_loader::~Xfire_avatar_loader() {
+ //liste leeren, damit der laufende thread abgebrochen wird
+ list.clear();
+ //warten bis der thread geschlossen wurde
+ EnterCriticalSection(&this->avatarMutex);
+ LeaveCriticalSection(&this->avatarMutex);
+ //critical section entfernen
+ DeleteCriticalSection(&this->avatarMutex);
+}
+
+void Xfire_avatar_loader::loadThread(LPVOID lparam) {
+ Xfire_avatar_loader* loader=(Xfire_avatar_loader*)lparam;
+
+ //kein loader, dann abbruch
+ if(!lparam)
+ return;
+
+ if(loader) {
+ EnterCriticalSection(&loader->avatarMutex);
+ loader->threadrunning=TRUE;
+ }
+
+ while(1){
+ //keinen avatarload auftrag mehr
+ if(!loader->list.size())
+ break;
+
+ //letzten load process holen
+ Xfire_avatar_process process=loader->list.back();
+
+ //buddyinfo abfragen
+ GetBuddyInfo buddyinfo;
+ buddyinfo.userid=process.userid;
+ if(loader->client)
+ if(loader->client->connected)
+ {
+ loader->client->send(&buddyinfo);
+ }
+ else //nicht mehr verbunden? dann liste leeren und schleife abbrechen
+ {
+ loader->list.clear();
+ break;
+ }
+
+ //auftrag entfernen
+ loader->list.pop_back();
+
+ Sleep(1000);
+ }
+
+ if(loader)
+ {
+ loader->threadrunning=FALSE;
+ LeaveCriticalSection(&loader->avatarMutex);
+ }
+
+ return;
+}
+
+BOOL Xfire_avatar_loader::loadAvatar(HANDLE hcontact,char*username,unsigned int userid) {
+ Xfire_avatar_process process={0};
+
+ //struktur füllen
+ process.hcontact = hcontact;
+ if(username)
+ strcpy_s(process.username,128,username);
+ process.userid=userid;
+
+ //Avataranfrage an die liste übergeben
+ this->list.push_back(process);
+
+ if(!threadrunning && client!=NULL) {
+ mir_forkthread(Xfire_avatar_loader::loadThread,(LPVOID)this);
+ }
+
+ return TRUE;
+} \ No newline at end of file
diff --git a/protocols/Xfire/src/Xfire_avatar_loader.h b/protocols/Xfire/src/Xfire_avatar_loader.h
new file mode 100644
index 0000000000..a51082629e
--- /dev/null
+++ b/protocols/Xfire/src/Xfire_avatar_loader.h
@@ -0,0 +1,58 @@
+/*
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ *
+ * Copyright (C) 2009 by
+ * dufte <dufte@justmail.de>
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ *
+ * Miranda ICQ: the free icq client for MS Windows
+ * Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
+ *
+ */
+
+//Klasse behandelt alle Iconsachen unter Xfire
+
+#ifndef _XFIRE_AVATAR_LOADER
+#define _XFIRE_AVATAR_LOADER
+
+#include "client.h"
+#include "Xfire_base.h"
+#include "getbuddyinfo.h"
+#include <vector>
+
+using namespace xfirelib;
+
+struct Xfire_avatar_process {
+ HANDLE hcontact;
+ char username[128];
+ unsigned int userid;
+};
+
+class Xfire_avatar_loader : public Xfire_base {
+private:
+ static void loadThread(LPVOID lparam);
+ xfirelib::Client *client;
+ CRITICAL_SECTION avatarMutex;
+public:
+ vector<Xfire_avatar_process> list;
+ BOOL threadrunning;
+ BOOL loadAvatar(HANDLE hcontact,char*username,unsigned int userid);
+ Xfire_avatar_loader(xfirelib::Client* client);
+ ~Xfire_avatar_loader();
+};
+
+#endif \ No newline at end of file
diff --git a/protocols/Xfire/src/Xfire_base.cpp b/protocols/Xfire/src/Xfire_base.cpp
new file mode 100644
index 0000000000..2d28b12659
--- /dev/null
+++ b/protocols/Xfire/src/Xfire_base.cpp
@@ -0,0 +1,567 @@
+#include "stdafx.h"
+
+#include "Xfire_base.h"
+
+//rechnet die einzelnen chars des strings zusammen
+BYTE Xfire_base::accStringByte(char* str){
+ BYTE temp=0;
+
+ //keins tirng? bye bye
+ if(str==NULL)
+ return 0;
+
+ for(unsigned int i=0;i<(int)strlen(str);i++)
+ {
+ temp+=str[i];
+ }
+
+ return temp;
+}
+
+//lowercased einen string
+void Xfire_base::strtolower(char*str)
+{
+ //keins tirng? bye bye
+ if(str==NULL)
+ return;
+
+ //lowercase it :)
+ for(unsigned int i=0;i<(int)strlen(str);i++)
+ {
+ str[i]=tolower(str[i]);
+ }
+}
+
+//uppercased einen string
+void Xfire_base::strtoupper(char*str)
+{
+ //keins tirng? bye bye
+ if(str==NULL)
+ return;
+
+ //lowercase it :)
+ for(unsigned int i=0;i<(int)strlen(str);i++)
+ {
+ str[i]=toupper(str[i]);
+ }
+}
+
+//setzt einen string
+void Xfire_base::setString(char*from,char**to)
+{
+ //keine quelle, kein ziel? dann nix machen
+ if(from==NULL||to==NULL)
+ return;
+
+ //stringgröße auslesen
+ int size=strlen(from);
+
+ //bestehenden zielpointer leeren
+ if(*to!=NULL)
+ delete[] *to;
+
+ //neuen string anlegen
+ *to=new char[size+1];
+
+ //string in neues array kopieren
+ strcpy_s(*to,size+1,from);
+}
+
+//setzt einen string
+void Xfire_base::appendString(char*from,char**to)
+{
+ //keine quelle, kein ziel? dann nix machen
+ if(from==NULL||to==NULL||*to==NULL)
+ return;
+
+ //stringgröße auslesen
+ int size=strlen(from);
+ int size2=strlen(*to);
+
+ //temporären pointer anlegen
+ char* append=new char[size+size2+1];
+
+ //string in neues array kopieren
+ strcpy_s(append,size+size2+1,*to);
+ //zusätzlichen stirng anhängen
+ strcat_s(append,size+size2+1,from);
+ //altes to entfernen
+ delete[] *to;
+ //appendstring zuordnen
+ *to=append;
+}
+
+//liest einen stringval aus der db und setzt einen string für
+void Xfire_base::readStringfromDB(char*name,unsigned int dbid,char**to)
+{
+ //keine quelle, kein ziel? dann nix machen
+ if(name==NULL||to==NULL)
+ return;
+
+ //wert aus der dblesen
+ sprintf_s(temp,128,"%s_%i",name,dbid);
+ if(!DBGetContactSettingTString(NULL, protocolname, temp,&dbv))
+ {
+ //string setzen
+ setString(dbv.pszVal,to);
+ //dbval wieder freigeben
+ DBFreeVariant(&dbv);
+ }
+}
+
+//liest einen stringval aus der db welches unterid hat und setzt einen string für
+void Xfire_base::readStringfromDB(char*name,unsigned int dbid,int id,char**to)
+{
+ //keine quelle, kein ziel? dann nix machen
+ if(name==NULL||to==NULL)
+ return;
+
+ //wert aus der dblesen
+ sprintf_s(temp,128,"%s_%i_%i",name,dbid,id);
+ if(!DBGetContactSettingTString(NULL, protocolname, temp,&dbv))
+ {
+ //string setzen
+ setString(dbv.pszVal,to);
+ //dbval wieder freigeben
+ DBFreeVariant(&dbv);
+ }
+}
+
+//schreibt einen stringval in die db welche unterid hat
+void Xfire_base::writeStringtoDB(char*name,unsigned int dbid,int id,char*val)
+{
+ //keine quelle, kein ziel? dann nix machen
+ if(name==NULL||val==NULL)
+ return;
+
+ //wert aus der dblesen
+ sprintf_s(temp,128,"%s_%i_%i",name,dbid,id);
+ DBWriteContactSettingTString(NULL, protocolname, temp,val);
+}
+
+//schreibt einen stringval in die db welche unterid hat
+void Xfire_base::writeStringtoDB(char*name,unsigned int dbid,char*val)
+{
+ //keine quelle, kein ziel? dann nix machen
+ if(name==NULL||val==NULL)
+ return;
+
+ //wert aus der dblesen
+ sprintf_s(temp,128,"%s_%i",name,dbid);
+ DBWriteContactSettingTString(NULL, protocolname, temp,val);
+}
+
+//schreibt einen bytewert in die db
+void Xfire_base::writeBytetoDB(char*name,unsigned int dbid,int val)
+{
+ //keine quelle, kein ziel? dann nix machen
+ if(name==NULL)
+ return;
+
+ //wert aus der dblesen
+ sprintf_s(temp,128,"%s_%i",name,dbid);
+ DBWriteContactSettingByte(NULL, protocolname, temp, val);
+}
+
+//schreibt einen wordwert in die db
+void Xfire_base::writeWordtoDB(char*name,unsigned int dbid,int val)
+{
+ //keine quelle, kein ziel? dann nix machen
+ if(name==NULL)
+ return;
+
+ //wert aus der dblesen
+ sprintf_s(temp,128,"%s_%i",name,dbid);
+ DBWriteContactSettingWord(NULL, protocolname, temp, val);
+}
+
+
+//liest einen byteval aus der db und gibt es zurück
+unsigned char Xfire_base::readBytefromDB(char*name,unsigned int dbid,int defaultval)
+{
+ //keine quelle, kein ziel? dann nix machen
+ if(name==NULL)
+ return 0;
+
+ //wert aus der dblesen
+ sprintf_s(temp,128,"%s_%i",name,dbid);
+ return DBGetContactSettingByte(NULL, protocolname, temp, defaultval);
+}
+
+//liest einen wordval aus der db und gibt es zurück
+unsigned int Xfire_base::readWordfromDB(char*name,unsigned int dbid,int defaultval)
+{
+ //keine quelle, kein ziel? dann nix machen
+ if(name==NULL)
+ return 0;
+
+ //wert aus der dblesen
+ sprintf_s(temp,128,"%s_%i",name,dbid);
+ return DBGetContactSettingWord(NULL, protocolname, temp, defaultval);
+}
+
+//entfernt einen dbeintrag
+BOOL Xfire_base::removeDBEntry(char*name,unsigned int dbid)
+{
+ //kein name?
+ if(name==NULL)
+ return 0;
+
+ //wert aus der dblesen
+ sprintf_s(temp,128,"%s_%i",name,dbid);
+
+ //eintrag entfernen
+ if(!DBGetContactSetting(NULL, protocolname, temp,&dbv))
+ {
+ DBFreeVariant(&dbv);
+ DBDeleteContactSetting(NULL, protocolname, temp);
+
+ return TRUE;
+ }
+ return FALSE;
+}
+
+//entfernt einen dbeintrag welche unterid's hat
+BOOL Xfire_base::removeDBEntry(char*name,unsigned int dbid,int id)
+{
+ //kein name?
+ if(name==NULL)
+ return 0;
+
+ //wert aus der dblesen
+ sprintf_s(temp,128,"%s_%i_%i",name,dbid,id);
+
+ //eintrag entfernen
+ if(!DBGetContactSetting(NULL, protocolname, temp,&dbv))
+ {
+ DBFreeVariant(&dbv);
+ DBDeleteContactSetting(NULL, protocolname, temp);
+
+ return TRUE;
+ }
+ return FALSE;
+}
+
+//sucht innerhalb eines strings ein anderen string und liefert true zurück wenn gefunden
+BOOL Xfire_base::inString(char*str,char*search,char**pos) {
+ //leere pointer?, dann FALSE zurück
+ if(str==NULL||search==NULL)
+ {
+ //poszeiger, falls übergeben, auf NULL setzen
+ if(pos) *pos=NULL;
+ return FALSE;
+ }
+
+ //ist der gesuchte string größer, wie der string wo gesucht werden soll? dann FALSE zurück
+ unsigned int sizeofsearch=strlen(search);
+ if(sizeofsearch>strlen(str))
+ {
+ //poszeiger, falls übergeben, auf NULL setzen
+ if(pos) *pos=NULL;
+ return FALSE;
+ }
+
+ char* src=str;
+ char* s=search;
+
+ while(*src!=0)
+ {
+ if(*src==*s) //gleich, dann zum nächsten buchstaben springen
+ s++;
+ else if(*s==0) //string ende erreicht? dann true
+ {
+ //poszeiger mit aktueller pos füllen, da position gefunden
+ if(pos) *pos=src-sizeofsearch;
+ return TRUE;
+ }
+ else //anderer biuchstabe? dann wieder zurück zum anfangsbuchstaben
+ s=search;
+ src++;
+ }
+ if(*s==0) //string ende erreicht? dann true
+ {
+ //poszeiger mit aktueller pos füllen, da position gefunden
+ if(pos) *pos=src-sizeofsearch;
+ return TRUE;
+ }
+
+ //poszeiger, falls übergeben, auf NULL setzen
+ if(pos) *pos=NULL;
+ //nix gefunden, FALSE
+ return FALSE;
+}
+
+void Xfire_base::strreplace(char*search,char*replace,char**data) {
+ //leere pointer?, dann zurück
+ if(replace==NULL||search==NULL||data==NULL||*data==NULL)
+ {
+ return;
+ }
+
+ char* pos=NULL;
+ //gesuchten string suchen
+ if(this->inString(*data,search,&pos))
+ {
+ //gefunden? dann replace
+ *pos=0;
+ char* newdata=NULL;
+ //alles vorm gefunden anhängen
+ this->setString(*data,&newdata);
+ //ersetzendes anhängen
+ this->appendString(replace,&newdata);
+ //poszeiger um die größe des zusuchenden strings erhöhen
+ pos+=strlen(search);
+ //rest anhängen
+ this->appendString(pos,&newdata);
+ //alten string löschen
+ delete[] *data;
+ *data=NULL;
+ //neuen auf diesen setzen
+ this->setString(newdata,data);
+ //temporären newdata löschen
+ delete[] newdata;
+ }
+}
+
+//stringvergleich mit wildcards
+BOOL Xfire_base::wildcmp(const char*search,const char *text) {
+ //keine gültigen strings, dann abbruch
+ if(search==NULL || text==NULL || *text==0 || *search==0)
+ return FALSE;
+
+ //wildcardmodus
+ int wildc=0;
+
+ do {
+ //wilcard gefunden?
+ if(*search=='*')
+ {
+ //wildcardmodus an
+ wildc=1;
+ //nächsten suchzeichen
+ search++;
+ //wenn searchzeichen 0, dann 1 zurückgeben, da der rest des searchstings egal ist
+ if(*search==0)
+ return TRUE;
+ }
+
+ //prüfe searchzeichen mit textzeichen, aber nut wenn kein wildcardmodus aktiv ist
+ if(*search!=*text && !wildc)
+ return FALSE;
+
+ //kein wildcardmodus
+ if(!wildc)
+ {
+ //nächstes suchzeichen
+ search++;
+ }
+ //wenn suchzeichen und textzeichen gleich ist
+ else if(*search==*text)
+ {
+ //den wildcardmodus abschalten
+ wildc=0;
+ //nächstes suchzeichen
+ search++;
+ }
+ //nächstes textzeichen
+ text++;
+ //wenn textende erreicht und suchzeichen noch vorhanden, dann 0 zurückgegebn
+ if(*text==0 && *search!=0)
+ return FALSE;
+ }
+ //solange weiter bis kein suchzeichen mehr vorhanden is
+ while(*search!=0);
+
+ //textzeichen übrig 0 zurück
+ if(*text!=0)
+ return FALSE;
+
+ //volle übereinstimmung
+ return TRUE;
+}
+
+//wrapper wenn nur gameid angegeben
+BOOL Xfire_base::getIniValue(unsigned int gameid,const char* valname,char*out,int sizeofout) {
+ return Xfire_base::getIniValue(gameid,0,valname,out,sizeofout);
+}
+
+
+//läd einen eintrag aus der ini
+BOOL Xfire_base::getIniValue(unsigned int gameid,unsigned int subid,const char* valname,char*out,int sizeofout) {
+ //kein ziel oder kein variablenname, dann FALSE zurück
+ if(!out || !valname)
+ return FALSE;
+
+ char idstring[15];
+ char path[MAX_PATH];
+
+ //pfad einlesen
+ if(!getIniPath(path))
+ return FALSE; //kein pfad bug?!?!
+
+ if(subid==0) {
+ sprintf_s(idstring,15,"%d",gameid);
+
+ if(xfire_GetPrivateProfileString(idstring, valname, "", out, sizeofout, path))
+ return TRUE;
+
+ subid++;
+ }
+
+ sprintf_s(idstring,15,"%d_%d",gameid,subid);
+
+ if(xfire_GetPrivateProfileString(idstring, valname, "", out, sizeofout, path))
+ return TRUE;
+
+ return FALSE;
+}
+
+BOOL Xfire_base::getIniPath(char*path) {
+ //kein ziel abbruch
+ if(!path)
+ return FALSE;
+
+ FoldersGetCustomPath( XFireWorkingFolder, path, MAX_PATH, "" );
+ strcat_s(path,MAX_PATH,"\\");
+ strcat_s(path,MAX_PATH,"xfire_games.ini");
+
+ return TRUE;
+}
+
+BOOL Xfire_base::getIconPath(char*path) {
+ //kein ziel abbruch
+ if(!path)
+ return FALSE;
+
+ FoldersGetCustomPath( XFireIconFolder, path, MAX_PATH, "" );
+ strcat_s(path,MAX_PATH,"\\");
+
+ return TRUE;
+}
+
+BOOL Xfire_base::getGamename(unsigned int gameid,char* out,int outsize){
+ //kein ziel
+ if(!out)
+ return FALSE;
+
+ if(!getIniValue(gameid,"LongName",out,outsize))
+ {
+ //customnamen laden, wenn vorhanden
+ DBVARIANT dbv;
+ char dbstr[80]="";
+ sprintf_s(dbstr,XFIRE_MAXSIZEOFGAMENAME,"customgamename_%d",gameid);
+ if(!DBGetContactSetting(NULL,protocolname,dbstr,&dbv)) {
+ sprintf_s(out,outsize,"%s",dbv.pszVal);
+ DBFreeVariant(&dbv);
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ return TRUE;
+}
+
+//wandelt einen buffer mit größe in ein hicon mit hilfe von gdi+ um
+HICON Xfire_base::createHICONfromdata(LPVOID data,unsigned int size) {
+ //zielspeichern anlegen
+ HGLOBAL buffer=GlobalAlloc(GMEM_MOVEABLE, size);
+ if(buffer) {
+ LPVOID data2=GlobalLock(buffer);
+ if(data2) {
+ CopyMemory(data2, data, size);
+
+ IStream* stream=NULL;
+ if(CreateStreamOnHGlobal(data2,FALSE,&stream)== S_OK)
+ {
+ HICON hicon=NULL;
+ Gdiplus::Bitmap image(stream);
+
+ image.GetHICON(&hicon);
+ stream->Release();
+
+ GlobalUnlock(buffer);
+ GlobalFree(buffer);
+
+ return hicon;
+ }
+ GlobalUnlock(buffer);
+ }
+ GlobalFree(buffer);
+ }
+ return NULL;
+}
+
+//wandelt einen buffer mit größe in ein hicon mit hilfe von gdi+ um
+HBITMAP Xfire_base::createHBITMAPfromdata(LPVOID data,unsigned int size) {
+ //zielspeichern anlegen
+ HGLOBAL buffer=GlobalAlloc(GMEM_MOVEABLE, size);
+ if(buffer) {
+ LPVOID data2=GlobalLock(buffer);
+ if(data2) {
+ CopyMemory(data2, data, size);
+
+ IStream* stream=NULL;
+ if(CreateStreamOnHGlobal(data2,FALSE,&stream)== S_OK)
+ {
+ HBITMAP hbitmap=NULL;
+ Gdiplus::Bitmap image(stream);
+
+ image.GetHBITMAP(0,&hbitmap);
+ stream->Release();
+
+ GlobalUnlock(buffer);
+ GlobalFree(buffer);
+
+ return hbitmap;
+ }
+ GlobalUnlock(buffer);
+ }
+ GlobalFree(buffer);
+ }
+ return NULL;
+}
+
+//prüft ob processid noch gültig is
+BOOL Xfire_base::isValidPid(DWORD pid) {
+ DWORD aProcesses[1024],cbNeeded,cProcesses;
+
+ if(pid==NULL)
+ return FALSE;
+
+ if(!EnumProcesses(aProcesses,sizeof(aProcesses),&cbNeeded))
+ return FALSE;
+
+ cProcesses = cbNeeded / sizeof(DWORD);
+
+ for ( unsigned int i = 0; i < cProcesses; i++ )
+ if(aProcesses[i]==pid)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+//sucht nach einen process und liefert die pid
+BOOL Xfire_base::getPidByProcessName(char*name,DWORD*pid) {
+ if(pid==NULL||name==NULL)
+ return FALSE;
+
+ HANDLE hSnapShot = CreateToolhelp32Snapshot ( TH32CS_SNAPALL, 0);
+ PROCESSENTRY32* processInfo = new PROCESSENTRY32;
+ processInfo->dwSize = sizeof ( PROCESSENTRY32);
+
+ while ( Process32Next ( hSnapShot,processInfo ) != FALSE)
+ {
+ if(processInfo->th32ProcessID!=0) {
+ if(_stricmp(processInfo->szExeFile,name)==0)
+ {
+ *pid=processInfo->th32ProcessID;
+ CloseHandle ( hSnapShot);
+ return TRUE;
+ }
+ }
+ }
+ CloseHandle ( hSnapShot);
+ return FALSE;
+}
diff --git a/protocols/Xfire/src/Xfire_base.h b/protocols/Xfire/src/Xfire_base.h
new file mode 100644
index 0000000000..5753e631c4
--- /dev/null
+++ b/protocols/Xfire/src/Xfire_base.h
@@ -0,0 +1,81 @@
+/*
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ *
+ * Copyright (C) 2010 by
+ * dufte <dufte@justmail.de>
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ *
+ * Miranda ICQ: the free icq client for MS Windows
+ * Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
+ *
+ */
+
+/*
+ Beinhaltet Basisfunktionen
+*/
+
+#ifndef _XFIRE_BASE
+#define _XFIRE_BASE
+
+#include "baseProtocol.h"
+
+extern HANDLE XFireWorkingFolder;
+extern HANDLE XFireIconFolder;
+
+#define XFIRE_MAXSIZEOFGAMENAME 80
+
+class Xfire_base {
+private:
+ //vars
+ DBVARIANT dbv;
+public:
+ char temp[128];
+ //funktionen/tools
+ void setString(char*from,char**to);
+ void appendString(char*from,char**to);
+ void readStringfromDB(char*name,unsigned int dbid,char**to);
+ void readStringfromDB(char*name,unsigned int dbid,int id,char**to);
+ unsigned char readBytefromDB(char*name,unsigned int dbid,int defaultval=0);
+ unsigned int readWordfromDB(char*name,unsigned int dbid,int defaultval=0);
+ BOOL removeDBEntry(char*name,unsigned int dbid);
+ BOOL removeDBEntry(char*name,unsigned int dbid,int id2);
+ void writeStringtoDB(char*name,unsigned int dbid,int id,char*val);
+ void writeStringtoDB(char*name,unsigned int dbid,char*val);
+ void writeBytetoDB(char*name,unsigned int dbid,int val);
+ void writeWordtoDB(char*name,unsigned int dbid,int val);
+ void strtolower(char*);
+ void strtoupper(char*);
+ void strreplace(char*search,char*replace,char**data);
+ BYTE accStringByte(char*);
+ BOOL inString(char*str,char*search,char**pos=NULL);
+ BOOL wildcmp(const char*search,const char *text);
+ // ini funktionen
+ BOOL getIniValue(unsigned int gameid,const char* valname,char*out,int sizeofout=255);
+ BOOL getIniValue(unsigned int gameid,unsigned int subid,const char* valname,char*out,int sizeofout=255);
+ BOOL getIniPath(char*path);
+ BOOL getIconPath(char*path);
+ // gamename
+ BOOL getGamename(unsigned int gameid,char* out,int outsize=255);
+ //gdi+
+ HICON createHICONfromdata(LPVOID data,unsigned int size);
+ HBITMAP createHBITMAPfromdata(LPVOID data,unsigned int size);
+ //processzeugs
+ BOOL isValidPid(DWORD pid);
+ BOOL getPidByProcessName(char*name,DWORD*pid);
+};
+
+#endif \ No newline at end of file
diff --git a/protocols/Xfire/src/Xfire_game.cpp b/protocols/Xfire/src/Xfire_game.cpp
new file mode 100644
index 0000000000..10ae7bc783
--- /dev/null
+++ b/protocols/Xfire/src/Xfire_game.cpp
@@ -0,0 +1,487 @@
+#include "stdafx.h"
+
+#include "Xfire_game.h"
+#include "pwd_dlg.h" //passwort eingabe dlg
+
+//prüft nach, ob das game das nötige extragameargs im launcherstring hat
+BOOL Xfire_game::haveExtraGameArgs() {
+ //kein launcher stirng, dann abbruch
+ if(!this->launchparams)
+ return FALSE;
+
+ //wenn platzhalter vorhanden, dann TRUE zurück
+ if(this->inString(this->launchparams,"%UA_LAUNCHER_EXTRA_ARGS%"))
+ return TRUE;
+
+ return FALSE;
+}
+
+//startes das spiel
+BOOL Xfire_game::start_game(char*ip,unsigned int port,char*pw) {
+ //launchparam prüfen ob gefüllt?
+ if(this->launchparams==NULL)
+ return FALSE;
+
+ //ist launchparam großgenug für eibne urlprüfung?
+ if(strlen(this->launchparams)>5)
+ {
+ //launchparams ne url? dann openurl funktion von miranda verwenden
+ if(this->launchparams[0]=='h'&&
+ this->launchparams[1]=='t'&&
+ this->launchparams[2]=='t'&&
+ this->launchparams[3]=='p'&&
+ this->launchparams[4]==':')
+ {
+ return CallService( MS_UTILS_OPENURL, 1, (LPARAM)this->launchparams );
+ }
+ }
+
+ //spiel hat netwerkparameter?
+ int networksize=0;
+ char* mynetworkparams=NULL;
+
+ if(this->networkparams)
+ {
+ if(ip)
+ {
+ char portstr[6]="";
+ int pwsize=255;
+
+ //größe des netzwerparams berechnen
+ if(this->pwparams)
+ pwsize+=strlen(this->pwparams);
+
+ mynetworkparams=new char[strlen(this->networkparams)+pwsize];
+ strcpy_s(mynetworkparams,strlen(this->networkparams)+pwsize,this->networkparams);
+
+ //port begrenzen
+ port=port%65535;
+ //port in string wandeln
+ sprintf_s(portstr,6,"%d",port);
+
+ str_replace(mynetworkparams,"%UA_GAME_HOST_NAME%",ip);
+ str_replace(mynetworkparams,"%UA_GAME_HOST_PORT%",portstr);
+
+ //passwort dialog, nur wenn SHIFT gehalten wird beim join, da sonst immer gefragt wird
+ if(GetAsyncKeyState(VK_LSHIFT) && this->pwparams){
+ char password[256]=""; //passwort maximal 255 zeichen
+
+ if(ShowPwdDlg(password)) {
+ char* mypwargs=new char[pwsize];
+
+ //speicher frei?
+ if(mypwargs!=NULL) {
+ strcpy_s(mypwargs,pwsize,this->pwparams);
+ str_replace(mypwargs, "%UA_GAME_HOST_PASSWORD%", password);
+ str_replace(mynetworkparams,"%UA_LAUNCHER_PASSWORD_ARGS%",mypwargs);
+ delete[] mypwargs;
+ }
+ else
+ str_replace(mynetworkparams,"%UA_LAUNCHER_PASSWORD_ARGS%","");
+ }
+ else
+ {
+ str_replace(mynetworkparams,"%UA_LAUNCHER_PASSWORD_ARGS%","");
+ }
+ }
+ else
+ str_replace(mynetworkparams,"%UA_LAUNCHER_PASSWORD_ARGS%","");
+
+ //bestimmte felder erstmal leer ersetzen
+ str_replace(mynetworkparams,"%UA_LAUNCHER_RCON_ARGS%","");
+ }
+
+ if(mynetworkparams)
+ networksize=strlen(mynetworkparams)+strlen(this->networkparams);
+ }
+
+ //extra parameter
+ int extraparamssize=0;
+ if(this->extraparams)
+ {
+ extraparamssize=strlen(this->extraparams);
+ }
+
+ //temporäres array anlegen
+ char*temp=NULL;
+ temp=new char[strlen(this->launchparams)+networksize+extraparamssize+1];
+
+ if(temp==NULL)
+ {
+ //wenn nwparams gesetzt, leeren
+ if(mynetworkparams)
+ delete[] mynetworkparams;
+
+ return FALSE;
+ }
+
+ //launcherstring ins temporäre array
+ strcpy_s(temp,strlen(this->launchparams)+1,this->launchparams);
+
+ //netzwerkparameter ?
+ if(mynetworkparams)
+ {
+ str_replace(temp,"%UA_LAUNCHER_NETWORK_ARGS%",mynetworkparams);
+ delete[] mynetworkparams;
+ }
+ else
+ str_replace(temp,"%UA_LAUNCHER_NETWORK_ARGS%","");
+
+ if(this->extraparams)
+ str_replace(temp,"%UA_LAUNCHER_EXTRA_ARGS%",this->extraparams);
+ else
+ str_replace(temp,"%UA_LAUNCHER_EXTRA_ARGS%","");
+
+ //auf createprocess umgebaut
+ STARTUPINFO si = { sizeof(si) };
+ PROCESS_INFORMATION pi;
+
+ // MessageBox(NULL,temp,temp,0);
+
+ //starten
+ if(CreateProcess(0, temp, 0, 0, FALSE, 0, 0, GetLaunchPath(temp) , &si, &pi)==0)
+ {
+ //schlug fehl, dann runas methode verwenden
+ char*exe=strrchr(temp,'\\');
+ if(exe==0)
+ {
+ delete[] temp;
+ return FALSE;
+ }
+ *exe=0;
+ exe++;
+ char*params=strchr(exe,'.');
+ if(params!=0)
+ {
+ params=strchr(params,' ');
+ if(params!=0)
+ {
+ *params=0;
+ params++;
+ }
+ }
+
+
+ SHELLEXECUTEINFO sei = {0};
+ sei.cbSize = sizeof(sei);
+ sei.hwnd = NULL;
+ sei.lpVerb = "runas";
+ sei.lpFile = exe;
+ sei.lpParameters = params;
+ sei.lpDirectory = temp;
+ sei.nShow = SW_SHOWNORMAL;
+ ShellExecuteEx(&sei);
+ }
+ delete[] temp;
+ return TRUE;
+}
+
+//prüft den übergebenen pfad, ob es dem spiel vergleichbar
+BOOL Xfire_game::checkpath(PROCESSENTRY32* processInfo)
+{
+ //gibts net, weg mit dir
+ if(this->path==NULL)
+ return FALSE;
+
+ //versuche ein processhandle des speils zubekommen
+ HANDLE op=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ, FALSE, processInfo->th32ProcessID);
+
+ if(op)
+ {
+ //varaibele wohin der pfad eingelesen wird
+ char fpath[MAX_PATH]="";
+
+ //lese den pfad des spiels aus
+ GetModuleFileNameEx(op,NULL,fpath,sizeof(fpath));
+
+ //8.3 pfade umwandeln, nur wenn sich eine tilde im string befindet
+ if(strchr(fpath,'~'))
+ GetLongPathNameA(fpath,fpath,sizeof(fpath));
+
+ //alles in kelinbuchstaben umwandeln
+ this->strtolower(fpath);
+
+ if(this->wildcmp(this->path,fpath))
+ //if(strcmp(this->path,fpath)==0)
+ {
+ //pfad stimmt überein, commandline prüfen
+ if(checkCommandLine(op,this->mustcontain,this->notcontain))
+ {
+ //handle zuamachen
+ CloseHandle(op);
+ //positive antwort an die gamedetection
+ return TRUE;
+ }
+ }
+ else //prüfe den multipfad
+ {
+ int size=mpath.size();
+ for(int j=0;j<size;j++)
+ {
+ if(strcmp(mpath.at(j),fpath)==0)
+ {
+ //pfad stimmt überein, commandline prüfen
+ if(checkCommandLine(op,this->mustcontain,this->notcontain))
+ {
+ //handle zumachen
+ CloseHandle(op);
+ //positive antwort an die gamedetection
+ return TRUE;
+ }
+ }
+ }
+ }
+ //is nich das game, handle zumachen
+ CloseHandle(op);
+ }
+ else //if(this->mustcontain==NULL&&this->notcontain==NULL) //spiele die was bestimmtes im pfad benötigen skippen
+ {
+ char* exename=strrchr(this->path,'\\')+1;
+
+ //kleiner fix bei fehlerhaften pfaden kann keine exe ermittelt werden also SKIP
+ if((unsigned int)exename==0x1)
+ return FALSE;
+
+ //exenamen des process kleinschreiben
+ this->strtolower(processInfo->szExeFile);
+
+ //vergleich die exenamen
+ if(strcmp(exename,processInfo->szExeFile)==0)
+ {
+ return TRUE;
+ }
+ else //anderen pfade des games noch durchprüfen
+ {
+ int size=mpath.size();
+ for(int j=0;j<size;j++)
+ {
+ //exenamen rausfischen
+ char* exename=strrchr(mpath.at(j),'\\')+1;
+
+ //mhn keien exe, nächsten pfad prüfen
+ if((unsigned int)exename==0x1)
+ continue;
+
+ //exe vergleichen
+ if(strcmp(exename,processInfo->szExeFile)==0)
+ {
+ //positive antwort an die gamedetection
+ return TRUE;
+ }
+ }
+ }
+ }
+
+ //keine übereinstimmung
+ return FALSE;
+}
+
+//icondaten setzen
+void Xfire_game::setIcon(HICON hicon,HANDLE handle) {
+ this->hicon=hicon;
+ this->iconhandl=handle;
+}
+
+//liest gamewerte aus der db
+void Xfire_game::readFromDB(unsigned dbid)
+{
+ //lese alle string werte aus der db und befülle die passenden variablen damit
+ this->readStringfromDB("gamepath",dbid,&this->path);
+
+ //8.3 fix, prüfe auf ~ pfad, wenn ja pfad var umwalnd in longname
+ if(this->path)
+ {
+ BOOL found=FALSE;
+ for(unsigned int i=0;i<strlen(this->path);i++)
+ {
+ if(this->path[i] == '~')
+ {
+ found=TRUE;
+ break;
+ }
+ }
+ //gefunden? dann stirng wandeln und in pfad speichern
+ if(found) {
+ char ctemp[MAX_PATH]="";
+ strcpy_s(ctemp,MAX_PATH,this->path);
+ GetLongPathNameA(ctemp,ctemp,sizeof(ctemp));
+ this->strtolower(ctemp);
+ this->setString(ctemp,&this->path);
+ }
+ }
+
+ this->readStringfromDB("gamelaunch",dbid,&this->launchparams);
+ this->readStringfromDB("gamenetargs",dbid,&this->networkparams);
+ this->readStringfromDB("gamepwargs",dbid,&this->pwparams);
+ this->readStringfromDB("gameuserargs",dbid,&this->userparams);
+ this->readStringfromDB("gamecmdline",dbid,&this->mustcontain);
+ this->readStringfromDB("gamencmdline",dbid,&this->notcontain);
+
+ //alle sonstigen werte
+ this->id=this->readWordfromDB("gameid",dbid);
+ this->send_gameid=this->readWordfromDB("gamesendid",dbid);
+ if(this->send_gameid==0)
+ this->send_gameid=this->id;
+ this->setstatusmsg=this->readWordfromDB("gamesetsmsg",dbid,0);
+ this->custom=this->readBytefromDB("gamecustom",dbid,0);
+ this->skip=this->readBytefromDB("gameskip",this->id,0);
+ this->notinstartmenu=this->readBytefromDB("notinstartmenu",this->id,0);
+ this->noicqstatus=this->readBytefromDB("gamenostatus",this->id,0);
+ this->readStringfromDB("gameextraparams",this->id,&this->extraparams);
+ this->readStringfromDB("customgamename",this->id,&this->customgamename);
+ this->readStringfromDB("statusmsg",this->id,&this->statusmsg);
+
+ //mehrere pfade
+ int size=this->readWordfromDB("gamemulti",dbid,0);
+ for(int j=0;j<size;j++)
+ {
+ char* tpath=NULL;
+ this->readStringfromDB("gamepath",dbid,j,&tpath);
+
+ if(tpath)
+ {
+ mpath.push_back(tpath);
+ }
+ }
+
+ //spielname auslesen, wird später für die sortierung gebraucht
+ setNameandIcon();
+}
+
+//läd spielnamen aus, sowie icon
+void Xfire_game::setNameandIcon()
+{
+ if(this->customgamename)
+ {
+ this->setString(this->customgamename,&this->name);
+ }
+ else
+ {
+ //std::string game=GetGame(this->id,0,&this->iconhandl,&this->hicon,TRUE);
+ //zielbuffer für den namen
+ char buf[XFIRE_MAXSIZEOFGAMENAME]="Unknown Game";
+ //name des spiels auslesen
+ this->getGamename(this->id,buf,XFIRE_MAXSIZEOFGAMENAME);
+ //namen setzen
+ this->setString(buf,&this->name);
+ }
+}
+
+//liest gamewerte aus der db
+void Xfire_game::writeToDB(unsigned dbid)
+{
+ //alle stringwerte schreiben
+ this->writeStringtoDB("gamepath",dbid,this->path);
+ this->writeStringtoDB("gamelaunch",dbid,this->launchparams);
+ this->writeStringtoDB("gamenetargs",dbid,this->networkparams);
+ this->writeStringtoDB("gamepwargs",dbid,this->pwparams);
+ this->writeStringtoDB("gameuserargs",dbid,this->userparams);
+ this->writeStringtoDB("gamecmdline",dbid,this->mustcontain);
+ this->writeStringtoDB("gamencmdline",dbid,this->notcontain);
+
+ //alle sonstigen werte
+ this->writeWordtoDB("gameid",dbid,this->id);
+ if(this->send_gameid!=0&&this->send_gameid!=this->id) this->writeWordtoDB("gamesendid",dbid,this->send_gameid);
+ if(this->setstatusmsg!=0) this->writeWordtoDB("gamesetsmsg",dbid,this->setstatusmsg);
+ if(this->custom!=0) this->writeBytetoDB("gamecustom",dbid,this->custom);
+ //wenn gesetzt, dann eintrag machen
+ if(this->skip!=0)
+ this->writeBytetoDB("gameskip",this->id,this->skip);
+ else //wenn nicht eintrag aus db löschen
+ this->removeDBEntry("gameskip",this->id);
+ if(this->notinstartmenu!=0)
+ this->writeBytetoDB("notinstartmenu",this->id,this->notinstartmenu);
+ else //wenn nicht eintrag aus db löschen
+ this->removeDBEntry("notinstartmenu",this->id);
+ if(this->noicqstatus!=0)
+ this->writeBytetoDB("gamenostatus",this->id,this->noicqstatus);
+ else //wenn nicht eintrag aus db löschen
+ this->removeDBEntry("gamenostatus",this->id);
+ if(this->extraparams!=0)
+ this->writeStringtoDB("gameextraparams",this->id,this->extraparams);
+ else //wenn nicht eintrag aus db löschen
+ this->removeDBEntry("gameextraparams",this->id);
+ if(this->customgamename!=0)
+ this->writeStringtoDB("customgamename",this->id,this->customgamename);
+ else //wenn nicht eintrag aus db löschen
+ this->removeDBEntry("customgamename",this->id);
+ if(this->statusmsg!=0)
+ this->writeStringtoDB("statusmsg",this->id,this->statusmsg);
+ else //wenn nicht eintrag aus db löschen
+ this->removeDBEntry("statusmsg",this->id);
+
+
+
+ //mehrere pfade
+ int size=mpath.size();
+ if(size>0)
+ {
+ this->writeWordtoDB("gamemulti",dbid,mpath.size());
+ for(int j=0;j<size;j++)
+ {
+ this->writeStringtoDB("gamepath",dbid,j,mpath.at(j));
+ }
+ }
+
+ //sendid 0 dann standard id reinladen
+ if(this->send_gameid==0)
+ this->send_gameid=this->id;
+}
+
+//erzeugt ein menüpunkt
+void Xfire_game::createMenuitem(unsigned int pos,int dbid)
+{
+ CLISTMENUITEM mi = { 0 };
+ char servicefunction[100];
+
+ if(dbid<0)
+ dbid=pos;
+
+ memset(&mi,0,sizeof(CLISTMENUITEM));
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, "StartGame%d");
+ mi.popupPosition = 500084000;
+ mi.pszPopupName = Translate("Start game");
+ mi.pszContactOwner=protocolname;
+ mi.cbSize = sizeof( mi );
+
+ sprintf(temp,servicefunction,this->id);
+ //wenn die servicefunktion schon exisitert vernichten, hehe
+ if(ServiceExists(temp))
+ DestroyServiceFunction(temp);
+ CreateServiceFunctionParam(temp,StartGame,this->id);
+ mi.pszService = temp;
+ mi.position = 500090002+pos;
+ mi.hIcon = this->hicon?this->hicon:LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
+ mi.pszName = menuitemtext(this->name);
+ this->menuhandle=Menu_AddMainMenuItem(&mi);
+
+ //menu aktualisieren ob hidden
+ this->refreshMenuitem();
+}
+
+//entfernt menüpunkt
+void Xfire_game::remoteMenuitem()
+{
+ if(menuhandle!=NULL)
+ {
+ CallService( MS_CLIST_REMOVEMAINMENUITEM, ( WPARAM )menuhandle, 0 );
+ menuhandle=NULL;
+ }
+}
+
+//aktualisiert menüpunkt ob hidden
+void Xfire_game::refreshMenuitem()
+{
+ if(menuhandle!=NULL)
+ {
+ CLISTMENUITEM clmi = { 0 };
+ clmi.cbSize = sizeof( clmi );
+ clmi.flags = CMIM_FLAGS;
+
+ if(this->notinstartmenu)
+ clmi.flags|= CMIF_HIDDEN;
+
+ CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )menuhandle, ( LPARAM )&clmi );
+ }
+} \ No newline at end of file
diff --git a/protocols/Xfire/src/Xfire_game.h b/protocols/Xfire/src/Xfire_game.h
new file mode 100644
index 0000000000..0d502d121b
--- /dev/null
+++ b/protocols/Xfire/src/Xfire_game.h
@@ -0,0 +1,194 @@
+/*
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ *
+ * Copyright (C) 2010 by
+ * dufte <dufte@justmail.de>
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ *
+ * Miranda ICQ: the free icq client for MS Windows
+ * Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
+ *
+ */
+
+/*
+ Beinhaltet alle Funktionen und Informationen des Spiels
+*/
+
+#ifndef _XFIRE_GAME
+#define _XFIRE_GAME
+
+#include "Xfire_base.h"
+#include <vector>
+
+using namespace std;
+
+//externe funktion die das spielstarten steuern
+extern int StartGame(WPARAM wParam,LPARAM lParam,LPARAM fParam);
+
+class Xfire_game : public Xfire_base {
+public:
+ //id des spiels
+ unsigned int id;
+ //handle des menuitems
+ HANDLE menuhandle;
+ //spiel soll bei der detection übersprungen werden
+ BOOL skip;
+ //voicehat?
+ BOOL voicechat;
+ //es soll kein icq und co status gesetzt werden
+ BOOL noicqstatus;
+ //handelt es sich um ein "custom" spiel
+ BOOL custom;
+ //soll ein spez. status gesetzt werden
+ BOOL setstatusmsg;
+ //iconhandle von miranda
+ HANDLE iconhandl;
+ //hicon vom icon des spiels
+ HICON hicon;
+ //dont show in startmenü
+ BOOL notinstartmenu;
+
+ //pfad des spiels wenn es laufen sollte
+ char* path;
+ //startparameter des spiels
+ char* launchparams;
+ //netzwerkparameter
+ char* networkparams;
+ //username parameter
+ char* userparams;
+ //passwort paramter
+ char* pwparams;
+ //mustcontain parameter
+ char* mustcontain;
+ //notcontain parameter
+ char* notcontain;
+ //spielname
+ char* name;
+ //extraparameter
+ char* extraparams;
+ //custom gamename
+ char* customgamename;
+ //custom statusmsg for xfire
+ char* statusmsg;
+
+ //mehrere pfade
+ vector<char*> mpath;
+
+ //zu sende gameid
+ signed short send_gameid;
+
+ //konstruktor
+ Xfire_game() {
+ //vars leer setzen
+ path=NULL;
+ launchparams=NULL;
+ networkparams=NULL;
+ userparams=NULL;
+ pwparams=NULL;
+ mustcontain=NULL;
+ notcontain=NULL;
+ name=NULL;
+ menuhandle=NULL;
+ iconhandl=NULL;
+ hicon=NULL;
+ extraparams=NULL;
+ customgamename=NULL;
+ statusmsg=NULL;
+ id=skip=noicqstatus=custom=setstatusmsg=send_gameid=notinstartmenu=voicechat=0;
+ }
+ //dekonstruktor
+ ~Xfire_game() {
+ //entferne dyn arrays
+ if(path)
+ {
+ delete[] path;
+ path=NULL;
+ }
+ if(launchparams)
+ {
+ delete[] launchparams;
+ launchparams=NULL;
+ }
+ if(networkparams)
+ {
+ delete[] networkparams;
+ networkparams=NULL;
+ }
+ if(userparams)
+ {
+ delete[] userparams;
+ userparams=NULL;
+ }
+ if(pwparams)
+ {
+ delete[] pwparams;
+ pwparams=NULL;
+ }
+ if(mustcontain)
+ {
+ delete[] mustcontain;
+ mustcontain=NULL;
+ }
+ if(notcontain)
+ {
+ delete[] notcontain;
+ notcontain=NULL;
+ }
+ if(name)
+ {
+ delete[] name;
+ name=NULL;
+ }
+ if(extraparams)
+ {
+ delete[] extraparams;
+ extraparams=NULL;
+ }
+ if(customgamename)
+ {
+ delete[] customgamename;
+ customgamename=NULL;
+ }
+ if(statusmsg)
+ {
+ delete[] statusmsg;
+ statusmsg=NULL;
+ }
+
+ for(unsigned int i = 0 ; i < mpath.size() ; i ++) {
+ if(mpath.at(i)!=NULL)
+ delete mpath.at(i);
+ }
+ mpath.clear();
+
+ remoteMenuitem();
+ }
+
+ //funktionen
+ void readFromDB(unsigned dbid);
+ void writeToDB(unsigned dbid);
+ void createMenuitem(unsigned int pos,int dbid=-1);
+ void refreshMenuitem();
+ void remoteMenuitem();
+ void setNameandIcon();
+ void setIcon(HICON hicon,HANDLE handle);
+ BOOL checkpath(PROCESSENTRY32* processInfo);
+ BOOL start_game(char*ip=NULL,unsigned int port=0,char*pw=NULL);
+ BOOL haveExtraGameArgs();
+};
+
+#endif \ No newline at end of file
diff --git a/protocols/Xfire/src/Xfire_gamelist.cpp b/protocols/Xfire/src/Xfire_gamelist.cpp
new file mode 100644
index 0000000000..3496a2e3f1
--- /dev/null
+++ b/protocols/Xfire/src/Xfire_gamelist.cpp
@@ -0,0 +1,312 @@
+#include "stdafx.h"
+
+#include "Xfire_gamelist.h"
+
+//liefert bestimmtes game zurück
+Xfire_game* Xfire_gamelist::getGame(unsigned int dbid)
+{
+ if(dbid<gamelist.size())
+ {
+ return gamelist.at(dbid);
+ }
+ return NULL;
+}
+
+//liefert bestimmtes game zurück
+Xfire_game* Xfire_gamelist::getGamebyGameid(unsigned int gameid)
+{
+ for(unsigned int i = 0 ; i < gamelist.size() ; i ++) {
+ Xfire_game* game=(Xfire_game*)gamelist.at(i);
+ if(game->id==gameid)
+ return game;
+ }
+ return NULL;
+}
+
+void Xfire_gamelist::readGamelist(int anz) {
+ //spiele einzeln einlesen
+ for(int i=0;i<anz;i++)
+ {
+ //erzeuge gameobject
+ Xfire_game* game=new Xfire_game();
+
+ if(game) {
+ //lese das spiel ein
+ game->readFromDB(i);
+ //icons laden
+ Xfire_icon_cache icon=this->iconmngr.getGameIconEntry(game->id);
+ game->setIcon(icon.hicon,icon.handle);
+ //in die liste einfügen
+ gamelist.push_back(game);
+ }
+ }
+}
+
+//setzt den ingamestatus
+void Xfire_gamelist::SetGameStatus(BOOL status)
+{
+ ingame=status;
+}
+
+Xfire_gamelist::Xfire_gamelist()
+{
+ nextgameid=0;
+ ingame=FALSE;
+ InitializeCriticalSection(&gamlistMutex);
+}
+
+//dekonstruktor
+Xfire_gamelist::~Xfire_gamelist() {
+ for(unsigned int i = 0 ; i < gamelist.size() ; i ++) {
+ Xfire_game* game=(Xfire_game*)gamelist.at(i);
+ if(game) delete game;
+ }
+ gamelist.clear();
+ DeleteCriticalSection(&gamlistMutex);
+}
+
+//hole das nächste game
+BOOL Xfire_gamelist::getnextGame(Xfire_game**currentgame)
+{
+ //kein pointer dann false zurückliefern
+ if(currentgame==NULL)
+ return FALSE;
+
+ //is die derzeitige id kleiner wie die anzahl an games, dann passendes game zurückliefern
+ if(nextgameid<gamelist.size())
+ {
+ *currentgame=gamelist.at(nextgameid);
+ nextgameid++;
+
+ //muss das spiel geskippt werden, dann nochmal funktion aufrufen um das nächste game zubekommen
+ if((*currentgame)->skip||(*currentgame)->id==32||(*currentgame)->id==33||(*currentgame)->id==34||(*currentgame)->id==35)
+ {
+ return getnextGame(currentgame);
+ }
+
+ return TRUE;
+ }
+ else
+ {
+ //liste durchgearbeitet, nextid wieder auf 0 setzen
+ nextgameid=0;
+ return FALSE;
+ }
+}
+
+void Xfire_gamelist::Block(BOOL block)
+{
+ if(block)
+ EnterCriticalSection(&gamlistMutex);
+ else
+ LeaveCriticalSection(&gamlistMutex);
+}
+
+//fügt simple ein gameobject in den vector ein
+void Xfire_gamelist::Addgame(Xfire_game* newgame)
+{
+ //spielicon auslesen
+ Xfire_icon_cache icon=this->iconmngr.getGameIconEntry(newgame->id);
+ newgame->setIcon(icon.hicon,icon.handle);
+
+ gamelist.push_back(newgame);
+}
+
+//entfernt ein game aus der liste
+BOOL Xfire_gamelist::Removegame(int id)
+{
+ std::vector<Xfire_game *>::iterator i = gamelist.begin();
+ while( i != gamelist.end() ) {
+ if((*i)->id == id) {
+ (*i)->remoteMenuitem();
+ gamelist.erase(i);
+ return TRUE;
+ }
+ ++i;
+ }
+ return FALSE;
+}
+
+//setzt die aktuelle id als currentgame
+int Xfire_gamelist::CurrentGame()
+{
+ this->SetGameStatus(TRUE);
+ return nextgameid-1;
+}
+
+//erzeugt das menu der gameliste
+void Xfire_gamelist::createStartmenu()
+{
+ //keine games in der internen liste? abbruch
+ if(gamelist.size()==0)
+ return;
+
+ //sortierarray
+ int* sorttemp=new int[gamelist.size()];
+
+ //zuordnungen setzen
+ for(unsigned int i = 0 ; i < gamelist.size() ; i ++)
+ sorttemp[i]=i;
+
+ //sortiert mit bubblesortalgo
+ BOOL changed=FALSE;
+ do
+ {
+ changed=FALSE;
+ for(unsigned int i = 1 ; i < gamelist.size() ; i ++)
+ {
+ Xfire_game* game=(Xfire_game*)gamelist.at(sorttemp[i-1]);
+ Xfire_game* game2=(Xfire_game*)gamelist.at(sorttemp[i]);
+ //sortieren
+ if(strcmp(game->name,game2->name)>0)
+ {
+ int tempi=sorttemp[i-1];
+ sorttemp[i-1]=sorttemp[i];
+ sorttemp[i]=tempi;
+ changed=TRUE;
+ }
+ }
+ }
+ while(changed);
+
+ //menüpunkte anlegen
+ for(unsigned int i = 0 ; i < gamelist.size() ; i ++) {
+ Xfire_game* game=(Xfire_game*)gamelist.at(sorttemp[i]);
+ game->createMenuitem(i,sorttemp[i]);
+ }
+
+ //entferne sortarray
+ delete[] sorttemp;
+
+ //dummymenu entfernen
+ removeDummyMenuItem();
+}
+
+//schreibt derzeitige gameliste in die db
+void Xfire_gamelist::writeDatabase()
+{
+ for(unsigned int i = 0 ; i < gamelist.size() ; i ++) {
+ Xfire_game* game=(Xfire_game*)gamelist.at(i);
+ if(game) game->writeToDB(i);
+ }
+
+ //anzahl aktualisieren
+ DBWriteContactSettingWord(NULL, protocolname, "foundgames", gamelist.size());
+}
+
+//prüft ob ein game schon in der liste is
+BOOL Xfire_gamelist::Gameinlist(int id,int*dbid)
+{
+ for(unsigned int i = 0 ; i < gamelist.size() ; i ++) {
+ Xfire_game* game=(Xfire_game*)gamelist.at(i);
+ if(game)
+ {
+ if(game->id==id)
+ {
+ //soll eine dbid zurückgeliefert werden? dann setzen
+ if(dbid)
+ *dbid=i;
+
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+//gibt die anzahl der spiele zurück
+int Xfire_gamelist::countGames()
+{
+ return gamelist.size();
+}
+
+//leert das startmenu
+void Xfire_gamelist::clearStartmenu()
+{
+ //erstelle dummyeintrag, für workaround
+ createDummyMenuItem();
+
+ //einzelene menüpunkte entfernen
+ for(unsigned int i = 0 ; i < gamelist.size() ; i ++) {
+ Xfire_game* game=(Xfire_game*)gamelist.at(i);
+ if(game) game->remoteMenuitem();
+ }
+}
+
+//dekonstruktor
+void Xfire_gamelist::clearGamelist() {
+ createDummyMenuItem();
+ for(unsigned int i = 0 ; i < gamelist.size() ; i ++) {
+ Xfire_game* game=(Xfire_game*)gamelist.at(i);
+ if(game) delete game;
+ }
+ gamelist.clear();
+}
+
+//erstellt ein dummyeintrag
+void Xfire_gamelist::createDummyMenuItem()
+{
+ CLISTMENUITEM midummy = { 0 };
+ midummy.cbSize = sizeof( midummy );
+ midummy.position = 500090001;
+ midummy.pszName = Translate("Please wait ...");
+ //midummy.flags = CMIF_GRAYED; geht nicht bei 0.8.1
+ midummy.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
+ midummy.popupPosition = 500084000;
+ midummy.pszPopupName = Translate("Start game");
+ midummy.pszContactOwner=protocolname;
+ dummymenuitem=Menu_AddMainMenuItem(&midummy);
+}
+
+//entfernt dummymenueintrag
+void Xfire_gamelist::removeDummyMenuItem()
+{
+ CallService( MS_CLIST_REMOVEMAINMENUITEM, ( WPARAM )dummymenuitem, 0 );
+}
+
+//säubert die datenbank spiel einträge udn trägt custom spiele vorher nach
+void Xfire_gamelist::clearDatabase(BOOL dontaddcustom)
+{
+ BOOL somethingfound=TRUE;
+ int i3=0;
+
+ //db durchsuchen
+ while(somethingfound) {
+ somethingfound=FALSE;
+ //customeintrag? dann ab in die gameliste damit
+ if(this->readBytefromDB("gamecustom",i3)==1)
+ {
+ //customgame nur in die liste adden wenn es gewollt is
+ if(!dontaddcustom)
+ {
+ //erzeuge gameobject
+ Xfire_game* game=new Xfire_game();
+ //lese das spiel ein
+ game->readFromDB(i3);
+ //spielicon auslesen
+ /*Xfire_icon_cache icon=this->iconmngr.getGameIconEntry(game->id);
+ game->setIcon(icon.hicon,icon.handle);
+ //in die liste einfügen
+ gamelist.push_back(game);*/
+ this->Addgame(game);
+ }
+ }
+
+ if(this->removeDBEntry("gamecustom",i3)) somethingfound=TRUE;
+ if(this->removeDBEntry("gameid",i3)) somethingfound=TRUE;
+ if(this->removeDBEntry("gamepath",i3)) somethingfound=TRUE;
+ if(this->removeDBEntry("gamepwargs",i3)) somethingfound=TRUE;
+ if(this->removeDBEntry("gameuserargs",i3)) somethingfound=TRUE;
+ if(this->removeDBEntry("gamecmdline",i3)) somethingfound=TRUE;
+ if(this->removeDBEntry("gamencmdline",i3)) somethingfound=TRUE;
+ if(this->removeDBEntry("gamelaunch",i3)) somethingfound=TRUE;
+ if(this->removeDBEntry("gamenetargs",i3)) somethingfound=TRUE;
+ if(this->removeDBEntry("gamemulti",i3)) somethingfound=TRUE;
+ if(this->removeDBEntry("gamesendid",i3)) somethingfound=TRUE;
+ if(this->removeDBEntry("gamesetsmsg",i3)) somethingfound=TRUE;
+
+ for(int i2=0;i2<10;i2++)
+ if(this->removeDBEntry("gamepath",i3,i2)) somethingfound=TRUE;
+ i3++;
+ }
+} \ No newline at end of file
diff --git a/protocols/Xfire/src/Xfire_gamelist.h b/protocols/Xfire/src/Xfire_gamelist.h
new file mode 100644
index 0000000000..0f6c341a45
--- /dev/null
+++ b/protocols/Xfire/src/Xfire_gamelist.h
@@ -0,0 +1,75 @@
+/*
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ *
+ * Copyright (C) 2010 by
+ * dufte <dufte@justmail.de>
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ *
+ * Miranda ICQ: the free icq client for MS Windows
+ * Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
+ *
+ */
+
+/*
+ Klasse soll die Gameliste verwalten. Dazu gehört das dynamische Einfügen/Löschen/Verändern von Games.
+ Erstellen/Sortieren der Menüpunkte ...
+*/
+
+#ifndef _XFIRE_GAMELIST
+#define _XFIRE_GAMELIST
+
+#include "Xfire_game.h"
+#include "Xfire_icon_mng.h"
+#include <vector>
+
+using namespace std;
+
+class Xfire_gamelist : public Xfire_base {
+private:
+ vector<Xfire_game*> gamelist;
+ HANDLE dummymenuitem;
+ unsigned int nextgameid;
+ BOOL ingame;
+ CRITICAL_SECTION gamlistMutex;
+
+ void removeDummyMenuItem();
+ void createDummyMenuItem();
+public:
+ Xfire_icon_mng iconmngr;
+
+ void readGamelist(int anz);
+ void clearGamelist();
+ void createStartmenu();
+ void clearStartmenu();
+ void clearDatabase(BOOL dontaddcustom=FALSE);
+ void writeDatabase();
+ BOOL Gameinlist(int id,int*dbid=NULL);
+ void Addgame(Xfire_game* newgame);
+ BOOL Xfire_gamelist::Removegame(int id);
+ int countGames();
+ ~Xfire_gamelist();
+ Xfire_gamelist();
+ BOOL getnextGame(Xfire_game**currentgame);
+ BOOL Ingame(){return ingame;}
+ void SetGameStatus(BOOL ingame);
+ int CurrentGame();
+ Xfire_game* getGame(unsigned int dbid);
+ Xfire_game* getGamebyGameid(unsigned int gameid);
+ void Block(BOOL block);
+};
+
+#endif \ No newline at end of file
diff --git a/protocols/Xfire/src/Xfire_icon_mng.cpp b/protocols/Xfire/src/Xfire_icon_mng.cpp
new file mode 100644
index 0000000000..f5612e8e56
--- /dev/null
+++ b/protocols/Xfire/src/Xfire_icon_mng.cpp
@@ -0,0 +1,216 @@
+#include "stdafx.h"
+#include "Xfire_icon_mng.h"
+
+//liefert den handle eines icons zurück
+HANDLE Xfire_icon_mng::getGameIconHandle(unsigned int gameid) {
+ Xfire_icon_cache entry={0};
+
+ //icon im cache dann zurückliefern
+ if(getIconfromCache(gameid,&entry))
+ return entry.handle;
+
+ //ansonsten gameicon laden
+ return this->LoadGameIcon(gameid).handle;
+}
+
+//liefert den index des icons zurück
+unsigned int Xfire_icon_mng::getGameIconId(unsigned int gameid) {
+ for(unsigned int i=0;i<iconcache.size();i++)
+ {
+ if(iconcache.at(i).gameid==gameid)
+ {
+ return i;
+ }
+ }
+ return -1;
+}
+
+//gameicon mit hilfe von id zurückliefern
+HICON Xfire_icon_mng::getGameIconFromId(unsigned int id) {
+ //id nur im bereich zurückliefern
+ if(id<0 || id>iconcache.size()-1)
+ return NULL;
+
+ return iconcache.at(id).hicon;
+}
+
+//liefert das hicon zurück
+HICON Xfire_icon_mng::getGameIcon(unsigned int gameid) {
+ Xfire_icon_cache entry={0};
+
+ //icon im cache dann zurückliefern
+ if(getIconfromCache(gameid,&entry))
+ return entry.hicon;
+
+ return this->LoadGameIcon(gameid).hicon;
+}
+
+//liefert den icon eintrag zurück
+Xfire_icon_cache Xfire_icon_mng::getGameIconEntry(unsigned int gameid) {
+ Xfire_icon_cache entry={0};
+
+ //icon im cache dann zurückliefern
+ if(getIconfromCache(gameid,&entry))
+ return entry;
+
+ return this->LoadGameIcon(gameid);
+}
+
+//sucht nach dem spielicon im cache
+BOOL Xfire_icon_mng::getIconfromCache(unsigned int gameid,Xfire_icon_cache* out) {
+ //kein ziel, keine prüfung
+ if(out==NULL)
+ return FALSE;
+
+ for(unsigned int i=0;i<iconcache.size();i++)
+ {
+ if(iconcache.at(i).gameid==gameid)
+ {
+ *out=iconcache.at(i);
+ return TRUE;
+ }
+ }
+
+ //nicht gefunden
+ return FALSE;
+}
+
+//dekonstruktor
+Xfire_icon_mng::~Xfire_icon_mng() {
+ //geladene icons wieder freigeben
+ for(unsigned int i=0;i<iconcache.size();i++)
+ {
+ if(iconcache.at(i).hicon)
+ {
+ DestroyIcon(iconcache.at(i).hicon);
+ iconcache.at(i).hicon=NULL;
+ }
+ }
+ iconcache.clear();
+
+ //Icons.dll wieder freigeben
+ if(hIconDll) {
+ FreeLibrary(hIconDll);
+ hIconDll=NULL;
+ }
+}
+
+//konstruktor
+Xfire_icon_mng::Xfire_icon_mng() {
+ hIconDll=NULL;
+}
+
+//erzeugt aus HICON ein Handle, welches in Miranda in der Clist angewendet werden kann
+HANDLE Xfire_icon_mng::createIconHandle(HICON hicon) {
+ if(!hicon)
+ return NULL;
+
+ return (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)hicon, 0);
+}
+
+//eigentliche laderoutine
+Xfire_icon_cache Xfire_icon_mng::LoadGameIcon(unsigned int gameid) {
+ Xfire_icon_cache entry={0};
+
+ //shortname
+ char shortname[255]="";
+
+ if(!getIniValue(gameid,"ShortName",shortname))
+ return entry;
+
+ //spielid zuweisen
+ entry.gameid=gameid;
+
+ //Icons.dll noch nicht geladen?!?
+ if(!hIconDll)
+ {
+ //versuch die Icons.dll zuladen
+ char path[MAX_PATH]="";
+ if(!getIconPath(path))
+ return entry;
+ strcat_s(path,MAX_PATH,IconsdllName);
+
+ hIconDll = LoadLibrary(path);
+ }
+
+ //dll konnte geladen werden
+ if(hIconDll) {
+ char resourcename[255]="";
+ //kurznamen des spiels uppercasen und .ICO anhängen
+ sprintf_s(resourcename,255,"XF_%s.ICO",shortname);
+ Xfire_base::strtoupper(resourcename);
+
+ //versuche die resource zufinden
+ HRSRC hrsrc = FindResource(hIconDll,resourcename,"ICONS");
+ if(hrsrc) {
+ //aus der resource ein HICON erstellen
+ int size=SizeofResource(hIconDll,hrsrc);
+ //iconresource laden
+ HGLOBAL hglobal=LoadResource(hIconDll,hrsrc);
+ if(hglobal) {
+ //lock
+ LPVOID data=LockResource(hglobal);
+ if(data) {
+ //erzeuge ein handle für das icon und ab in den cache damit
+ entry.hicon=this->createHICONfromdata(data,size);
+ UnlockResource(hglobal);
+ }
+ FreeResource(hglobal);
+ }
+ }
+ }
+
+ //kein icon in der dll, dann aus dem internet laden
+ if(!entry.hicon)
+ entry.hicon=downloadIcon(shortname);
+
+ //wenn ein hicon erzeugt wurde, dann handle erstellen und in den cache laden
+ if(entry.hicon)
+ entry.handle=this->createIconHandle(entry.hicon);
+
+ //eintrag in den cache, selbst wenn kein icon geladen werden konnte
+ this->iconcache.push_back(entry);
+
+ return entry;
+}
+
+//icon vom xfire server laden
+HICON Xfire_icon_mng::downloadIcon(char* shortname) {
+ //nur vom internetladen, wenn die option aktiv ist
+ if(!DBGetContactSettingByte(NULL,protocolname,"xfiresitegameico",0))
+ return NULL;
+
+ //keinen namen angegeben?
+ if(!shortname)
+ return NULL;
+
+ //buffer
+ char*buf=NULL;
+ unsigned int size=0;
+
+ char url[255]="http://media.xfire.com/xfire/xf/images/icons/";
+ strcat_s(url,255,shortname);
+ strcat_s(url,255,".gif");
+
+ //verscuhe das icon aus dem inet zulasen
+ if(GetWWWContent2(url,NULL,FALSE,&buf,&size))
+ {
+ //aus dem buffer ein hicon erzeugen
+ HICON hicon=this->createHICONfromdata(buf,size);
+ //speicher freigeben
+ delete[] buf;
+
+ return hicon;
+ }
+
+ return NULL;
+}
+
+//setzt alle handles der icons neu
+int Xfire_icon_mng::resetIconHandles() {
+ for(unsigned int i=0;i<iconcache.size();i++)
+ {
+ iconcache.at(i).handle=this->createIconHandle(iconcache.at(i).hicon);
+ }
+ return 0;
+} \ No newline at end of file
diff --git a/protocols/Xfire/src/Xfire_icon_mng.h b/protocols/Xfire/src/Xfire_icon_mng.h
new file mode 100644
index 0000000000..895d18ba91
--- /dev/null
+++ b/protocols/Xfire/src/Xfire_icon_mng.h
@@ -0,0 +1,70 @@
+/*
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ *
+ * Copyright (C) 2009 by
+ * dufte <dufte@justmail.de>
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ *
+ * Miranda ICQ: the free icq client for MS Windows
+ * Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
+ *
+ */
+
+//Klasse behandelt alle Iconsachen unter Xfire
+
+#ifndef _XFIRE_ICON_MNG
+#define _XFIRE_ICON_MNG
+
+#include "Xfire_base.h"
+#include <vector>
+
+const char IconsdllName[]="Icons.dll";
+
+#pragma comment(lib,"ole32.lib")
+
+using namespace std;
+
+//eintrag eines icons
+struct Xfire_icon_cache {
+ unsigned int gameid;
+ HANDLE handle;
+ HICON hicon;
+};
+
+//icon loader, cache manager
+class Xfire_icon_mng : public Xfire_base {
+private:
+ vector<Xfire_icon_cache> iconcache;
+ BOOL getIconfromCache(unsigned int gameid,Xfire_icon_cache* out);
+ Xfire_icon_cache LoadGameIcon(unsigned int gameid);
+ HANDLE createIconHandle(HICON hicon);
+ HICON downloadIcon(char* shortname);
+
+ HINSTANCE hIconDll;
+public:
+ HANDLE getGameIconHandle(unsigned int gameid);
+ HICON getGameIcon(unsigned int gameid);
+ unsigned int getGameIconId(unsigned int gameid);
+ HICON getGameIconFromId(unsigned int gameid);
+ Xfire_icon_cache getGameIconEntry(unsigned int gameid);
+ int resetIconHandles();
+
+ Xfire_icon_mng();
+ ~Xfire_icon_mng();
+};
+
+#endif \ No newline at end of file
diff --git a/protocols/Xfire/src/Xfire_proxy.cpp b/protocols/Xfire/src/Xfire_proxy.cpp
new file mode 100644
index 0000000000..641c481097
--- /dev/null
+++ b/protocols/Xfire/src/Xfire_proxy.cpp
@@ -0,0 +1,96 @@
+#include "stdafx.h"
+
+#include "Xfire_proxy.h"
+
+extern HANDLE hNetlib;
+HANDLE hBindPort=NULL;
+HANDLE netlibcon=NULL;
+
+
+void FromServerToClient(LPVOID lParam) {
+ char buf[1024]={0};
+
+ HANDLE hConnection=(HANDLE)lParam;
+ do {
+ if(!hBindPort) return;
+
+ int cbRead = Netlib_Recv(netlibcon, buf, sizeof(buf), 0);
+ if( cbRead == SOCKET_ERROR)
+ break;
+
+ if(cbRead) {
+ Netlib_Send(hConnection, buf, cbRead, 0);
+ }
+ }
+ while(1);
+}
+
+//xfireclient baut verbindung auf
+void XfireclientConnecting(HANDLE hConnection, DWORD, void* extra )
+{
+ char buf[1024]={0};
+
+ //verbindung zum richtigen xfire server aufbauen
+ NETLIBOPENCONNECTION ncon = { 0 };
+ ncon.cbSize = sizeof(ncon);
+ ncon.szHost = "206.220.42.147";
+ ncon.wPort = (WORD)atol("25999");
+ ncon.timeout=5;
+ netlibcon = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) hNetlib, (LPARAM) & ncon);
+
+ if(!netlibcon) {
+ Netlib_CloseHandle(hConnection);
+ }
+
+ mir_forkthread(FromServerToClient,(LPVOID)hConnection);
+
+ //schleife behandelt empfangende daten
+ do {
+ int cbRead = Netlib_Recv(hConnection, buf, sizeof(buf), 0);
+ if( cbRead == SOCKET_ERROR)
+ {
+ Netlib_CloseHandle(hConnection);
+ Netlib_CloseHandle(netlibcon);
+ break;
+ }
+
+ if(cbRead) {
+ if(!Netlib_Send(netlibcon, buf, cbRead, 0))
+ {
+ Netlib_CloseHandle(hConnection);
+ Netlib_CloseHandle(netlibcon);
+ break;
+ }
+ }
+ }
+ while(1);
+}
+
+//inits nachdem alle module geladen wurden
+int AfterSystemModulesLoaded(WPARAM wParam,LPARAM lParam)
+{
+ //init netlib handle
+ NETLIBUSER nlu = {0};
+ nlu.cbSize = sizeof(nlu);
+ nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_INCOMING;
+ nlu.szSettingsModule = protocolname;
+ nlu.szDescriptiveName = "XFire server connection";
+ hNetlib = (HANDLE) CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM) & nlu);
+
+ //init socet server
+ NETLIBBIND nb = {0};
+ nb.cbSize = NETLIBBIND_SIZEOF_V2;
+ nb.pfnNewConnectionV2 = XfireclientConnecting;
+ nb.pExtra = NULL;
+ nb.wPort = 25999;
+ hBindPort = (HANDLE)CallService( MS_NETLIB_BINDPORT, (WPARAM)hNetlib,(LPARAM) &nb);
+
+
+ return 0;
+}
+
+int initXfireProxy() {
+ //inits nach dem alle module geladen wurden
+ HookEvent(ME_SYSTEM_MODULESLOADED, AfterSystemModulesLoaded);
+ return 0;
+}
diff --git a/protocols/Xfire/src/Xfire_proxy.h b/protocols/Xfire/src/Xfire_proxy.h
new file mode 100644
index 0000000000..3623d969dc
--- /dev/null
+++ b/protocols/Xfire/src/Xfire_proxy.h
@@ -0,0 +1,8 @@
+#ifndef _XFIRE_PROXY
+#define _XFIRE_PROXY
+
+#include "baseProtocol.h"
+
+int initXfireProxy();
+
+#endif \ No newline at end of file
diff --git a/protocols/Xfire/src/Xfire_voicechat.cpp b/protocols/Xfire/src/Xfire_voicechat.cpp
new file mode 100644
index 0000000000..ccca22b1a8
--- /dev/null
+++ b/protocols/Xfire/src/Xfire_voicechat.cpp
@@ -0,0 +1,380 @@
+#include "stdafx.h"
+#include "Xfire_voicechat.h"
+
+//konstruktor
+Xfire_voicechat::Xfire_voicechat() {
+ this->resetCurrentvoicestatus();
+ ipport=NULL;
+ tsrDLL=NULL;
+ IpHlpApiDLL=NULL;
+ tsrGetServerInfo=NULL;
+ GetExtendedTcpTable=NULL;
+ pid=0;
+}
+
+//dekonstruktor
+Xfire_voicechat::~Xfire_voicechat() {
+ //geladene tsr remote dll freigeben
+ if(tsrDLL) {
+ FreeLibrary(tsrDLL);
+ tsrDLL=NULL;
+ }
+ //geladene iphlper freigeben
+ if(IpHlpApiDLL) {
+ FreeLibrary(IpHlpApiDLL);
+ IpHlpApiDLL=NULL;
+ }
+}
+
+//init
+void Xfire_voicechat::initVoicechat() {
+ //tsremotedll laden
+ tsrDLL=this->loadTSR();
+ //weitere dll's laden
+ IpHlpApiDLL=LoadLibraryA("IpHlpApi.dll");
+ if(IpHlpApiDLL) {
+ GetExtendedTcpTable=(pGetExtendedTcpTable)GetProcAddress(IpHlpApiDLL,"GetExtendedTcpTable");
+ }
+ else
+ {
+ XFireLog("IpHlpApi.dll load failed!");
+ }
+}
+
+//prüft ob das paket schonmal versendet wurde, soll unnötigen nwtraffic reduzieren, *ÜBERLEGUNG* ob wirklich notwendig
+BOOL Xfire_voicechat::alreadySend(SendGameStatus2Packet* packet) {
+ if(packet==NULL)
+ return FALSE;
+
+ if(packet->ip[3] != lastpacket.ip[3] ||
+ packet->ip[2] != lastpacket.ip[2] ||
+ packet->ip[1] != lastpacket.ip[1] ||
+ packet->ip[0] != lastpacket.ip[0] ||
+ packet->port != lastpacket.port) {
+ lastpacket=*packet;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+//prüft nach laufenden voicechat anwendungen
+BOOL Xfire_voicechat::checkVoicechat(SendGameStatus2Packet* packet) {
+ //kein gültiger verweis?
+ if(packet==NULL)
+ return FALSE;
+ //jeh nach letzten status handeln
+ switch(currentvoice) {
+ case XFIREVOICECHAT_TS2:
+ if(checkforTS2(packet)) {
+ return alreadySend(packet);
+ }
+ else
+ {
+ //kein ts2 mehr? dann paket restten
+ resetSendGameStatus2Packet(packet);
+ resetCurrentvoicestatus();
+ //in db schreiben
+ writeToDatabase(packet);
+ return TRUE;
+ }
+ break;
+ case XFIREVOICECHAT_TS3:
+ if(checkforTS3(packet)) {
+ return alreadySend(packet);
+ }
+ else
+ {
+ //kein ts3 mehr? dann paket restten
+ resetSendGameStatus2Packet(packet);
+ resetCurrentvoicestatus();
+ //in db schreiben
+ writeToDatabase(packet);
+ return TRUE;
+ }
+ break;
+ case XFIREVOICECHAT_MUMBLE:
+ if(checkforMumble(packet)) {
+ return alreadySend(packet);
+ }
+ else
+ {
+ //kein mumble mehr? dann paket restten
+ resetSendGameStatus2Packet(packet);
+ resetCurrentvoicestatus();
+ //in db schreiben
+ writeToDatabase(packet);
+ return TRUE;
+ }
+ break;
+ default:
+ //prüfe nach ts3
+ if(checkforTS3(packet)) {
+ return alreadySend(packet);
+ }
+ //prüfe nach ts2
+ else if(checkforTS2(packet)) {
+ return alreadySend(packet);
+ }
+ //prüfe nach mumble
+ else if(checkforMumble(packet)) {
+ return alreadySend(packet);
+ }
+ break;
+ };
+
+ return FALSE;
+}
+
+//setzte currentvoice auf 0 zurück, falls es einen disconnect gab
+void Xfire_voicechat::resetCurrentvoicestatus() {
+ currentvoice=XFIREVOICECHAT_NOVOICE;
+ lastpacket.ip[3]=0;
+ lastpacket.ip[2]=0;
+ lastpacket.ip[1]=0;
+ lastpacket.ip[0]=0;
+ lastpacket.port=0;
+ pid=0;
+}
+
+//resettet das packet auf 0
+void Xfire_voicechat::resetSendGameStatus2Packet(SendGameStatus2Packet* packet) {
+ if(packet==NULL)
+ return;
+ //voiceid
+ packet->gameid=XFIREVOICECHAT_NOVOICE;
+ //ip zuweisen
+ packet->ip[3]=0;
+ packet->ip[2]=0;
+ packet->ip[1]=0;
+ packet->ip[0]=0;
+ //port zuweisen
+ packet->port=0;
+}
+
+//schreibt derzetigen status in die mirandadb für variables usw
+void Xfire_voicechat::writeToDatabase(SendGameStatus2Packet* packet) {
+ //für sprintf
+ char temp[32]="";
+
+ if(packet==NULL || packet->gameid==XFIREVOICECHAT_NOVOICE) {
+ //einträge aus der db entfernen
+ DBDeleteContactSetting(NULL,protocolname, "VServerIP");
+ DBDeleteContactSetting(NULL,protocolname, "currentvoicename");
+ //zurück
+ return;
+ }
+ //ip speichern
+ sprintf_s(temp,32,"%d.%d.%d.%d:%d",(unsigned char)packet->ip[3],(unsigned char)packet->ip[2],(unsigned char)packet->ip[1],(unsigned char)packet->ip[0],packet->port);
+ DBWriteContactSettingTString(NULL, protocolname, "VServerIP", temp);
+ //namen jeh nach id schreiben
+ switch(packet->gameid) {
+ case XFIREVOICECHAT_TS3:
+ DBWriteContactSettingTString(NULL, protocolname, "currentvoicename", "Teamspeak 3");
+ break;
+ case XFIREVOICECHAT_TS2:
+ DBWriteContactSettingTString(NULL, protocolname, "currentvoicename", "Teamspeak 2");
+ break;
+ case XFIREVOICECHAT_MUMBLE:
+ DBWriteContactSettingTString(NULL, protocolname, "currentvoicename", "Mumble");
+ break;
+ case XFIREVOICECHAT_VENTRILO:
+ DBWriteContactSettingTString(NULL, protocolname, "currentvoicename", "Ventrilo");
+ break;
+ };
+}
+
+//versucht die TSR zuladen
+HMODULE Xfire_voicechat::loadTSR(char* path,BOOL nolocaltest) {
+ char pathtotsr[MAX_PATH]="";
+
+ /*if(path)
+ ; was tun*/
+ strcat_s(pathtotsr,MAX_PATH,"TSRemote.dll");
+
+ //versuche dll zuladen
+ HMODULE tsrDLL = LoadLibrary(pathtotsr);
+ //konnte nicht geladen werden
+ if(!tsrDLL)
+ {
+ XFireLog("TSRemote.dll load failed!");
+
+ //bei keinem lokalen test abbruch
+ if(nolocaltest) return NULL;
+
+ //nochmal engl. lokal versuchen
+ tsrDLL = LoadLibrary("C:\\Program Files\\Teamspeak2_RC2\\client_sdk\\TSRemote.dll");
+
+ if(!tsrDLL) {
+ XFireLog("TSRemote.dll load faild (using standard installationpath)!");
+
+ //deutsches sys?
+ tsrDLL = LoadLibrary("C:\\Programme\\Teamspeak2_RC2\\client_sdk\\TSRemote.dll");
+
+ if(!tsrDLL)
+ XFireLog("TSRemote.dll load failed (using standard installationpath2)!");
+
+ //aufgeben
+ return NULL;
+ }
+ }
+
+ XFireLog("TSRemote.dll successfully loaded!");
+
+ //getserverinfo funktion holen
+ tsrGetServerInfo = (LPtsrGetServerInfo)GetProcAddress(tsrDLL,"tsrGetServerInfo");
+
+ return tsrDLL;
+}
+
+
+//teamspeak 3 detection, benötigt ts3plugin
+BOOL Xfire_voicechat::checkforTS3(SendGameStatus2Packet* packet) {
+ ts3IPPORT* ipport=NULL;
+ //kein gültiger verweis?
+ if(packet==NULL)
+ return FALSE;
+ //existiert ein filemap?
+ HANDLE hMapObject = OpenFileMappingA(FILE_MAP_READ, FALSE, "$ts3info4xfire$");
+ //nicht gefunden, dann kein ts3
+ if (hMapObject == NULL)
+ return FALSE;
+ //versuch ipport zubesorgen
+ ipport = (ts3IPPORT *) MapViewOfFile(hMapObject, FILE_MAP_READ, 0, 0, sizeof(ts3IPPORT));
+ //fehler beim zugriff auf filemap?
+ if(ipport==NULL)
+ {
+ CloseHandle(hMapObject);
+ return FALSE;
+ }
+
+ //wenn kein port, dann stimmt was mit der ip nicht, paket resetten
+ if(ipport->port==0) {
+ //packet resetten
+ resetSendGameStatus2Packet(packet);
+ //in db schreiben
+ writeToDatabase(packet);
+ return TRUE;
+ }
+
+ //voiceid zuweisen
+ this->currentvoice=XFIREVOICECHAT_TS3;
+ packet->gameid=XFIREVOICECHAT_TS3;
+ //ip zuweisen
+ packet->ip[3]=ipport->ip[3];
+ packet->ip[2]=ipport->ip[2];
+ packet->ip[1]=ipport->ip[1];
+ packet->ip[0]=ipport->ip[0];
+ //port zuweisen
+ packet->port=ipport->port;
+ //unmap, handle schließem
+ UnmapViewOfFile(ipport);
+ CloseHandle(hMapObject);
+ //in db schreiben
+ writeToDatabase(packet);
+ //ts3 gefunden
+ return TRUE;
+}
+
+//teamspeak 2 detection mit hilfe der tsr
+BOOL Xfire_voicechat::checkforTS2(SendGameStatus2Packet* packet) {
+ TtsrServerInfo serverinfo={0};
+
+ //get funktion ist nicht initialisiert
+ if(this->tsrGetServerInfo==NULL || packet==NULL)
+ {
+ return FALSE;
+ }
+
+ //infos holen
+ this->tsrGetServerInfo(&serverinfo);
+
+ //auswerten wenn serverip gesetzt
+ if(serverinfo.ServerIp[0]!=0)
+ {
+ char * pos=strrchr(serverinfo.ServerIp,':');
+ if(pos==0)
+ {
+ return FALSE;
+ }
+
+ *pos=0;
+ unsigned int ip=inet_addr(serverinfo.ServerIp);
+ pos++;
+ int port=atoi(pos);
+
+ //port zuweisen
+ packet->port=port;
+ //ip zuweisen
+ packet->ip[3]=LOBYTE(LOWORD(ip));
+ packet->ip[2]=HIBYTE(LOWORD(ip));
+ packet->ip[1]=LOBYTE(HIWORD(ip));
+ packet->ip[0]=HIBYTE(HIWORD(ip));
+ //gameid/voice zuweisen
+ packet->gameid=XFIREVOICECHAT_TS2;
+ this->currentvoice=XFIREVOICECHAT_TS2;
+ //ab in die db
+ writeToDatabase(packet);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+//detection für mumble
+BOOL Xfire_voicechat::checkforMumble(SendGameStatus2Packet* packet) {
+ //kein gültiger verweis?
+ if(packet==NULL)
+ return FALSE;
+
+ //gültige pid
+ if(this->pid!=0 && !this->isValidPid(this->pid))
+ {
+ this->pid=0;
+ return FALSE;
+ }
+ else {
+ if(!this->getPidByProcessName("mumble.exe",&this->pid)) {
+ return FALSE;
+ }
+ }
+
+ DWORD size=0;
+ MIB_TCPTABLE_OWNER_PID* ptab=NULL;
+ //tcptabelle holen
+ this->GetExtendedTcpTable(NULL,&size,FALSE, AF_INET, TCP_TABLE_OWNER_PID_CONNECTIONS, 0);
+ //überhaupt was drin?
+ if(size) {
+ ptab=(MIB_TCPTABLE_OWNER_PID*)malloc(size);
+ //liste auslesen
+ if(GetExtendedTcpTable(ptab,&size,FALSE, AF_INET, TCP_TABLE_OWNER_PID_CONNECTIONS, 0)==NO_ERROR)
+ {
+ for(unsigned int i=0;i<ptab->dwNumEntries;i++)
+ {
+ if(ptab->table[i].dwOwningPid==this->pid && ptab->table[i].dwLocalAddr!=ptab->table[i].dwRemoteAddr) //verbindung gefunden, hoffentlich
+ {
+ unsigned char*rip=(unsigned char*)&ptab->table[i].dwRemoteAddr;
+ XFireLog("IP %x,%x",ptab->table[i].dwRemoteAddr,ptab->table[i].dwRemotePort);
+ //ipzuweisen
+ packet->ip[3]=rip[0];
+ packet->ip[2]=rip[1];
+ packet->ip[1]=rip[2];
+ packet->ip[0]=rip[3];
+ //portzuweisen
+ packet->port=r(ptab->table[i].dwRemotePort);
+ //mumble
+ packet->gameid=XFIREVOICECHAT_MUMBLE;
+ this->currentvoice=XFIREVOICECHAT_MUMBLE;
+ //table wieder freigeben
+ delete ptab;
+ //mumble läuft + ip gefunden also TRUE
+ return TRUE;
+ }
+ }
+ }
+ delete ptab;
+ }
+
+ return FALSE;
+} \ No newline at end of file
diff --git a/protocols/Xfire/src/Xfire_voicechat.h b/protocols/Xfire/src/Xfire_voicechat.h
new file mode 100644
index 0000000000..1b70f3f456
--- /dev/null
+++ b/protocols/Xfire/src/Xfire_voicechat.h
@@ -0,0 +1,114 @@
+/*
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ *
+ * Copyright (C) 2009 by
+ * dufte <dufte@justmail.de>
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ *
+ * Miranda ICQ: the free icq client for MS Windows
+ * Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
+ *
+ */
+
+//Klasse behandelt alle Iconsachen unter Xfire
+
+#include "stdafx.h"
+
+#ifndef _XFIRE_VOICECHAT
+#define _XFIRE_VOICECHAT
+
+#include "client.h"
+#include "sendgamestatus2packet.h"
+#include "Xfire_base.h"
+
+#include <vector>
+
+/* tsr definitionen für teamspeak 2 */
+struct TtsrServerInfo
+{
+ char ServerName[30];
+ char WelcomeMessage[256];
+ int ServerVMajor;
+ int ServerVMinor;
+ int ServerVRelease;
+ int ServerVBuild;
+ char ServerPlatform[28]; //geändert in 28 - dufte
+ char ServerIp[30];
+ char ServerHost[102];
+ int ServerType;
+ int ServerMaxUsers;
+ int SupportedCodecs;
+ int ChannelCount;
+ int PlayerCount;
+};
+
+typedef int (__stdcall *LPtsrGetServerInfo)(TtsrServerInfo *tsrServerInfo);
+
+/* klassen definitionen */
+struct ts3IPPORT {
+ unsigned char ip[4];
+ unsigned short port;
+};
+
+enum XFIREVOICECHATTYPE {
+ XFIREVOICECHAT_NOVOICE,
+ XFIREVOICECHAT_TS3=35,
+ XFIREVOICECHAT_TS2=32,
+ XFIREVOICECHAT_MUMBLE=34,
+ XFIREVOICECHAT_VENTRILO=33,
+ XFIREVOICECHAT_IPDETECT=999
+};
+
+using namespace xfirelib;
+
+class Xfire_voicechat : public Xfire_base {
+private:
+ //interner status, des aktiven voicechats
+ XFIREVOICECHATTYPE currentvoice;
+ //ipportport structur für ts3
+ ts3IPPORT* ipport;
+ //statuspacket caching
+ SendGameStatus2Packet lastpacket;
+ //tsremotedll
+ HMODULE tsrDLL;
+ //tsrGetServerInfo funktion vom tsremotedll
+ LPtsrGetServerInfo tsrGetServerInfo;
+ //GetExtendedTcpTable für mumble
+ pGetExtendedTcpTable GetExtendedTcpTable;
+ //pid für mumble
+ DWORD pid;
+ //IpHlperApi Module
+ HMODULE IpHlpApiDLL;
+public:
+ Xfire_voicechat();
+ ~Xfire_voicechat();
+
+ void initVoicechat();
+ void resetSendGameStatus2Packet(SendGameStatus2Packet* packet);
+ void resetCurrentvoicestatus();
+ void writeToDatabase(SendGameStatus2Packet* packet);
+ HMODULE loadTSR(char* path=NULL,BOOL nolocaltest=FALSE);
+ BOOL checkVoicechat(SendGameStatus2Packet* packet);
+ BOOL alreadySend(SendGameStatus2Packet* packet);
+
+ //prüf routinen
+ BOOL checkforTS3(SendGameStatus2Packet* packet);
+ BOOL checkforTS2(SendGameStatus2Packet* packet);
+ BOOL checkforMumble(SendGameStatus2Packet* packet);
+};
+
+#endif \ No newline at end of file
diff --git a/protocols/Xfire/src/addgamedialog.cpp b/protocols/Xfire/src/addgamedialog.cpp
new file mode 100644
index 0000000000..4d3d717b8c
--- /dev/null
+++ b/protocols/Xfire/src/addgamedialog.cpp
@@ -0,0 +1,867 @@
+#include "stdafx.h"
+
+#include "addgamedialog.h"
+
+extern HANDLE XFireWorkingFolder;
+extern Xfire_gamelist xgamelist;
+
+char inipath[MAX_PATH];
+char* buffer=NULL;
+BOOL dontClose=FALSE;
+
+vector<lbInicache> Inicache;
+Xfire_game* editgame=NULL;
+
+HWND hwndTab,hPage;
+
+void AddGameDialog(HWND hwndDlg,Xfire_game* game) {
+ //übergebendes game, dem editgame zuordnen, damit wechselt es in den editmodus
+ editgame=game;
+ if(DialogBox(hinstance,MAKEINTRESOURCE(IDD_ADDGAMEMAIN),hwndDlg,DlgAddGameProcMain)) {
+ }
+ //wieder auf NULL setzen
+ editgame=NULL;
+}
+
+static void FillGameList( LPVOID hwndDlg ) {
+ //liste.,suche und suchlabel unsichtbar machen
+ ShowWindow(GetDlgItem((HWND)hwndDlg,IDC_GAMELIST),SW_HIDE);
+ ShowWindow(GetDlgItem((HWND)hwndDlg,IDC_SEARCH),SW_HIDE);
+ ShowWindow(GetDlgItem((HWND)hwndDlg,IDC_STC14),SW_HIDE);
+
+ //handle von progressbar holen
+ HWND hwndPB=GetDlgItem((HWND)hwndDlg,IDC_PROGRESS);
+
+ //das schließen des dialogs verhindern
+ dontClose=TRUE;
+
+ if(Inicache.size()==0)
+ {
+ //temp xfirebaseob für strlower
+ Xfire_base tempxfire;
+ //vector für doppelfilter
+ vector<DWORD> dublBuffer;
+ //Cache ist leer, Cache füllen
+ FoldersGetCustomPath( XFireWorkingFolder, inipath, 1024, "" );
+ strcat_s(inipath,MAX_PATH,"\\");
+ strcat_s(inipath,MAX_PATH,"xfire_games.ini");
+
+ //ini soll in den RAM geladen werden, fürs schnellere ausparsen
+ FILE* f=fopen(inipath,"rb");
+ //wenn ini nicht aufrufbar, abbrechen
+ if(f==NULL)
+ return;
+ //ans ende der datei springen
+ fseek(f,0,SEEK_END);
+ //aktuelle position im filepoitner als größe zwischenspeichern
+ int size=ftell(f);
+ //buffer anelgen
+ buffer=new char[size+1];
+ //wenn nicht genug ram, abbruch
+ if(buffer==NULL)
+ return;
+ //buffer nullen
+ memset(buffer,0,size+1);
+ //zum anfang springen
+ fseek(f,0,SEEK_SET);
+ //ini komplett in den ram lesen
+ fread(buffer,size,1,f);
+ //datei schließen
+ fclose(f);
+
+ //parse einzelne sections aus
+
+ //pointer vom buffer
+ char*p=buffer;
+ //zahlenbufer1 und pointer
+ char zahlbuffer[10]="";
+ char*z=zahlbuffer;
+ //zahlenbuffer2 uznd pointer
+ char zahlbuffer2[10]="";
+ char*z2=zahlbuffer2;
+
+ //progressbar auf bytegröße anpassen
+ SendMessage(hwndPB, PBM_SETRANGE32, 0,size);
+
+ //solange bis wir bei 0 angekommen sind
+ if(*p!=0)
+ p++;
+ while(*p!=0)
+ {
+ if(*p=='['&&*(p-1)=='\n')
+ {
+ z=zahlbuffer;
+ z2=zahlbuffer2;
+ p++;
+ while(*p>='0'&&*p<='9'&&p!=0)
+ {
+ *z=*p;
+ p++;
+ z++;
+ }
+ *z=0;
+ if(*p=='_') {
+ p++;
+ while(*p>='0'&&*p<='9'&&p!=0)
+ {
+ *z2=*p;
+ p++;
+ z2++;
+ }
+ *z2=0;
+ }
+
+ //erste zahl gefunden
+ if(z!=zahlbuffer)
+ {
+ int gameid=atoi(zahlbuffer);
+ //prüfe ob das game schon in der gameliste ist
+ if(!xgamelist.Gameinlist(gameid))
+ {
+ char*name=p;
+ lbInicache listentry;
+ char gameidtemp[10]="";
+ char ret[512];
+ DWORD uniqid=0;
+ BYTE accLaunch=0;
+ BYTE accDetect=0;
+
+ //bis zum nächsten isgleich springen
+ while(*name!='=')
+ name++;
+ name++;
+
+ //jetzt den umbruch suchen
+ p=name;
+ while(*p!='\n'&&*p!='\r') p++;
+ *p=0;
+ p++;
+
+ //spielnamen in den listentry einfügen
+ strcpy_s(listentry.name,255,name);
+
+ if(z2!=zahlbuffer2)
+ {
+ listentry.gameid=MAKELONG(gameid,atoi(zahlbuffer2));
+ sprintf_s(gameidtemp,10,"%d_%d",gameid,atoi(zahlbuffer2));
+ }
+ else
+ {
+ listentry.gameid=gameid;
+ sprintf_s(gameidtemp,10,"%d",gameid);
+ }
+
+
+ if(xfire_GetPrivateProfileString(gameidtemp, "LauncherExe", "", ret, 512, inipath)) {
+ //lower launchstring
+ tempxfire.strtolower(ret);
+ //einzelnen ziechen zusammenrechnen
+ if(z2!=zahlbuffer2)
+ {
+ //wenn pfad, dann exe vorher rausziehen
+ if(strrchr(ret,'\\'))
+ accLaunch=tempxfire.accStringByte(strrchr(ret,'\\'));
+ else
+ accLaunch=tempxfire.accStringByte(ret);
+ }
+ //Steam.exe als launcher?
+ if((ret[0]=='s')&&
+ ret[1]=='t'&&
+ ret[2]=='e'&&
+ ret[3]=='a'&&
+ ret[4]=='m'&&
+ ret[5]=='.'&&
+ ret[6]=='e'&&
+ ret[7]=='x'&&
+ ret[8]=='e')
+ {
+ strcat_s(listentry.name,255," (Steam)");
+ }
+ }
+
+ if(z2!=zahlbuffer2) {
+ if(xfire_GetPrivateProfileString(gameidtemp, "DetectExe", "", ret, 512, inipath)) {
+ //lower launchstring
+ tempxfire.strtolower(ret);
+ //einzelnen ziechen zusammenrechnen
+ //wenn pfad, dann exe vorher rausziehen
+ if(strrchr(ret,'\\'))
+ accDetect=tempxfire.accStringByte(strrchr(ret,'\\'));
+ else
+ accDetect=tempxfire.accStringByte(ret);
+ }
+ }
+
+ //standardmäßig TRUE
+ BOOL addtolist=TRUE;
+
+ //schon ein eintrag vorhanden?
+ if(z2!=zahlbuffer2) {
+ //uniq id zusammen bauen aus spielid sowie zusammengerechneten launchstring und detectstring
+ uniqid=MAKELONG(gameid,MAKEWORD(accLaunch,accDetect));
+ for(uint i = 0 ; i < dublBuffer.size() ; i ++) {
+ if(dublBuffer.at(i)==uniqid)
+ {
+ addtolist=FALSE;
+ break;
+ }
+ }
+ }
+
+ //nur eintragen, wenn kein doppelter gefunden wurde
+ if(addtolist) {
+ //eintrag einfügen
+ int idx=SendDlgItemMessage( (HWND)hwndDlg, IDC_GAMELIST, LB_ADDSTRING, 0, (LPARAM)listentry.name);
+ SendDlgItemMessage( (HWND)hwndDlg, IDC_GAMELIST, LB_SETITEMDATA, idx, listentry.gameid);
+ //eintrag in den buffer für die dublikateprüfung
+ dublBuffer.push_back(uniqid);
+ //und eintrag in den cache
+ Inicache.push_back(listentry);
+ SendMessage(hwndPB, PBM_SETPOS, (WPARAM)(p-buffer), 0);
+ }
+ }
+ }
+ }
+ else
+ p++;
+ }
+ }
+ else
+ {
+ //liste mit dem cache aufbauen
+ for(uint i = 0 ; i < Inicache.size() ; i ++) {
+ //spielid in der liste spielliste?
+ if(!xgamelist.Gameinlist(LOWORD(Inicache.at(i).gameid)))
+ {
+ //eintrag in die listeeinfügen
+ int idx=SendDlgItemMessage( (HWND)hwndDlg, IDC_GAMELIST, LB_ADDSTRING, 0, (LPARAM)Inicache.at(i).name);
+ //gameid zuweisen
+ SendDlgItemMessage( (HWND)hwndDlg, IDC_GAMELIST, LB_SETITEMDATA, idx, Inicache.at(i).gameid);
+ }
+ }
+ }
+
+ //progressbar unsichtbar
+ ShowWindow(hwndPB,SW_HIDE);
+ //liste sichtbar machen
+ ShowWindow(GetDlgItem((HWND)hwndDlg,IDC_GAMELIST),SW_SHOW);
+ //suche und suchlabel sichtbar machen
+ ShowWindow(GetDlgItem((HWND)hwndDlg,IDC_SEARCH),SW_SHOW);
+ ShowWindow(GetDlgItem((HWND)hwndDlg,IDC_STC14),SW_SHOW);
+
+ dontClose=FALSE;
+}
+
+BOOL OpenFileDialog(HWND hwndDlg,OPENFILENAME*ofn,char*exe) {
+ //pointer zum exenamen
+ char* exename=NULL;
+ //buffer vom pfad
+ static char szFile[260]=""; //static damit noch nach dem aufruf lesbar bleibt
+ //buffer vom filter
+ char szFilter[260]="";
+ //backslash suchen
+ exename=strrchr(exe,'\\')+1;
+ //kein backslash dann normal ret als exenamen verwenden
+ if((int)exename==1) exename=exe;
+ //filterstring aufbauen
+ sprintf(szFilter,"%s|%s|%s|*.*|",exename,exename,Translate("All Files"));
+ //umbruch in 0 wandeln
+ unsigned int sizeFilter=strlen(szFilter);
+ for(unsigned int i=0;i<sizeFilter;i++)
+ if(szFilter[i]=='|') szFilter[i]=0;
+ //openfiledia vorbereiten
+ ZeroMemory(ofn, sizeof(OPENFILENAME));
+ ofn->lStructSize = sizeof(OPENFILENAME);
+ ofn->hwndOwner = hwndDlg;
+ ofn->lpstrFile = szFile;
+ ofn->nMaxFile = sizeof(szFile);
+ ofn->lpstrFilter = szFilter;
+ ofn->nFilterIndex = 1;
+ ofn->lpstrFileTitle = exe;
+ ofn->nMaxFileTitle = 0;
+ ofn->lpstrInitialDir = NULL;
+ ofn->Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
+
+ return GetOpenFileName(ofn);
+}
+
+INT_PTR CALLBACK DlgAddGameProc (HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam
+)
+{
+ switch (uMsg) {
+ case WM_INITDIALOG:
+ {
+ //übersetzen lassen
+ TranslateDialogDefault(hwndDlg);
+
+
+ //per thread liste füllen
+ mir_forkthread(FillGameList,hwndDlg);
+ }
+ break;
+ case WM_COMMAND:
+ if(LOWORD(wParam) == IDC_SEARCH && HIWORD(wParam)==EN_CHANGE)
+ {
+ char temp[256];
+ //eingabe bei der suche auslesen
+ GetDlgItemText(hwndDlg,IDC_SEARCH,temp,256);
+ //eingabe in der liste suchen
+ int idx=SendDlgItemMessage(hwndDlg, IDC_GAMELIST, LB_FINDSTRING, 0, (LPARAM)temp);
+ //gefunden?
+ if(idx!=LB_ERR)
+ {
+ //als aktiv setzen
+ SendDlgItemMessage(hwndDlg, IDC_GAMELIST,LB_SETCURSEL,idx,0);
+ }
+ }
+ else if(LOWORD(wParam) == IDCANCEL)
+ {
+ //nicht schließen, wenn noch der thread läuft
+ if(dontClose) {
+ MessageBoxA(hwndDlg, Translate("Please wait, gameini will be currently parsed ..."), Translate("XFire Options"), MB_OK|MB_ICONEXCLAMATION);
+ return FALSE;
+ }
+ return SendMessage(GetParent(hwndDlg),WM_CLOSE,0,0);
+ }
+ else if(LOWORD(wParam) == IDC_CUSTOM)
+ {
+ int idx=SendDlgItemMessage(hwndDlg, IDC_GAMELIST, LB_GETCURSEL, 0, 0);
+ //es wurde was ausgewählt?
+ if(idx==LB_ERR) {
+ MessageBoxA(hwndDlg,Translate("Please choose one game in the list!"),Translate("XFire Options"),MB_OK|MB_ICONEXCLAMATION);
+ }
+ else
+ {
+ char ret[512]="";
+ char gameidtemp[10]="";
+
+ int gameids=SendDlgItemMessage( (HWND)hwndDlg, IDC_GAMELIST, LB_GETITEMDATA, idx, 0);
+ //gameid splitten
+ int gameid1=LOWORD(gameids);
+ int gameid2=HIWORD(gameids);
+
+ if(gameid2!=0)
+ sprintf_s(gameidtemp,10,"%d_%d",gameid1,gameid2);
+ else
+ sprintf_s(gameidtemp,10,"%d",gameid1);
+
+ //spielnamen holen
+ if(xfire_GetPrivateProfileString(gameidtemp, "LongName", "", ret, 512, inipath)) {
+ sprintf_s(gameidtemp,10,"%d",gameid1);
+
+ //einige felder vorbelegen
+ SetDlgItemText(hPage,IDC_ADD_NAME,ret);
+ SetDlgItemText(hPage,IDC_ADD_DETECTEXE,"");
+ SetDlgItemText(hPage,IDC_ADD_LAUNCHEREXE,"");
+ SetDlgItemText(hPage,IDC_ADD_ID,gameidtemp);
+ SetDlgItemText(hPage,IDC_ADD_STATUSMSG,"");
+ SetDlgItemText(hPage,IDC_ADD_CUSTOMPARAMS,"");
+ SetDlgItemText(hPage,IDC_ADD_SENDID,gameidtemp);
+
+ //auf customeintrag edit tab wechseln
+ TabCtrl_SetCurSel(hwndTab, 1);
+ ShowWindow(hwndDlg,SW_HIDE);
+ ShowWindow(hPage,SW_SHOW);
+ }
+ }
+ }
+ else if(LOWORD(wParam) == IDOK)
+ {
+ int idx=SendDlgItemMessage(hwndDlg, IDC_GAMELIST, LB_GETCURSEL, 0, 0);
+ //es wurde was ausgewählt?
+ if(idx==LB_ERR) {
+ MessageBoxA(hwndDlg,Translate("Please choose one game in the list!"),Translate("XFire Options"),MB_OK|MB_ICONEXCLAMATION);
+ }
+ else
+ {
+ //datei öffnen dialog
+ OPENFILENAME ofn;
+ //listdata auslesen, wo die gameid gespeihcert ist
+ int gameids=SendDlgItemMessage( (HWND)hwndDlg, IDC_GAMELIST, LB_GETITEMDATA, idx, 0);
+ //gameid splitten
+ int gameid1=LOWORD(gameids);
+ int gameid2=HIWORD(gameids);
+ char gameidtemp[10]="";
+ char ret[512];
+
+ if(gameid2!=0)
+ sprintf_s(gameidtemp,10,"%d_%d",gameid1,gameid2);
+ else
+ sprintf_s(gameidtemp,10,"%d",gameid1);
+
+ //neuen gameeintrag anlegen
+ Xfire_game* newgame=new Xfire_game();
+ //gameid und sendid setzen
+ newgame->id=gameid1;
+ newgame->send_gameid=gameid1;
+ //es handelt sich um einen customeintrag, man staune xD
+ newgame->custom=1;
+
+ //launcherexe abfragen
+ if(xfire_GetPrivateProfileString(gameidtemp, "LauncherExe", "", ret, 512, inipath)) {
+ //datei vom user öffnen lassen
+ if(OpenFileDialog(hwndDlg,&ofn,ret))
+ {
+ //lowercase pfad
+ newgame->strtolower(ofn.lpstrFile);
+ //pfad dem spiel zuordnen
+ newgame->setString(ofn.lpstrFile,&newgame->launchparams);
+ }
+ else
+ {
+ //speicher freigeben
+ delete newgame;
+ return FALSE;
+ }
+ }
+
+ //detectexe abfragen
+ if(xfire_GetPrivateProfileString(gameidtemp, "DetectExe", "", ret, 512, inipath)) {
+ //datei vom user öffnen lassen
+ if(OpenFileDialog(hwndDlg,&ofn,ret))
+ {
+ //lowercase pfad
+ newgame->strtolower(ofn.lpstrFile);
+ //pfad dem spiel zuordnen
+ newgame->setString(ofn.lpstrFile,&newgame->path);
+ }
+ else
+ {
+ //speicher freigeben
+ delete newgame;
+ return FALSE;
+ }
+ } //MatchExe abfragen
+ else if(xfire_GetPrivateProfileString(gameidtemp, "MatchExe", "", ret, 512, inipath)) {
+ //datei vom user öffnen lassen
+ if(OpenFileDialog(hwndDlg,&ofn,ret))
+ {
+ //lowercase pfad
+ newgame->strtolower(ofn.lpstrFile);
+ //pfad dem spiel zuordnen
+ newgame->setString(ofn.lpstrFile,&newgame->path);
+ }
+ else
+ {
+ //speicher freigeben
+ delete newgame;
+ return FALSE;
+ }
+ }
+
+
+ //prüfe ob schon ein launchstring festgelegt wurde, wenn nicht die detectexe nehmen
+ if(!newgame->launchparams&&newgame->path) {
+ newgame->setString(newgame->path,&newgame->launchparams);
+ }
+
+ //prüfe ob schon ein detectexe festgelegt wurde, wenn nicht die launchstring nehmen
+ if(newgame->launchparams&&!newgame->path) {
+ newgame->setString(newgame->launchparams,&newgame->path);
+ }
+
+ //LauncherUrl wird der launcherstring überschrieben
+ if(xfire_GetPrivateProfileString(gameidtemp, "LauncherUrl", "", ret, 512, inipath)) {
+ newgame->setString(ret,&newgame->launchparams);
+ }
+ else if(xfire_GetPrivateProfileString(gameidtemp, "Launch", "", ret, 512, inipath)) {
+ str_replace(ret,"%UA_LAUNCHER_EXE_PATH%",""); //erstmal unwichtige sachen entfernen
+ //str_replace(ret,"%UA_LAUNCHER_EXTRA_ARGS%",""); // - auch entfernen
+ str_replace(ret,"%UA_LAUNCHER_LOGIN_ARGS%",""); // - auch entfernen
+
+ //ein leerzeichen anfügen
+ newgame->appendString(" ",&newgame->launchparams);
+ //nun commandline des launchstringes dranhängen
+ newgame->appendString(ret,&newgame->launchparams);
+ }
+
+ //restliche wichtige felder einfügen
+ if(xfire_GetPrivateProfileString(gameidtemp, "LauncherPasswordArgs", "", ret, 512, inipath))
+ newgame->setString(ret,&newgame->pwparams);
+ if(xfire_GetPrivateProfileString(gameidtemp, "LauncherNetworkArgs", "", ret, 512, inipath))
+ newgame->setString(ret,&newgame->networkparams);
+ if(xfire_GetPrivateProfileString(gameidtemp, "CommandLineMustContain[0]", "", ret, 512, inipath))
+ newgame->setString(ret,&newgame->mustcontain);
+ if(xfire_GetPrivateProfileString(gameidtemp, "XUSERSendId", "", ret, 512, inipath))
+ newgame->send_gameid=atoi(ret);
+ if(xfire_GetPrivateProfileString(gameidtemp, "XUSERSetStatusMsg", "", ret, 512, inipath))
+ newgame->setstatusmsg=atoi(ret);
+
+ //namen setzen und icon laden
+ newgame->setNameandIcon();
+ //spiel in die gameliste einfügen
+ xgamelist.Addgame(newgame);
+ //derzeitige gameliste in die datenbank eintragen
+ xgamelist.writeDatabase();
+ //startmenu leeren
+ xgamelist.clearStartmenu();
+ //startmenu neuerzeugen
+ xgamelist.createStartmenu();
+
+ return SendMessage(GetParent(hwndDlg),WM_CLOSE,0,0);
+ }
+ }
+ break;
+ case WM_CLOSE:
+ //nicht schließen, wenn noch der thread läuft
+ if(dontClose) {
+ MessageBoxA(hwndDlg, Translate("Please wait, gameini will be currently parsed ..."), Translate("XFire Options"), MB_OK|MB_ICONEXCLAMATION);
+ return FALSE;
+ }
+ //hauptfenster schließen
+ SendMessage(GetParent(hwndDlg),WM_CLOSE,0,0);
+ break;
+ }
+ return FALSE;
+}
+
+
+INT_PTR CALLBACK DlgAddGameProc2 (HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam
+)
+{
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+ //ein spiel wurde zum editieren geöffnet, felder alle vorbelegen
+ if(editgame) {
+ //add augf übernehmen umstellen
+ SetDlgItemTextA(hwndDlg,IDOK,Translate("Apply"));
+
+ //namen vorbelegen
+ if(editgame->customgamename)
+ SetDlgItemTextA(hwndDlg,IDC_ADD_NAME,editgame->customgamename);
+ else if(editgame->name)
+ SetDlgItemTextA(hwndDlg,IDC_ADD_NAME,editgame->name);
+
+ //gameid setzen und feld schreibschützen
+ char gameid[10]="";
+ _itoa_s(editgame->id,gameid,10,10);
+ SetDlgItemTextA(hwndDlg,IDC_ADD_ID,gameid);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_ADD_ID),FALSE);
+
+ //sendgameid setzen, bei -1 leer lassen
+ if(editgame->send_gameid!=-1)
+ {
+ _itoa_s(editgame->send_gameid,gameid,10,10);
+ SetDlgItemTextA(hwndDlg,IDC_ADD_SENDID,gameid);
+ }
+
+ //launcherstring
+ if(editgame->launchparams) {
+ SetDlgItemTextA(hwndDlg,IDC_ADD_LAUNCHEREXE,editgame->launchparams);
+ }
+
+ //detectstring
+ if(editgame->path) {
+ SetDlgItemTextA(hwndDlg,IDC_ADD_DETECTEXE,editgame->path);
+ }
+
+ //statusmsg
+ if(editgame->statusmsg) {
+ SetDlgItemTextA(hwndDlg,IDC_ADD_STATUSMSG,editgame->statusmsg);
+ }
+
+ //mustcontain parameter
+ if(editgame->mustcontain) {
+ SetDlgItemTextA(hwndDlg,IDC_ADD_CUSTOMPARAMS,editgame->mustcontain);
+ }
+ }
+ //dialog übersetzen
+ TranslateDialogDefault(hwndDlg);
+
+ return TRUE;
+
+ case WM_COMMAND:
+ {
+ if(LOWORD(wParam) == IDC_SENDIDHELP)
+ {
+ MessageBoxA(hwndDlg, Translate("If you add a mod of a Xfire supported game, then you can specify what gameid will be sent to Xfire. So if you add a Half-Life mod, you can set the Half-Life game id and if you start the game, your Xfire buddies will see the Half-Life game icon next to your name and the game time will be tracked."), Translate("XFire Options"), MB_OK|MB_ICONASTERISK);
+ }
+ else if(LOWORD(wParam) == IDC_GAMEIDHELP)
+ {
+ MessageBoxA(hwndDlg, Translate("Every game in Xfire needs an id. Use a number above the last used id to avoid problems with used ids. Every number above 10000 should be save. This id will not be sent to Xfire, when you start a game."), Translate("XFire Options"), MB_OK|MB_ICONASTERISK);
+ }
+ else if(LOWORD(wParam) == IDC_ADD_BROWSEDETECT)
+ {
+ OPENFILENAME ofn;
+ if(OpenFileDialog(hwndDlg,&ofn,"*.exe"))
+ {
+ SetDlgItemText(hwndDlg,IDC_ADD_DETECTEXE,ofn.lpstrFile);
+ }
+ }
+ else if(LOWORD(wParam) == IDC_ADD_BROWSELAUNCHER)
+ {
+ OPENFILENAME ofn;
+ if(OpenFileDialog(hwndDlg,&ofn,"*.exe"))
+ {
+ SetDlgItemText(hwndDlg,IDC_ADD_LAUNCHEREXE,ofn.lpstrFile);
+ }
+ }
+ else if(LOWORD(wParam) == IDCANCEL)
+ {
+ //nicht schließen, wenn noch der thread läuft
+ if(dontClose) {
+ MessageBoxA(hwndDlg, Translate("Please wait, gameini will be currently parsed ..."), Translate("XFire Options"), MB_OK|MB_ICONEXCLAMATION);
+ return FALSE;
+ }
+ return SendMessage(GetParent(hwndDlg),WM_CLOSE,0,0);
+ }
+ else if(LOWORD(wParam) == IDOK)
+ {
+ char temp[256];
+
+ //fillgames sucht noch
+ if(dontClose) {
+ MessageBoxA(hwndDlg, Translate("Please wait, gameini will be currently parsed ..."), Translate("XFire Options"), MB_OK|MB_ICONEXCLAMATION);
+ return FALSE;
+ }
+
+ //neuen gameeintrag anlegen
+ Xfire_game* newgame=NULL;
+
+ if(editgame)
+ newgame=editgame;
+ else
+ newgame=new Xfire_game();
+
+ //Spielname
+ GetDlgItemText(hwndDlg,IDC_ADD_NAME,temp,256);
+ if(!strlen(temp))
+ {
+ if(!editgame) delete newgame;
+ return MessageBoxA(hwndDlg, Translate("Please enter a game name."), Translate("XFire Options"), MB_OK|MB_ICONEXCLAMATION);
+ }
+ else
+ {
+ //spielname zuordnen
+ newgame->setString(temp,&newgame->customgamename);
+ //spielnamen fürs menü
+ newgame->setString(temp,&newgame->name);
+ }
+ //spielid nur setzen/prüfen, wenn kein editgame
+ if(!editgame) {
+ GetDlgItemText(hwndDlg,IDC_ADD_ID,temp,256);
+ if(!strlen(temp))
+ {
+ if(!editgame) delete newgame;
+ return MessageBoxA(hwndDlg, Translate("Please enter a game id."), Translate("XFire Options"), MB_OK|MB_ICONEXCLAMATION);
+ }
+ else
+ {
+ int gameid=atoi(temp);
+ //negative gameid blocken
+ if(gameid<1)
+ {
+ if(!editgame) delete newgame;
+ return MessageBoxA(hwndDlg, Translate("Please enter a game id above 1."), Translate("XFire Options"), MB_OK|MB_ICONEXCLAMATION);
+ }
+ //gameid auf uniq prüfen
+ else if(xgamelist.getGamebyGameid(gameid))
+ {
+ if(!editgame) delete newgame;
+ return MessageBoxA(hwndDlg, Translate("This game id is already in use."), Translate("XFire Options"), MB_OK|MB_ICONEXCLAMATION);
+ }
+ //gameid zuordnen
+ newgame->id=gameid;
+ //standardmäßig wird bei einem customeintrag keine id versendet
+ newgame->send_gameid=-1;
+ }
+ }
+ //zu sendene spielid
+ GetDlgItemText(hwndDlg,IDC_ADD_SENDID,temp,256);
+ if(strlen(temp))
+ {
+ //standardmäßig wird bei einem customeintrag keine id versendet
+ int sendid=atoi(temp);
+ if(sendid>0)
+ newgame->send_gameid=sendid;
+ }
+
+ //launcher exe
+ GetDlgItemText(hwndDlg,IDC_ADD_LAUNCHEREXE,temp,256);
+ if(strlen(temp))
+ {
+ //lowercase pfad
+ newgame->strtolower(temp);
+ //detect exe
+ newgame->setString(temp,&newgame->launchparams);
+ }
+ //detectexe
+ GetDlgItemText(hwndDlg,IDC_ADD_DETECTEXE,temp,256);
+ if(!strlen(temp))
+ {
+ if(!editgame) delete newgame;
+ return MessageBoxA(hwndDlg, Translate("Please select a game exe. Note: If you dont select a launcher exe, the game exe will be used in the game start menu."), Translate("XFire Options"), MB_OK|MB_ICONEXCLAMATION);
+ }
+ else
+ {
+ //lowercase pfad
+ newgame->strtolower(temp);
+ //detect exe
+ newgame->setString(temp,&newgame->path);
+ //wenn kein launcher exe/pfad angeben wurde, dann den gamepath nehmen
+ if(!newgame->launchparams)
+ newgame->setString(temp,&newgame->launchparams);
+
+ }
+ //mustcontain parameter
+ GetDlgItemText(hwndDlg,IDC_ADD_CUSTOMPARAMS,temp,256);
+ if(strlen(temp))
+ {
+ newgame->setString(temp,&newgame->mustcontain);
+ }
+ //statusmsg speichern
+ GetDlgItemText(hwndDlg,IDC_ADD_STATUSMSG,temp,256);
+ if(strlen(temp))
+ {
+ newgame->setString(temp,&newgame->statusmsg);
+ newgame->setstatusmsg=1;
+ }
+ //custom eintrag aktivieren
+ newgame->custom=1;
+ //spiel in die gameliste einfügen, aber nur im nicht editmodus
+ if(!editgame)
+ xgamelist.Addgame(newgame);
+ //derzeitige gameliste in die datenbank eintragen
+ xgamelist.writeDatabase();
+ //startmenu leeren
+ xgamelist.clearStartmenu();
+ //startmenu neuerzeugen
+ xgamelist.createStartmenu();
+
+ return SendMessage(GetParent(hwndDlg),WM_CLOSE,0,0);
+ }
+ break;
+ }
+ }
+ return FALSE;
+}
+
+
+INT_PTR CALLBACK DlgAddGameProcMain (HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam
+)
+{
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+ {
+ TCITEMA tci = {0};
+ int iTotal;
+ RECT rcClient;
+
+ //icon des dialogs setzen
+ SendMessage(hwndDlg,WM_SETICON, (WPARAM)false, (LPARAM)LoadIcon(hinstance, MAKEINTRESOURCE(IDI_TM)));
+
+ hwndTab = GetDlgItem(hwndDlg, IDC_OPTIONSTAB);
+ TabCtrl_DeleteAllItems(hwndTab);
+ GetClientRect(GetParent(hwndTab), &rcClient);
+
+ hPage=CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADDGAME), hwndDlg, DlgAddGameProc);
+
+ //bei editgame keine spiellisteauswahl
+ if(!editgame)
+ {
+ iTotal = TabCtrl_GetItemCount(hwndTab);
+ tci.mask = TCIF_PARAM|TCIF_TEXT;
+ tci.lParam = (LPARAM)hPage;
+ tci.pszText = Translate("Supported Games");
+ SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tci);
+ MoveWindow(hPage, 3, 24, rcClient.right - 10, rcClient.bottom - 28, 1);
+ iTotal++;
+ }
+ else
+ ShowWindow(hPage,FALSE);
+
+ hPage=CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADDGAME2), hwndDlg, DlgAddGameProc2);
+ iTotal = TabCtrl_GetItemCount(hwndTab);
+ tci.mask = TCIF_PARAM|TCIF_TEXT;
+ tci.lParam = (LPARAM)hPage;
+ tci.pszText = Translate("Custom game");
+ SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tci);
+ MoveWindow(hPage, 3, 24, rcClient.right - 10, rcClient.bottom - 28, 1);
+ iTotal++;
+
+ //bei editgame 2. registerkarte aktiv schalten
+ if(!editgame) {
+ ShowWindow(hPage,FALSE);
+ TabCtrl_SetCurSel(hwndTab, 0);
+ }
+
+ return TRUE;
+ }
+ case WM_CLOSE:
+ //nicht schließen, wenn noch der thread läuft
+ if(dontClose) return FALSE;
+ //buffer leeren
+ if(buffer)
+ {
+ delete[] buffer;
+ buffer=NULL;
+ }
+ EndDialog(hwndDlg,0);
+ break;
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->idFrom)
+ {
+ case 0:
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case PSN_APPLY:
+ {
+ TCITEM tci;
+ int i,count;
+
+ tci.mask = TCIF_PARAM;
+ count = TabCtrl_GetItemCount(GetDlgItem(hwndDlg,IDC_OPTIONSTAB));
+ for (i=0; i<count; i++)
+ {
+ TabCtrl_GetItem(GetDlgItem(hwndDlg,IDC_OPTIONSTAB),i,&tci);
+ SendMessage((HWND)tci.lParam,WM_NOTIFY,0,lParam);
+ }
+ break;
+ }
+ }
+ break;
+
+ case IDC_OPTIONSTAB:
+ {
+ HWND hTabCtrl = GetDlgItem(hwndDlg, IDC_OPTIONSTAB);
+
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case TCN_SELCHANGING:
+ {
+ TCITEM tci;
+
+ tci.mask = TCIF_PARAM;
+ TabCtrl_GetItem(hTabCtrl, TabCtrl_GetCurSel(hTabCtrl), &tci);
+ ShowWindow((HWND)tci.lParam, SW_HIDE);
+ }
+ break;
+
+ case TCN_SELCHANGE:
+ {
+ TCITEM tci;
+
+ tci.mask = TCIF_PARAM;
+ TabCtrl_GetItem(hTabCtrl, TabCtrl_GetCurSel(hTabCtrl), &tci);
+ ShowWindow((HWND)tci.lParam,SW_SHOW);
+ }
+ break;
+ }
+ break;
+ }
+ }
+ break;
+ }
+ return FALSE;
+} \ No newline at end of file
diff --git a/protocols/Xfire/src/addgamedialog.h b/protocols/Xfire/src/addgamedialog.h
new file mode 100644
index 0000000000..3795df1ed5
--- /dev/null
+++ b/protocols/Xfire/src/addgamedialog.h
@@ -0,0 +1,28 @@
+#ifndef _ADDGAME_H
+#define _ADDGAME_H
+
+#include "baseProtocol.h"
+#include "Xfire_gamelist.h"
+
+//dialog funktion
+INT_PTR CALLBACK DlgAddGameProc (HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam
+);
+
+INT_PTR CALLBACK DlgAddGameProcMain (HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam
+);
+
+//struct für den cache
+struct lbInicache {
+ char name[255];
+ unsigned int gameid;
+};
+
+void AddGameDialog(HWND hwndDlg,Xfire_game* game=NULL);
+
+#endif \ No newline at end of file
diff --git a/protocols/Xfire/src/all_statusmsg.cpp b/protocols/Xfire/src/all_statusmsg.cpp
new file mode 100644
index 0000000000..52e06e79ba
--- /dev/null
+++ b/protocols/Xfire/src/all_statusmsg.cpp
@@ -0,0 +1,398 @@
+//beinhaltet funktionen zum setzen des status wenn man ingame ist
+
+#include "stdafx.h"
+#include "baseProtocol.h"
+#include "m_variables.h"
+#include "Xfire_gamelist.h"
+
+extern Xfire_gamelist xgamelist;
+
+
+#include <vector>
+
+using namespace std;
+
+#include "xdebug.h"
+
+//vector beinhaltet statusmessages
+vector<string> *olstatusmsg=NULL;
+vector<string> *protoname=NULL;
+vector<unsigned int> *olstatus=NULL;
+vector<unsigned int> *oltostatus=NULL;
+PROTOCOLDESCRIPTOR **temp;
+int anz,statusid;
+int statustype;
+
+BOOL BackupStatusMsg() {
+ DBVARIANT dbv;
+
+ statustype=DBGetContactSettingByte(NULL,protocolname,"statuschgtype",0);
+
+ XFireLog("Backup Status Message ...");
+
+ //alten vector löschen
+ if(olstatusmsg!=NULL)
+ {
+ delete olstatusmsg;
+ olstatusmsg=NULL;
+ }
+ if(protoname!=NULL)
+ {
+ delete protoname;
+ protoname=NULL;
+ }
+ if(olstatus!=NULL)
+ {
+ delete olstatus;
+ olstatus=NULL;
+ }
+ if(oltostatus!=NULL)
+ {
+ delete oltostatus;
+ oltostatus=NULL;
+ }
+ olstatusmsg=new vector<string>;
+ protoname=new vector<string>;
+ olstatus=new vector<unsigned int>;
+ oltostatus=new vector<unsigned int>;
+
+ //alle protokolle durchgehen und den status in den vector sichern
+ // TODO: was enumprotocols, is enumprotos okay?
+ CallService(MS_PROTO_ENUMPROTOS,(WPARAM)&anz,(LPARAM)&temp);
+ for(int i=0;i<anz;i++)
+ {
+ statusid=CallProtoService(temp[i]->szName,PS_GETSTATUS,0,0);
+ XFireLog("Get Status of %s ...",temp[i]->szName);
+
+ char ttemp[128]="";
+ sprintf_s(ttemp,128,"%s%s",temp[i]->szName,PS_SETAWAYMSG);
+
+ //xfire wird geskipped, offline prots und invs prots auch, und locked status prots auch
+ if(statusid==ID_STATUS_INVISIBLE||statusid==ID_STATUS_OFFLINE||!lstrcmpiA( temp[i]->szName, protocolname )||!ServiceExists(ttemp)||DBGetContactSettingByte(NULL,temp[i]->szName,"LockMainStatus",0)==1)
+ {
+ XFireLog("-> Skip %s.",temp[i]->szName);
+
+ olstatus->push_back(-1);
+ olstatusmsg->push_back("");
+ if(statustype) oltostatus->push_back(-1);
+ protoname->push_back("");
+ continue;
+ }
+
+ int dummystatusid=statusid;
+
+ if(statustype)
+ {
+ if(statusid!=0)
+ {
+ int caps=CallProtoService(temp[i]->szName,PS_GETCAPS,PFLAGNUM_2,0);
+
+ //normale statusreihenfolge
+ if(DBGetContactSettingByte(NULL,protocolname,"dndfirst",0)==0)
+ {
+ if(caps&PF2_LIGHTDND)
+ {
+ oltostatus->push_back(ID_STATUS_OCCUPIED);
+ dummystatusid=ID_STATUS_OCCUPIED;
+ XFireLog("%s supports OCCUPIED.",temp[i]->szName);
+ }
+ else if(caps&PF2_HEAVYDND)
+ {
+ oltostatus->push_back(ID_STATUS_DND);
+ dummystatusid=ID_STATUS_DND;
+ XFireLog("%s supports DND.",temp[i]->szName);
+ }
+ else if(caps&PF2_SHORTAWAY)
+ {
+ oltostatus->push_back(ID_STATUS_AWAY);
+ dummystatusid=ID_STATUS_AWAY;
+ XFireLog("%s supports AWAY.",temp[i]->szName);
+ }
+ else
+ {
+ XFireLog("%s no Away???.",temp[i]->szName);
+ oltostatus->push_back(statusid);
+ dummystatusid=statusid;
+ }
+ }
+ else //dnd bevorzugt
+ {
+ if(caps&PF2_HEAVYDND)
+ {
+ oltostatus->push_back(ID_STATUS_DND);
+ dummystatusid=ID_STATUS_DND;
+ XFireLog("%s supports DND.",temp[i]->szName);
+ }
+ else if(caps&PF2_LIGHTDND)
+ {
+ oltostatus->push_back(ID_STATUS_OCCUPIED);
+ dummystatusid=ID_STATUS_OCCUPIED;
+ XFireLog("%s supports OCCUPIED.",temp[i]->szName);
+ }
+ else if(caps&PF2_SHORTAWAY)
+ {
+ oltostatus->push_back(ID_STATUS_AWAY);
+ dummystatusid=ID_STATUS_AWAY;
+ XFireLog("%s supports AWAY.",temp[i]->szName);
+ }
+ else
+ {
+ XFireLog("%s no Away???.",temp[i]->szName);
+ oltostatus->push_back(statusid);
+ dummystatusid=statusid;
+ }
+ }
+ }
+ else
+ oltostatus->push_back(-1);
+ }
+
+ switch(statusid)
+ {
+ case ID_STATUS_ONLINE:
+ if(DBGetContactSetting(NULL,"SRAway","OnMsg",&dbv))
+ olstatusmsg->push_back(Translate("Yep, I'm here."));
+ break;
+ case ID_STATUS_AWAY:
+ if(DBGetContactSetting(NULL,"SRAway","AwayMsg",&dbv))
+ olstatusmsg->push_back(Translate("I've been away since %time%."));
+ break;
+ case ID_STATUS_NA:
+ if(DBGetContactSetting(NULL,"SRAway","NaMsg",&dbv))
+ olstatusmsg->push_back(Translate("Give it up, I'm not in!"));
+ break;
+ case ID_STATUS_OCCUPIED:
+ if(DBGetContactSetting(NULL,"SRAway","OccupiedMsg",&dbv))
+ olstatusmsg->push_back(Translate("Not right now."));
+ break;
+ case ID_STATUS_DND:
+ if(DBGetContactSetting(NULL,"SRAway","DndMsg",&dbv))
+ olstatusmsg->push_back(Translate("Give a guy some peace, would ya?"));
+ break;
+ case ID_STATUS_FREECHAT:
+ if(DBGetContactSetting(NULL,"SRAway","FreeChatMsg",&dbv))
+ olstatusmsg->push_back(Translate("Well, I would talk to you if Miranda ICQ supported chat"));
+ break;
+ case ID_STATUS_ONTHEPHONE:
+ if(DBGetContactSetting(NULL,"SRAway","OtpMsg",&dbv))
+ olstatusmsg->push_back(Translate("That'll be the phone."));
+ break;
+ case ID_STATUS_OUTTOLUNCH:
+ if(DBGetContactSetting(NULL,"SRAway","OtlMsg",&dbv))
+ olstatusmsg->push_back(Translate("Mmm...food."));
+ break;
+ default:
+ //nix zumachn, kenn den status nicht
+ olstatus->push_back(-1);
+ olstatusmsg->push_back("");
+ protoname->push_back("");
+ continue;
+ }
+
+ //ab in den vector
+ olstatus->push_back(statusid);
+ if(olstatus->size()>olstatusmsg->size())
+ {
+ olstatusmsg->push_back(string(dbv.pszVal));
+ protoname->push_back(temp[i]->szName);
+ //freigeben
+ DBFreeVariant(&dbv);
+ }
+ else
+ protoname->push_back(temp[i]->szName);
+ }
+
+ return TRUE;
+}
+
+BOOL SetGameStatusMsg()
+{
+ char* statusmsg=NULL;
+
+ //prüfe ob vector leer
+ if(olstatusmsg==NULL)
+ return FALSE;
+
+ //zusetzende statusmsg erstellen
+ if (ServiceExists(MS_VARS_FORMATSTRING))
+ {
+ DBVARIANT dbv;
+ if(!DBGetContactSetting(NULL,protocolname,"setstatusmsg",&dbv)) {
+ //direkte funktionen verwenden
+ statusmsg = variables_parse(dbv.pszVal,NULL,0);
+ if (statusmsg == NULL)
+ {
+ DBFreeVariant(&dbv);
+ return FALSE;
+ }
+
+ DBFreeVariant(&dbv);
+ }
+ }
+ else
+ {
+ //alternativ zweig ohne variables
+ DBVARIANT dbv;
+ if(!DBGetContactSetting(NULL,protocolname,"setstatusmsg",&dbv)) {
+
+ DBVARIANT dbv3;
+
+ //statusmsg rein
+ xgamelist.setString(dbv.pszVal,&statusmsg);
+
+ //mit den vars ersetzen beginnen
+
+ //derzeitiges spiel
+ if(!DBGetContactSetting(NULL,protocolname, "currentgamename",&dbv3))
+ {
+ xgamelist.strreplace("%myxfiregame%",dbv3.pszVal,&statusmsg);
+ DBFreeVariant(&dbv3);
+ }
+ else
+ xgamelist.strreplace("%myxfiregame%","",&statusmsg);
+
+ //derzeitiges voiceprogram
+ if(!DBGetContactSetting(NULL,protocolname, "currentvoicename",&dbv3))
+ {
+ xgamelist.strreplace("%myxfirevoice%",dbv3.pszVal,&statusmsg);
+ DBFreeVariant(&dbv3);
+ }
+ else
+ xgamelist.strreplace("%myxfirevoice%","",&statusmsg);
+
+ //derzeitige voiceip
+ if(!DBGetContactSetting(NULL,protocolname, "VServerIP",&dbv3))
+ {
+ xgamelist.strreplace("%myxfirevoiceip%",dbv3.pszVal,&statusmsg);
+ DBFreeVariant(&dbv3);
+ }
+ else
+ xgamelist.strreplace("%myxfirevoiceip%","",&statusmsg);
+
+ //derzeitige gameip
+ if(!DBGetContactSetting(NULL,protocolname, "ServerIP",&dbv3))
+ {
+ xgamelist.strreplace("%myxfireserverip%",dbv3.pszVal,&statusmsg);
+ DBFreeVariant(&dbv3);
+ }
+ else
+ xgamelist.strreplace("%myxfireserverip%","",&statusmsg);
+
+ }
+ }
+
+ // TODO: MS_PROTO_ENUMPROTOCOLS was original... is enumprotos okay?
+ CallService(MS_PROTO_ENUMPROTOS,(WPARAM)&anz,(LPARAM)&temp);
+ for(int i=0;i<anz;i++)
+ {
+ if(olstatus->at(i)!=-1)
+ {
+ if(statustype)
+ {
+ //newawaysys
+ if(ServiceExists("NewAwaySystem/SetStateA"))
+ {
+ XFireLog("-> SetStatusMsg of %s with NewAwaySystem/SetStateA.",protoname->at(i).c_str());
+
+ NAS_PROTOINFO npi = {0};
+ npi.cbSize=sizeof(NAS_PROTOINFO);
+ npi.szProto=(char*)protoname->at(i).c_str();
+ npi.status=oltostatus->at(i);
+ npi.szMsg=mir_strdup(statusmsg);
+ CallService("NewAwaySystem/SetStateA", (WPARAM)&npi, (LPARAM)1);
+ }
+ else if(ServiceExists("NewAwaySystem/SetStateW")) {
+ XFireLog("-> SetStatusMsg of %s with NewAwaySystem/SetStateW.",protoname->at(i).c_str());
+
+ NAS_PROTOINFO npi = {0};
+ npi.cbSize=sizeof(NAS_PROTOINFO);
+ npi.szProto=(char*)protoname->at(i).c_str();
+ npi.status=oltostatus->at(i);
+ npi.szMsg=mir_strdup(statusmsg);
+ CallService("NewAwaySystem/SetStateW", (WPARAM)&npi, (LPARAM)1);
+ }
+ else
+ {
+ XFireLog("-> SetStatusMsg of %s with Miranda with occupied status.",protoname->at(i).c_str());
+
+ //statusmsg für beschäftigt setzen
+ CallProtoService(temp[i]->szName,PS_SETAWAYMSG,oltostatus->at(i),(LPARAM)statusmsg);
+ //status auf beschäftigt wechseln
+ CallProtoService(temp[i]->szName,PS_SETSTATUS,oltostatus->at(i),0);
+ //statusmsg für beschäftigt setzen
+ if(CallProtoService(temp[i]->szName,PS_GETSTATUS,0,0)!=oltostatus->at(i))
+ {
+ XFireLog("Set StatusMsg again, Status was not succesfully set.");
+ CallProtoService(temp[i]->szName,PS_SETAWAYMSG,oltostatus->at(i),(LPARAM)statusmsg);
+ }
+ }
+ }
+ else
+ {
+ XFireLog("-> SetStatusMsg of %s.",protoname->at(i).c_str());
+
+ CallProtoService(temp[i]->szName,PS_SETAWAYMSG,olstatus->at(i),(LPARAM)statusmsg);
+ }
+ }
+ }
+
+ if (ServiceExists(MS_VARS_FORMATSTRING))
+ CallService(MS_VARS_FREEMEMORY, (WPARAM)statusmsg, 0);
+ else
+ if(statusmsg) delete[] statusmsg;
+
+ return TRUE;
+}
+
+BOOL SetOldStatusMsg()
+{
+ //prüfe ob vector leer
+ if(olstatusmsg==NULL)
+ return FALSE;
+
+ // TODO: was enumprotocols, is enumprotos okay?
+ CallService(MS_PROTO_ENUMPROTOS,(WPARAM)&anz,(LPARAM)&temp);
+ for(int i=0;i<anz;i++)
+ {
+ if(olstatus->at(i)!=-1)
+ {
+ if(statustype)
+ {
+ //alten status setzen
+ CallProtoService(temp[i]->szName,PS_SETSTATUS,olstatus->at(i),0);
+ //status wurde nicht gewechselt, dann statusmsg nachträglich setzen
+ if(CallProtoService(temp[i]->szName,PS_GETSTATUS,0,0)!=olstatus->at(i))
+ CallProtoService(temp[i]->szName,PS_SETAWAYMSG,olstatus->at(i),(LPARAM)olstatusmsg->at(i).c_str());
+ }
+ else
+ {
+ CallProtoService(temp[i]->szName,PS_SETSTATUS,olstatus->at(i),0);
+ CallProtoService(temp[i]->szName,PS_SETAWAYMSG,olstatus->at(i),(LPARAM)olstatusmsg->at(i).c_str());
+ }
+ }
+ }
+
+ //alten vector löschen
+ if(protoname!=NULL)
+ {
+ delete protoname;
+ protoname=NULL;
+ }
+ if(olstatusmsg!=NULL)
+ {
+ delete olstatusmsg;
+ olstatusmsg=NULL;
+ }
+ if(olstatus!=NULL)
+ {
+ delete olstatus;
+ olstatus=NULL;
+ }
+ if(oltostatus!=NULL)
+ {
+ delete olstatus;
+ olstatus=NULL;
+ }
+
+ return TRUE;
+} \ No newline at end of file
diff --git a/protocols/Xfire/src/all_statusmsg.h b/protocols/Xfire/src/all_statusmsg.h
new file mode 100644
index 0000000000..a3a95a56b7
--- /dev/null
+++ b/protocols/Xfire/src/all_statusmsg.h
@@ -0,0 +1,7 @@
+//definitionen für die statusmsg handling geschichte
+#include "baseProtocol.h"
+
+//sichert die statusmeldungen in den speicher
+BOOL BackupStatusMsg();
+BOOL SetGameStatusMsg();
+BOOL SetOldStatusMsg(); \ No newline at end of file
diff --git a/protocols/Xfire/src/authpacket.cpp b/protocols/Xfire/src/authpacket.cpp
new file mode 100644
index 0000000000..9183fd1e48
--- /dev/null
+++ b/protocols/Xfire/src/authpacket.cpp
@@ -0,0 +1,47 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "authpacket.h"
+#include "xfireparse.h"
+#include "variablevalue.h"
+
+namespace xfirelib {
+ using namespace std;
+
+ AuthPacket::AuthPacket() : XFireRecvPacketContent() {
+ salt = 0;
+ }
+ AuthPacket::~AuthPacket() {
+ delete salt;
+ }
+
+ void AuthPacket::parseContent(char *buf, int length, int numberOfAtts) {
+
+ //XFireParse parse;
+ salt = new VariableValue();
+ //parse.readVariableValue(buf, 0, length, salt);
+ salt->readVariableValue(buf, 0, length);
+ }
+
+};
diff --git a/protocols/Xfire/src/authpacket.h b/protocols/Xfire/src/authpacket.h
new file mode 100644
index 0000000000..5a9f5bb057
--- /dev/null
+++ b/protocols/Xfire/src/authpacket.h
@@ -0,0 +1,54 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __AUTHPACKET_H
+#define __AUTHPACKET_H
+
+#include "xfirerecvpacketcontent.h"
+#include "variablevalue.h"
+
+#define XFIRE_PACKET_AUTH_ID 128
+
+namespace xfirelib {
+
+ class AuthPacket : public XFireRecvPacketContent {
+ public:
+ AuthPacket();
+ virtual ~AuthPacket();
+
+ XFirePacketContent* newPacket() { return new AuthPacket(); }
+
+
+ int getPacketId() { return XFIRE_PACKET_AUTH_ID; }
+ int getPacketContent(char *buf) { return 0; }
+ int getPacketAttributeCount() { return 0; };
+ int getPacketSize() { return 1024; };
+ void parseContent(char *buf, int length, int numberOfAtts);
+
+ VariableValue *getSalt() { return salt; }
+ private:
+ VariableValue *salt;
+ };
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/baseProtocol.h b/protocols/Xfire/src/baseProtocol.h
new file mode 100644
index 0000000000..1e63fb59c2
--- /dev/null
+++ b/protocols/Xfire/src/baseProtocol.h
@@ -0,0 +1,272 @@
+/*
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ *
+ * Copyright (C) 2010 by
+ * dufte <dufte@justmail.de>
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Based on J. Lawler - BaseProtocol
+ * Herbert Poul/Beat Wolf - xfirelib
+ *
+ * Miranda ICQ: the free icq client for MS Windows
+ * Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
+ *
+ */
+
+#define MIRANDA_VER 0x0A00
+
+//=====================================================
+// Includes (yea why not include lots of stuff :D )
+//=====================================================
+#include <windows.h>
+#include <gdiplus.h>
+#include <Wininet.h>
+#include <commctrl.h>
+#include <stdio.h>
+#include <time.h>
+#include <stddef.h>
+#include <process.h>
+#include <string.h>
+#include <winsock.h>
+#include "resource.h"
+#include <winbase.h>
+#include <tlhelp32.h>
+#include <Psapi.h>
+#include <string.h>
+#include <Iphlpapi.h>
+
+//Miranda SDK headers
+#include <newpluginapi.h>
+#include <m_clist.h>
+#include <m_clui.h>
+#include <m_skin.h>
+#include <m_langpack.h>
+#include <m_protomod.h>
+#include <m_database.h>
+#include <m_system.h>
+#include <m_protocols.h>
+#include <m_protomod.h>
+#include <m_protosvc.h>
+#include <m_protoint.h>
+#include <m_userinfo.h>
+#include <m_options.h>
+#include <m_utils.h>
+#include <m_ignore.h>
+#include <m_clc.h>
+#include <m_netlib.h>
+#include <m_avatars.h>
+#include <m_folders.h>
+#include <m_assocmgr.h>
+#include <m_icolib.h>
+#include <m_genmenu.h>
+#include <m_cluiframes.h>
+#include <m_account.h>
+#include <m_protoplugin.h>
+
+#include "services.h"
+
+/*#pragma comment(lib, "atl.lib")
+#include <atldef.h>
+#define _ATL_DLL_IMPL
+#include <atliface.h>*/
+
+#ifndef _BASEPROTO_H
+#define _BASEPROTO_H
+
+//=======================================================
+// Definitions
+//=======================================================
+#define protocolname "XFire" //no spaces here :)
+
+/* */
+typedef DWORD (*pGetExtendedTcpTable)(
+ __out_bcount_opt(*pdwSize) PVOID pTcpTable,
+ __inout PDWORD pdwSize,
+ __in BOOL bOrder,
+ __in ULONG ulAf,
+ __in TCP_TABLE_CLASS TableClass,
+ __in ULONG Reserved
+ );
+
+typedef DWORD (*pGetExtendedUdpTable)(
+ __out_bcount_opt(*pdwSize) PVOID pUdpTable,
+ __inout PDWORD pdwSize,
+ __in BOOL bOrder,
+ __in ULONG ulAf,
+ __in UDP_TABLE_CLASS TableClass,
+ __in ULONG Reserved
+ );
+
+//=======================================================
+// Defines
+//=======================================================
+//General
+extern HINSTANCE hinstance;
+extern int bpStatus;
+
+//Services.c
+int GetCaps(WPARAM wParam,LPARAM lParam);
+int GetName(WPARAM wParam,LPARAM lParam);
+int TMLoadIcon(WPARAM wParam,LPARAM lParam);
+int SetStatus(WPARAM wParam,LPARAM lParam);
+int GetStatus(WPARAM wParam,LPARAM lParam);
+BOOL IsXFireContact(HANDLE h);
+int displayPopup(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,HICON hhicon=NULL);
+BOOL CreateToolTip(int toolID, HWND hDlg, CHAR* pText);
+void EnableDlgItem(HWND hwndDlg, UINT control, int state);
+BOOL str_replace(char*src,char*find,char*rep);
+extern void Message(LPVOID msg);
+extern void MessageE(LPVOID msg);
+char* GetLaunchPath(char*launch);
+unsigned short r(unsigned short data);
+BOOL GetServerIPPort(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1,char*ip2,char*ip3,char*ip4,long*port);
+BOOL GetServerIPPort2(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1,char*ip2,char*ip3,char*ip4,long*port);
+int SetNickName(WPARAM newnick, LPARAM lparam);
+BOOL FindTeamSpeak(DWORD*pid,int*vid);
+char*menuitemtext(char*mtext);
+BOOL checkCommandLine(HANDLE hProcess,char * mustcontain,char * mustnotcontain);
+char * getItem(char * string,char delim,int count);
+BOOL GetWWWContent(char*host,char* request,char*filename,BOOL dontoverwrite);
+BOOL GetWWWContent2(char*address,char*filename,BOOL dontoverwrite,char**tobuf=NULL,unsigned int* size=NULL);
+BOOL CheckWWWContent(char*address);
+unsigned int getfilesize(char*path);
+void UpdateMyXFireIni(LPVOID dummy);
+void UpdateMyIcons(LPVOID dummy);
+BOOL IsContactMySelf(std::string buddyusername);
+DWORD xfire_GetPrivateProfileString(__in LPCTSTR lpAppName, __in LPCTSTR lpKeyName, __in LPCTSTR lpDefault, __out LPTSTR lpReturnedString, __in DWORD nSize, __in LPCTSTR lpFileName);
+BOOL mySleep(int ms,HANDLE evt);
+void __stdcall XFireLog( const char* fmt, ... );
+
+#define ID_STATUS_RECONNECT ID_STATUS_OFFLINE-1
+
+struct CONTACT // Contains info about users
+{
+ TCHAR* name;
+ TCHAR* user;
+ TCHAR* host;
+ bool ExactOnly;
+ bool ExactWCOnly;
+ bool ExactNick;
+};
+
+
+#define MSGBOX(msg) mir_forkthread(Message,(LPVOID)msg)
+#define MSGBOXE(msg) mir_forkthread(MessageE,(LPVOID)msg)
+
+#pragma comment(lib,"Advapi32.lib")
+#pragma comment(lib,"Psapi.lib")
+#pragma comment(lib,"gdiplus.lib")
+#pragma comment(lib,"comdlg32.lib")
+#pragma comment(lib,"comctl32.lib")
+#pragma comment(lib,"shell32.lib")
+
+//=====================================================
+// Definitions
+//=====================================================
+
+struct GameIco {
+ int gameid;
+ HANDLE handle;
+ HICON hicon;
+};
+
+struct XFireContact {
+ char * username;
+ char * nick;
+ int id;
+ int sid;
+};
+
+struct XFireAvatar {
+ int type;
+ char backup[256];
+ char file[256];
+ char rfile[256];
+};
+
+struct XFire_FoundGame
+{
+ int gameid;
+ int gameid2;
+ short send_gameid;
+ char path[256];
+ char mpath[9][256];
+ int morepaths;
+ char launchparams[1024];
+ char networkparams[1024];
+ char userparams[1024];
+ char pwparams[1024];
+ char mustcontain[1024];
+ char notcontain[1024];
+ char temp[128];
+ BOOL setstatusmsg;
+ BOOL custom;
+ BOOL skip;
+ BOOL noicqstatus;
+ HANDLE menuitem;
+};
+
+struct XFire_SetAvatar
+{
+ HANDLE hContact;
+ char* username;
+};
+
+struct gServerstats {
+ int players;
+ int maxplayers;
+ char name[512];
+ char map[512];
+ char gametype[512];
+ char fgametype[512];
+ BOOL password;
+};
+
+struct GameServerQuery_query {
+ int xfiregameid;
+ char ip[16];
+ WORD port;
+ HANDLE handle; //will be overwritten
+ int queryengine; // immer 0
+};
+
+#define XFIRE_MAX_STATIC_STRING_LEN 1024
+#define XFIRE_SCAN_VAL 0x3
+
+#define XFIRE_GAME_ICON 0
+#define XFIRE_VOICE_ICON 1
+
+
+typedef struct {
+ int cbSize;
+ char *szProto; // pointer to protocol modulename (NULL means global)
+ union
+ {
+ char *szMsg;
+ WCHAR *wszMsg;
+ TCHAR *tszMsg;
+ }; // pointer to the status message _format_ (i.e. it's an unparsed message containing variables, in any case. NAS takes care of parsing) (may be NULL - means that there's no specific message for this protocol - then the global status message will be used)
+/*
+ Be aware that MS_NAS_GETSTATE allocates memory for szMsg through Miranda's
+ memory management interface (MS_SYSTEM_GET_MMI). And MS_NAS_SETSTATE
+ expects szMsg to be allocated through the same service. MS_NAS_SETSTATE deallocates szMsg.
+*/
+ WORD status; // status mode. 0 means current (NAS will overwrite 0 with the current status mode)
+// for MS_NAS_GETSTATE if the specified status is not 0, MS_NAS_GETSTATE will return the default/last status message (depends on settings) - i.e. the same message that will be shown by default when user changes status to the specified one. please note that, for example, if current status mode is ID_STATUS_AWAY, then status messages returned by MS_NAS_GETSTATE for status=0 and status=ID_STATUS_AWAY may be different! for status=ID_STATUS_AWAY it always returns the default/last status message, and for status=0 it returns _current_ status message.
+ int Flags;
+} NAS_PROTOINFO;
+
+#endif \ No newline at end of file
diff --git a/protocols/Xfire/src/buddyinfo.cpp b/protocols/Xfire/src/buddyinfo.cpp
new file mode 100644
index 0000000000..bcd9d47c81
--- /dev/null
+++ b/protocols/Xfire/src/buddyinfo.cpp
@@ -0,0 +1,64 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+#include <vector>
+#include <string>
+
+#include "buddyinfo.h"
+#include "xfireparse.h"
+#include "variablevalue.h"
+#include "xdebug.h"
+
+namespace xfirelib {
+ using namespace std;
+
+ void BuddyInfoPacket::parseContent(char *buf, int length, int numberOfAtts) {
+ int index = 0;
+
+ VariableValue val;
+
+ XDEBUG2( "Len: %ld\n", length );
+
+ index+=2; //paar bytes überspringen
+
+ index += val.readValue(buf,index,4);
+ this->userid = val.getValueAsLong();
+
+ XDEBUG2( "UserId: %ld\n", this->userid);
+
+ index+=2;
+
+ this->avatarmode = buf[index];
+ XDEBUG2( "Avatarmode: %ld\n", this->avatarmode);
+ index+=6;
+
+
+ index += val.readValue(buf,index,4);
+ this->avatarid = val.getValueAsLong();
+ XDEBUG2( "Avatarid: %ld\n", this->avatarid);
+
+ }
+
+}; \ No newline at end of file
diff --git a/protocols/Xfire/src/buddyinfo.h b/protocols/Xfire/src/buddyinfo.h
new file mode 100644
index 0000000000..54f918dffd
--- /dev/null
+++ b/protocols/Xfire/src/buddyinfo.h
@@ -0,0 +1,52 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ * dufte <dufte@justmail.de>
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+//packet wird empfangen, nachdem man buddyinfos angefordert hat
+
+#ifndef __BUDDYINFO_H
+#define __BUDDYINFO_H
+
+#include "xfirerecvpacketcontent.h"
+#include <string>
+
+#define XFIRE_BUDDYINFO 0xAE
+
+namespace xfirelib {
+ class BuddyInfoPacket : public XFireRecvPacketContent {
+ public:
+ virtual ~BuddyInfoPacket() { }
+ int getPacketId() { return XFIRE_BUDDYINFO; }
+
+ XFirePacketContent *newPacket() { return new BuddyInfoPacket(); }
+ void parseContent(char *buf, int length, int numberOfAtts);
+
+ unsigned char avatarmode;
+ unsigned int avatarid;
+ unsigned int userid;
+
+ };
+
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/buddylist.cpp b/protocols/Xfire/src/buddylist.cpp
new file mode 100644
index 0000000000..ea7e264502
--- /dev/null
+++ b/protocols/Xfire/src/buddylist.cpp
@@ -0,0 +1,373 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include <iostream>
+#include <vector>
+#include "buddylist.h"
+#include "buddylistonlinepacket.h"
+#include "buddylistgamespacket.h"
+#include "buddylistgames2packet.h"
+#include "recvremovebuddypacket.h"
+#include "recvstatusmessagepacket.h"
+#include "recvbuddychangednick.h"
+#include "xdebug.h"
+
+//buddylist verarbeitung von der main in buddylist verschoben, um doppelte schleifenverarbeitung zuunterbinden
+#include "baseProtocol.h"
+
+extern HANDLE handlingBuddys(xfirelib::BuddyListEntry *entry, int clan=0,char* group=NULL,BOOL dontscan=FALSE);
+extern void setBuddyStatusMsg(xfirelib::BuddyListEntry *entry,std::string statusmsg);
+
+namespace xfirelib {
+
+ using namespace std;
+
+ BuddyList::BuddyList(Client *client) {
+ entries = new vector<BuddyListEntry *>;
+
+ //clan entries initialisieren - dufte
+ entriesClan = new vector<BuddyListEntry *>;
+
+ this->client = client;
+ this->client->addPacketListener( this );
+ }
+ BuddyList::~BuddyList() {
+ for(vector<BuddyListEntry *>::iterator it = entries->begin();
+ it != entries->end(); it++) {
+ delete *it;
+ }
+ delete entries;
+
+ //clan entries entfernen - dufte
+ for(vector<BuddyListEntry *>::iterator it = entriesClan->begin();
+ it != entriesClan->end(); it++) {
+ delete *it;
+ }
+ delete entriesClan;
+ }
+
+ BuddyListEntry *BuddyList::getBuddyById(long userid) {
+ for(uint i = 0 ; i < entries->size() ; i++) {
+ BuddyListEntry *entry = entries->at(i);
+ if(entry->userid == userid)
+ return entry;
+ }
+
+ //clan entries durchsuchen - dufte
+ for(uint i = 0 ; i < entriesClan->size() ; i++) {
+ BuddyListEntry *entry = entriesClan->at(i);
+ if(entry->userid == userid)
+ return entry;
+ }
+
+ return 0;
+ }
+
+ BuddyListEntry *BuddyList::getBuddyByName(string username) {
+ for(uint i = 0 ; i < entries->size() ; i++) {
+ BuddyListEntry *entry = entries->at(i);
+ if(entry->username == username)
+ return entry;
+ }
+
+ //clan entries durchsuchen - dufte
+ for(uint i = 0 ; i < entriesClan->size() ; i++) {
+ BuddyListEntry *entry = entriesClan->at(i);
+ if(entry->username == username)
+ return entry;
+ }
+
+ return 0;
+ }
+
+ BuddyListEntry *BuddyList::getBuddyBySid(const char *sid) {
+ for(uint i = 0 ; i < entries->size() ; i++) {
+ BuddyListEntry *entry = entries->at(i);
+
+ if(memcmp((void *)sid,(void *)entry->sid,16) == 0)
+ return entry;
+
+ }
+
+ //clan entries durchsuchen - dufte
+ for(uint i = 0 ; i < entriesClan->size() ; i++) {
+ BuddyListEntry *entry = entriesClan->at(i);
+
+ if(memcmp((void *)sid,(void *)entry->sid,16) == 0)
+ return entry;
+
+ }
+
+ return 0;
+ }
+
+
+ void BuddyList::initEntries(BuddyListNamesPacket *buddyNames) {
+ for(uint i = 0 ; i < buddyNames->usernames->size() ; i++) {
+ BuddyListEntry *entry = new BuddyListEntry;
+ entry->username = buddyNames->usernames->at(i);
+ entry->userid = buddyNames->userids->at(i);
+ entry->nick = buddyNames->nicks->at(i);
+ //buddies in miranda verarbeiten
+ handlingBuddys(entry,0,NULL);
+ entries->push_back(entry);
+ }
+ }
+
+ // funktion zum initialisieren der clanliste - dufte
+ void BuddyList::initEntriesClan(ClanBuddyListNamesPacket *buddyNames) {
+ for(uint i = 0 ; i < buddyNames->usernames->size() ; i++) {
+ BuddyListEntry *entry = new BuddyListEntry;
+ entry->username = buddyNames->usernames->at(i);
+ entry->userid = buddyNames->userids->at(i);
+ entry->nick = buddyNames->nicks->at(i);
+ entry->clanid = buddyNames->clanid;
+ /* ## buddies im miranda verarbietn */
+ char temp[255];
+ char * dummy;
+ sprintf_s(temp,255,"Clan_%d",entry->clanid);
+
+ DBVARIANT dbv;
+ if(!DBGetContactSetting(NULL,protocolname,temp,&dbv))
+ {
+ dummy=dbv.pszVal;
+ }
+ else
+ dummy=NULL;
+
+ handlingBuddys(entry,entry->clanid,dummy);
+ /* ## ende */
+ entriesClan->push_back(entry);
+ }
+ }
+
+ void BuddyList::updateFriendsofFriend(FriendsBuddyListNamesPacket* friends)
+ {
+ for(uint i = 0 ; i < friends->sids->size() ; i++) {
+ BuddyListEntry *entry = getBuddyBySid( friends->sids->at(i) );
+ if(entry){
+ XDEBUG2("Friends of Friend %s!\n",friends->usernames->at(i).c_str());
+ entry->nick=friends->nicks->at(i);
+ entry->username=friends->usernames->at(i);
+ entry->userid=friends->userids->at(i);
+ }else{
+ XERROR(("updateFriendsofFriendBuddies: sid not found!\n"));
+ }
+ }
+ }
+
+ void BuddyList::updateOnlineBuddies(BuddyListOnlinePacket* buddiesOnline) {
+ for(uint i = 0 ; i < buddiesOnline->userids->size() ; i++) {
+ BuddyListEntry *entry = getBuddyById( buddiesOnline->userids->at(i) );
+ if(entry){
+ entry->setSid( buddiesOnline->sids->at(i) );
+ //buddies in miranda verarbeiten
+ handlingBuddys(entry,0,NULL);
+ }else{
+ XERROR(("updateOnlineBuddies: Could not find buddy with this sid!\n"));
+ }
+ }
+ }
+
+ void BuddyList::updateBuddiesGame(BuddyListGamesPacket* buddiesGames) {
+ bool isFirst = buddiesGames->getPacketId() == XFIRE_BUDDYS_GAMES_ID;
+ for(uint i = 0 ; i < buddiesGames->sids->size() ; i++) {
+ BuddyListEntry *entry = getBuddyBySid( buddiesGames->sids->at(i) );
+ if(!entry) {
+ //nicht zuordbare sids zuordnen
+ XERROR("Add dummy Contact in buddylist for friends of friends!\n");
+ BuddyListEntry *newentry = new BuddyListEntry;
+ newentry->username = "";
+ newentry->userid = 0;
+ newentry->nick = "";
+ newentry->setSid(buddiesGames->sids->at(i));
+ entries->push_back(newentry);
+ //nochmal entry suchen
+ entry = newentry; //getBuddyBySid( buddiesGames->sids->at(i) );
+ }
+ if(entry){
+ if(isFirst) {
+ entry->game = buddiesGames->gameids->at(i);
+ delete entry->gameObj; entry->gameObj = NULL;
+ } else {
+ entry->game2 = buddiesGames->gameids->at(i);
+ delete entry->game2Obj; entry->game2Obj = NULL;
+ }
+ XDEBUG(( "Resolving Game ... \n" ));
+ XFireGameResolver *resolver = client->getGameResolver();
+ if(resolver) {
+ XDEBUG(( "Resolving Game ... \n" ));
+ if(isFirst)
+ entry->gameObj = resolver->resolveGame( entry->game, i, buddiesGames );
+ else
+ entry->game2Obj = resolver->resolveGame( entry->game2, i, buddiesGames );
+ } else {
+ XDEBUG(( "No GameResolver ? :(\n" ));
+ }
+ XDEBUG(( "%s: Game (%ld): %s / Game2 (%ld): %s\n",
+ entry->username.c_str(),
+ entry->game,
+ (entry->gameObj == NULL ? "UNKNOWN" : entry->gameObj->getGameName().c_str()),
+ entry->game2,
+ (entry->game2Obj== NULL ? "UNKNOWN" :entry->game2Obj->getGameName().c_str())
+ ));
+ }else{
+ XERROR("updateBuddiesGame: Could not find buddy with this sid!\n");
+ }
+ }
+ }
+
+ void BuddyList::receivedPacket(XFirePacket *packet) {
+ XFirePacketContent *content = packet->getContent();
+ if(content == 0) return;
+ XDEBUG2( "hmm... %d\n", content->getPacketId() );
+ switch(content->getPacketId()) {
+ case XFIRE_BUDDYS_NAMES_ID: {
+ XINFO(( "Received Buddy List..\n" ));
+ this->initEntries( (BuddyListNamesPacket*)content );
+ break;
+ }
+ case XFIRE_CLAN_BUDDYS_NAMES_ID: {
+ XINFO(( "Received Clan Buddy List..\n" ));
+ this->initEntriesClan( (ClanBuddyListNamesPacket*)content );
+ break;
+ }
+ //neue nicks updaten, dufte
+ case XFIRE_RECVBUDDYCHANGEDNICK: {
+ RecvBuddyChangedNick* recvchangednick=(RecvBuddyChangedNick*)content;
+ XINFO(( "Received new nick of a buddy..\n" ));
+ BuddyListEntry* entry=NULL;
+ entry=this->getBuddyById(recvchangednick->userid);
+ if(entry) {
+ entry->nick=recvchangednick->newnick;
+ recvchangednick->entry=(void*)entry;
+ handlingBuddys(entry,0,NULL);
+ }
+ break;
+ }
+ case XFIRE_BUDDYS_ONLINE_ID: {
+ XINFO(( "Received Buddy Online Packet..\n" ));
+ this->updateOnlineBuddies( (BuddyListOnlinePacket *)content );
+ break;
+ }
+ case XFIRE_FRIENDS_BUDDYS_NAMES_ID: {
+ XINFO(( "Received Friends of Friend..\n" ));
+ this->updateFriendsofFriend( (FriendsBuddyListNamesPacket *)content );
+ break;
+ }
+ case XFIRE_BUDDYS_GAMES2_ID:
+ case XFIRE_BUDDYS_GAMES_ID: {
+ XINFO(( "Recieved the game a buddy is playing..\n" ));
+ this->updateBuddiesGame( (BuddyListGamesPacket *)content );
+ break;
+ }
+ case XFIRE_RECVREMOVEBUDDYPACKET: {
+ RecvRemoveBuddyPacket *p = (RecvRemoveBuddyPacket*)content;
+ XDEBUG2( "Buddy was removed from contact list (userid: %ld)\n", p->userid );
+ std::vector<BuddyListEntry *>::iterator i = entries->begin();
+ while( i != entries->end() ) {
+ if((*i)->userid == p->userid) {
+ BuddyListEntry *buddy = *i;
+ XINFO(( "%s (%s) was removed from BuddyList.\n", buddy->username.c_str(), buddy->nick.c_str() ));
+ p->username = buddy->username;
+ p->handle = buddy->hcontact; // handle übergeben - dufte
+ entries->erase(i);
+ // i.erase();
+ break; // we are done.
+ }
+ ++i;
+ }
+ break;
+ }
+ case XFIRE_RECV_STATUSMESSAGE_PACKET_ID: {
+ RecvStatusMessagePacket *status = (RecvStatusMessagePacket*) content;
+
+ //status->entries=new PBuddyListEntry[status->sids->size];
+
+ for(uint i = 0 ; i < status->sids->size() ; i++) {
+ BuddyListEntry *entry = getBuddyBySid( status->sids->at(i) );
+ //status->entries[i]=entry;
+
+ if(entry == NULL) {
+ XERROR(( "No such Entry - Got StatusMessage from someone who is not in the buddylist ??\n" ));
+ return;
+ }
+ else
+ {
+ entry->statusmsg = status->msgs->at(i).c_str();
+ setBuddyStatusMsg(entry,entry->statusmsg); //auf eine funktion reduziert, verringert cpuauslastung und beseitigt das
+ //das problem der fehlenden statusmsg
+ }
+ }
+
+ break;
+ }
+ }
+ }
+
+ BuddyListEntry::~BuddyListEntry() {
+ if(lastpopup) {
+ delete[] lastpopup;
+ lastpopup=NULL;
+ }
+ }
+
+ BuddyListEntry::BuddyListEntry() {
+ memset(sid,0,16);
+ statusmsg = std::string();
+ game = 0;
+ game2 = 0;
+ gameObj = NULL;
+ game2Obj = NULL;
+ hcontact = NULL;
+ clanid = 0;
+ lastpopup=NULL;
+ }
+ bool BuddyListEntry::isOnline() {
+ for(int i = 0 ; i < 16 ; i++) {
+ if(sid[i]) return true;
+ }
+ return false;
+ }
+ void BuddyListEntry::setSid(const char *sid) {
+ int s=0;
+ for(int i = 0 ; i < 16 ; i++) { //wenn buddy offline geht, seine gameinfos zurücksetzen - dufte
+ if(sid[i])
+ {
+ s=1;
+ break;
+ }
+ }
+ if(s)
+ {
+ this->statusmsg = std::string();
+ this->game = 0;
+ this->game2 = 0;
+ this->gameObj = NULL;
+ this->game2Obj = NULL;
+ }
+ memcpy(this->sid,sid,16);
+ }
+};
+
diff --git a/protocols/Xfire/src/buddylist.h b/protocols/Xfire/src/buddylist.h
new file mode 100644
index 0000000000..7ab1e26878
--- /dev/null
+++ b/protocols/Xfire/src/buddylist.h
@@ -0,0 +1,100 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __BUDDYLIST_H
+#define __BUDDYLIST_H
+
+#include <iostream>
+#include <vector>
+
+#include "buddylistnamespacket.h"
+#include "clanbuddylistnamespacket.h"
+#include "buddylistgamespacket.h"
+#include "buddylistonlinepacket.h"
+#include "packetlistener.h"
+#include "client.h"
+#include "xfiregame.h"
+#include "friendsoffriendlist.h"
+
+
+namespace xfirelib {
+ using namespace std;
+
+ struct Client;
+ struct BuddyListEntry;
+
+ class BuddyList : public PacketListener {
+ public:
+ BuddyList(Client *client);
+ ~BuddyList();
+
+ vector <BuddyListEntry *> * getEntries() { return entries; }
+ vector <BuddyListEntry *> * getEntriesClan() { return entriesClan; }
+
+ void receivedPacket(XFirePacket *packet);
+ BuddyListEntry *getBuddyById(long userid);
+ BuddyListEntry *getBuddyBySid(const char *sid);
+ BuddyListEntry *getBuddyByName(string username);
+ private:
+ void initEntries(BuddyListNamesPacket* buddynames);
+ void initEntriesClan(ClanBuddyListNamesPacket* buddynames);
+ void updateOnlineBuddies(BuddyListOnlinePacket* buddiesOnline);
+ void updateBuddiesGame(BuddyListGamesPacket* buddiesGames);
+ void updateFriendsofFriend(FriendsBuddyListNamesPacket* friends);
+
+ Client *client;
+ vector <BuddyListEntry *> * entries;
+ vector <BuddyListEntry *> * entriesClan;
+ };
+
+
+ class BuddyListEntry {
+ public:
+ BuddyListEntry();
+ ~BuddyListEntry();
+ bool isOnline();
+
+ void setSid(const char *sid);
+
+ long userid;
+ char sid[16];
+ string nick;
+ string username;
+ string statusmsg;
+ string gameinfo;
+ long game;
+ long game2;
+ HANDLE hcontact;
+ int clanid;
+
+ //lastpopup
+ char* lastpopup;
+
+ XFireGame *gameObj;
+ XFireGame *game2Obj;
+ };
+
+ typedef BuddyListEntry *PBuddyListEntry;
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/buddylistgames2packet.cpp b/protocols/Xfire/src/buddylistgames2packet.cpp
new file mode 100644
index 0000000000..2252339908
--- /dev/null
+++ b/protocols/Xfire/src/buddylistgames2packet.cpp
@@ -0,0 +1,39 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "buddylistgames2packet.h"
+#include "xdebug.h"
+
+namespace xfirelib {
+ BuddyListGames2Packet::BuddyListGames2Packet() : BuddyListGamesPacket() {
+
+ }
+ void BuddyListGames2Packet::parseContent(char *buf, int length, int numberOfAtts) {
+ XDEBUG( "....Parsing Packet Content of game 2 ??\n" )
+ this->BuddyListGamesPacket::parseContent(buf,length,numberOfAtts);
+ XDEBUG2( "Parsed Packet Content of game 2 ??? ( %ld )\n", gameids->at(0) )
+ }
+
+};
+
diff --git a/protocols/Xfire/src/buddylistgames2packet.h b/protocols/Xfire/src/buddylistgames2packet.h
new file mode 100644
index 0000000000..81fe92eecb
--- /dev/null
+++ b/protocols/Xfire/src/buddylistgames2packet.h
@@ -0,0 +1,46 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+
+#ifndef __BUDDYLISTGAMES2PACKET_H
+#define __BUDDYLISTGAMES2PACKET_H
+
+#define XFIRE_BUDDYS_GAMES2_ID 147
+
+#include "buddylistgamespacket.h"
+
+namespace xfirelib {
+
+ class BuddyListGames2Packet : public BuddyListGamesPacket {
+ public:
+ BuddyListGames2Packet();
+ XFirePacketContent* newPacket() { return new BuddyListGames2Packet(); }
+ virtual int getPacketId() { return XFIRE_BUDDYS_GAMES2_ID; }
+ virtual void parseContent(char *buf, int length, int numberOfAtts);
+ };
+
+};
+
+
+#endif
+
diff --git a/protocols/Xfire/src/buddylistgamespacket.cpp b/protocols/Xfire/src/buddylistgamespacket.cpp
new file mode 100644
index 0000000000..4ba878951b
--- /dev/null
+++ b/protocols/Xfire/src/buddylistgamespacket.cpp
@@ -0,0 +1,144 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include <vector>
+#include <string>
+
+#include "buddylistgamespacket.h"
+#include "xfireparse.h"
+#include "variablevalue.h"
+#include "xdebug.h"
+
+namespace xfirelib {
+ using namespace std;
+
+ BuddyListGamesPacket::BuddyListGamesPacket() {
+ ips = 0;
+ ports = 0;
+ gameids = 0;
+ gameids2 = 0;
+ sids = 0;
+ type = 0;
+ }
+ BuddyListGamesPacket::~BuddyListGamesPacket() {
+ if(ips) {
+ for( vector<char*>::iterator it = ips->begin() ;
+ it != ips->end() ; it++) {
+ delete[] *it;
+ }
+ }
+ delete ips;
+ delete ports;
+ delete gameids;
+ delete gameids2;
+ delete sids;
+ }
+
+ void BuddyListGamesPacket::parseContent(char *buf, int length, int numberOfAtts) {
+ int index = 0;
+ int numberOfSids = 0;
+ VariableValue val;
+
+ index += val.readName(buf,index);
+ index ++; // Ignore 04
+ index ++; // Ignore 03
+ numberOfSids = (unsigned char) buf[index];
+ index ++; // Ignore 00
+ index ++;
+ sids = new vector<char *>;
+ for(int i = 0 ; i < numberOfSids ; i++) {
+ index += val.readValue(buf,index,16);
+ char *sid = new char[16];
+ memcpy(sid,val.getValue(),16);
+ sids->push_back(sid);
+ }
+
+ index += val.readName(buf,index);
+ index ++; // Ignore 04
+ index ++; // Ignore 03
+ numberOfSids = (unsigned char) buf[index];
+ index ++; // Ignore 00
+ index ++;
+
+ gameids = new vector<long>;
+ gameids2 = new vector<long>;
+ for(int i = 0 ; i < numberOfSids ; i++) {
+ index += val.readValue(buf,index,2);
+ long game = val.getValueAsLong();
+ index += val.readValue(buf,index,2);
+ long game2 = val.getValueAsLong();
+ gameids->push_back(game);
+ gameids2->push_back(game2);
+ }
+
+ index += val.readName(buf,index);
+ index ++; // Ignore 04
+ index ++; // Ignore 03
+ numberOfSids = (unsigned char) buf[index];
+ index ++; // Ignore 00
+ index ++;
+
+ ips = new vector<char *>;
+ for(int i = 0 ; i < numberOfSids ; i++) {
+ index += val.readValue(buf,index,4);
+ char *ip = new char[4];
+ memcpy(ip,val.getValue(),4);
+ ips->push_back(ip);
+ }
+
+ index += val.readName(buf,index);
+ index ++; // Ignore 04
+ index ++; // Ignore 03
+ numberOfSids = (unsigned char) buf[index];
+ index ++; // Ignore 00
+ index ++;
+
+// static int was=0;
+// int portwasnull=0;
+
+
+// was++;
+
+ ports = new vector<long>;
+ for(int i = 0 ; i < numberOfSids ; i++) {
+ index += val.readValue(buf,index,2);
+ long port = val.getValueAsLong();
+// if(port==0)
+// {
+// portwasnull=1;
+// }
+ ports->push_back(port);
+ index += 2; // fixed port bug - dufte
+ }
+
+// char temp[512];
+ /* sprintf(temp,"packet%d_%d.dmp",was,portwasnull);
+ FILE * f = fopen(temp,"wb");
+ fwrite(buf,length,1,f);
+ fclose(f);*/
+
+ }
+
+
+};
diff --git a/protocols/Xfire/src/buddylistgamespacket.h b/protocols/Xfire/src/buddylistgamespacket.h
new file mode 100644
index 0000000000..ba0264c29e
--- /dev/null
+++ b/protocols/Xfire/src/buddylistgamespacket.h
@@ -0,0 +1,61 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __BUDDYLISTGAMESPACKET_H
+#define __BUDDYLISTGAMESPACKET_H
+
+#define XFIRE_BUDDYS_GAMES_ID 135
+
+#include <vector>
+#include <string>
+
+#include "xfirerecvpacketcontent.h"
+#include "variablevalue.h"
+
+
+namespace xfirelib {
+ using namespace std;
+
+ class BuddyListGamesPacket : public XFireRecvPacketContent {
+ public:
+ BuddyListGamesPacket();
+ virtual ~BuddyListGamesPacket();
+
+ XFirePacketContent* newPacket() { return new BuddyListGamesPacket(); }
+
+ virtual int getPacketId() { return XFIRE_BUDDYS_GAMES_ID; }
+ int getPacketContent(char *buf) { return 0; }
+ int getPacketAttributeCount() { return 0; };
+ int getPacketSize() { return 1024; };
+ virtual void parseContent(char *buf, int length, int numberOfAtts);
+
+ vector<char *> *ips;
+ vector<long> *ports;
+ vector<long> *gameids;
+ vector<long> *gameids2;
+ vector<char *> *sids;
+ int type;
+ };
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/buddylistnamespacket.cpp b/protocols/Xfire/src/buddylistnamespacket.cpp
new file mode 100644
index 0000000000..80e962fe4d
--- /dev/null
+++ b/protocols/Xfire/src/buddylistnamespacket.cpp
@@ -0,0 +1,104 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+#include <vector>
+#include <string>
+
+#include "buddylistnamespacket.h"
+#include "xfireparse.h"
+#include "variablevalue.h"
+#include "xdebug.h"
+
+namespace xfirelib {
+ using namespace std;
+
+ BuddyListNamesPacket::BuddyListNamesPacket() {
+ usernames = 0;
+ nicks = 0;
+ userids = 0;
+ }
+ BuddyListNamesPacket::~BuddyListNamesPacket() {
+ delete usernames;
+ delete nicks;
+ delete userids;
+ }
+
+ void BuddyListNamesPacket::parseContent(char *buf, int length, int numberOfAtts) {
+ int index = 0;
+ //prüfe ob das packet mit 0x7 anfängt um eventuell crashes zufixen
+ if(buf[0]!=0x7)
+ {
+ usernames = new vector<string>;
+ nicks = new vector<string>;
+ userids = new vector<long>;
+ return;
+ }
+
+ // friends
+ VariableValue friends;
+ index += friends.readName(buf,index);
+ index ++; // Ignore 04
+ index ++; // Ignore 01, dufte skip 1
+
+ usernames = new vector<string>;
+ index = readStrings(usernames,buf,index);
+
+ index += friends.readName(buf,index);
+ index ++; // Ignore 04
+ index ++; // Ignore 01, dufte skip 1
+
+ nicks = new vector<string>;
+ index = readStrings(nicks,buf,index);
+
+ index += friends.readName(buf,index);
+ index ++; // Ignore 04
+ index ++; // Ignore 01, dufte skip 1
+
+ index += friends.readValue(buf,index,2); // 2 bytes lesen, für große mengen an friends
+ userids = new vector<long>;
+ int numberOfIds = friends.getValueAsLong();
+ for(int i = 0 ; i < numberOfIds ; i++) {
+ index += friends.readValue(buf,index,4);
+ userids->push_back(friends.getValueAsLong());
+ XDEBUG2( "UserID: %ld\n", friends.getValueAsLong() );
+ }
+ }
+
+ int BuddyListNamesPacket::readStrings(vector<string> *strings, char *buf, int index) {
+ VariableValue friends;
+ index += friends.readValue(buf,index,2); //jeweils 2 bytes lesen
+ //index ++; // Ignore 00 0 brauch nicht mehr geskippt werden
+ int numberOfStrings = friends.getValueAsLong();
+ XDEBUG3( "name: %s numberOfStrings: %d\n", friends.getName().c_str(), numberOfStrings );
+ for(int i = 0 ; i < numberOfStrings ; i++) {
+ int length = (unsigned char)buf[index++];
+ index++;
+ index += friends.readValue(buf,index,length);
+ string stringvalue = string(friends.getValue(),length);
+ strings->push_back(stringvalue);
+ XDEBUG3( "String length: %2d : %s\n", length, stringvalue.c_str() );
+ }
+ return index;
+ }
+
+};
diff --git a/protocols/Xfire/src/buddylistnamespacket.h b/protocols/Xfire/src/buddylistnamespacket.h
new file mode 100644
index 0000000000..5c50f4f110
--- /dev/null
+++ b/protocols/Xfire/src/buddylistnamespacket.h
@@ -0,0 +1,61 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __BUDDYLISTNAMESPACKET_H
+#define __BUDDYLISTNAMESPACKET_H
+
+#define XFIRE_BUDDYS_NAMES_ID 131
+
+#include <vector>
+#include <string>
+
+#include "xfirerecvpacketcontent.h"
+#include "variablevalue.h"
+
+
+namespace xfirelib {
+ using namespace std;
+
+ class BuddyListNamesPacket : public XFireRecvPacketContent {
+ public:
+ BuddyListNamesPacket();
+ virtual ~BuddyListNamesPacket();
+
+ XFirePacketContent* newPacket() { return new BuddyListNamesPacket(); }
+
+ int getPacketId() { return XFIRE_BUDDYS_NAMES_ID; }
+ int getPacketContent(char *buf) { return 0; }
+ int getPacketAttributeCount() { return 0; };
+ int getPacketSize() { return 1024; };
+ void parseContent(char *buf, int length, int numberOfAtts);
+
+ //private:
+ int readStrings(vector<string> *strings, char *buf, int index);
+
+ vector<string> *usernames;
+ vector<string> *nicks;
+ vector<long> *userids;
+ };
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/buddylistonlinepacket.cpp b/protocols/Xfire/src/buddylistonlinepacket.cpp
new file mode 100644
index 0000000000..3dd726d4e9
--- /dev/null
+++ b/protocols/Xfire/src/buddylistonlinepacket.cpp
@@ -0,0 +1,85 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include "stdafx.h"
+#include "buddylistonlinepacket.h"
+#include "xfireparse.h"
+#include "variablevalue.h"
+#include <vector>
+#include "xdebug.h"
+#include <iostream>
+
+namespace xfirelib {
+ using namespace std;
+
+ void BuddyListOnlinePacket::parseContent(char *buf, int length, int numberOfAtts) {
+ DUMPPACKET("BuddyListOnlinePacket")
+ XINFO(( "Got List of buddys that are online\n" ));
+ int index = 0;
+ // friends
+ VariableValue userid;
+ userids = new vector<long>;
+
+ /* auskommentiert, wird nicht mehr gesendet 2.3.11
+ index += userid.readName(buf,index);
+ */
+ index ++; // Ignore 01
+ index ++; // Ignore 04
+ index ++; // Ignore 02
+
+
+ int numberOfIds = (unsigned char)buf[index];
+ index++;
+ index++;//ignore 00
+ for(int i = 0 ; i < numberOfIds ; i++) {
+ index += userid.readValue(buf,index,4);
+ userids->push_back(userid.getValueAsLong());
+ XINFO2( "UserID: %ld\n", userid.getValueAsLong() );
+ }
+
+ VariableValue sid;
+ sids = new vector<char *>;
+ /* auskommentiert, wird nicht mehr gesendet 2.3.11
+ index += sid.readName(buf,index); */
+
+ index ++; // Ignore 03
+ index ++; // Ignore 04
+ index ++; // Ignore 03
+
+
+ numberOfIds = (unsigned char)buf[index];
+ index++;
+ index++;//ignore 00
+ for(int i = 0 ; i < numberOfIds ; i++) {
+ index += userid.readValue(buf,index,16);
+ char *sid = new char[16];
+ memcpy(sid,userid.getValue(),16);
+ sids->push_back(sid);
+ //for(int loop = 0; loop < userid.getValueLength();loop++){
+ // XINFO(( "SID: %d\n", userid.getValue()[loop] ));
+ //}
+ }
+
+ }
+
+};
diff --git a/protocols/Xfire/src/buddylistonlinepacket.h b/protocols/Xfire/src/buddylistonlinepacket.h
new file mode 100644
index 0000000000..1f9b432b63
--- /dev/null
+++ b/protocols/Xfire/src/buddylistonlinepacket.h
@@ -0,0 +1,53 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __BUDDYLISTONLINEPACKET_H
+#define __BUDDYLISTONLINEPACKET_H
+
+#include <vector>
+
+#include "xfirerecvpacketcontent.h"
+#include "variablevalue.h"
+
+
+#define XFIRE_BUDDYS_ONLINE_ID 132
+
+namespace xfirelib {
+using namespace std;
+ class BuddyListOnlinePacket : public XFireRecvPacketContent {
+ public:
+ XFirePacketContent* newPacket() { return new BuddyListOnlinePacket(); }
+
+
+ int getPacketId() { return XFIRE_BUDDYS_ONLINE_ID; }
+ int getPacketContent(char *buf) { return 0; }
+ int getPacketAttributeCount() { return 0; };
+ int getPacketSize() { return 1024; };
+ void parseContent(char *buf, int length, int numberOfAtts);
+
+ vector<long> *userids;
+ vector<char *> *sids;
+ };
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/clanbuddylistnamespacket.cpp b/protocols/Xfire/src/clanbuddylistnamespacket.cpp
new file mode 100644
index 0000000000..2a1b4c77a6
--- /dev/null
+++ b/protocols/Xfire/src/clanbuddylistnamespacket.cpp
@@ -0,0 +1,112 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+#include <vector>
+#include <string>
+
+#include "clanbuddylistnamespacket.h"
+#include "xfireparse.h"
+#include "variablevalue.h"
+#include "xdebug.h"
+
+namespace xfirelib {
+ using namespace std;
+
+ ClanBuddyListNamesPacket::ClanBuddyListNamesPacket() {
+ usernames = 0;
+ nicks = 0;
+ userids = 0;
+ clanid = 0;
+ }
+ ClanBuddyListNamesPacket::~ClanBuddyListNamesPacket() {
+ delete usernames;
+ delete nicks;
+ delete userids;
+ }
+
+ void ClanBuddyListNamesPacket::parseContent(char *buf, int length, int numberOfAtts) {
+ int index = 0;
+
+ VariableValue friends;
+
+ XDEBUG2( "Len: %ld\n", length );
+
+ index+=2; //paar bytes überspringen
+
+ index += friends.readValue(buf,index,2);
+ this->clanid = friends.getValueAsLong();
+
+ index+=4; //paar bytes überspringen
+
+ userids = new vector<long>;
+
+ index += friends.readValue(buf,index);
+
+ int numberOfIds = friends.getValueAsLong();
+
+ XDEBUG2( "numberofId: %ld\n", numberOfIds );
+
+ for(int i = 0 ; i < numberOfIds ; i++) {
+ index += friends.readValue(buf,index,4);
+ userids->push_back(friends.getValueAsLong());
+ XDEBUG3( "UserID: %ld %ld\n",i+1, friends.getValueAsLong() );
+ }
+
+ XDEBUG2( "NextByte: %ld\n",buf[index] );
+ XDEBUG2( "NextByte: %ld\n",buf[index+1] );
+
+ index+=3; //nächsten 3 skippen
+
+ XDEBUG2( "NextByte: %ld\n",buf[index] );
+ XDEBUG2( "NextByte: %ld\n",buf[index+1] );
+
+ usernames = new vector<string>;
+ index = readStrings(usernames,buf,index);
+
+ index+=3; //nächsten 3 skippen
+
+ nicks = new vector<string>;
+ index = readStrings(nicks,buf,index);
+
+ }
+
+ int ClanBuddyListNamesPacket::readStrings(vector<string> *strings, char *buf, int index) {
+ VariableValue friends;
+ index += friends.readValue(buf,index,2);
+ //index ++; // Ignore 00
+ int numberOfStrings = friends.getValueAsLong();
+ XDEBUG3( "name: %s numberOfStrings: %d\n", friends.getName().c_str(), numberOfStrings );
+ for(int i = 0 ; i < numberOfStrings ; i++) {
+ int length = (unsigned char)buf[index++];
+ index++;
+ index += friends.readValue(buf,index,length);
+ string stringvalue = string(friends.getValue(),length);
+ strings->push_back(stringvalue);
+ XDEBUG(( "String length: %2d : %s\n", length, stringvalue.c_str() ));
+ }
+ return index;
+ }
+
+};
diff --git a/protocols/Xfire/src/clanbuddylistnamespacket.h b/protocols/Xfire/src/clanbuddylistnamespacket.h
new file mode 100644
index 0000000000..f47fc694f7
--- /dev/null
+++ b/protocols/Xfire/src/clanbuddylistnamespacket.h
@@ -0,0 +1,64 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __CLANBUDDYLISTNAMESPACKET_H
+#define __CLANBUDDYLISTNAMESPACKET_H
+
+#define XFIRE_CLAN_BUDDYS_NAMES_ID 159
+
+#include <vector>
+#include <string>
+
+#include "xfirerecvpacketcontent.h"
+#include "variablevalue.h"
+
+
+namespace xfirelib {
+ using namespace std;
+
+ class ClanBuddyListNamesPacket : public XFireRecvPacketContent {
+ public:
+ ClanBuddyListNamesPacket();
+ virtual ~ClanBuddyListNamesPacket();
+
+ XFirePacketContent* newPacket() { return new ClanBuddyListNamesPacket(); }
+
+ int getPacketId() { return XFIRE_CLAN_BUDDYS_NAMES_ID; }
+ int getPacketContent(char *buf) { return 0; }
+ int getPacketAttributeCount() { return 0; };
+ int getPacketSize() { return 10024; };
+ void parseContent(char *buf, int length, int numberOfAtts);
+
+ //private:
+ int readStrings(vector<string> *strings, char *buf, int index);
+
+ long clanid;
+ vector<string> *usernames;
+ vector<string> *nicks;
+ vector<long> *userids;
+ };
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/claninvitationpacket.cpp b/protocols/Xfire/src/claninvitationpacket.cpp
new file mode 100644
index 0000000000..08fb2b2267
--- /dev/null
+++ b/protocols/Xfire/src/claninvitationpacket.cpp
@@ -0,0 +1,138 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include <vector>
+#include <string>
+
+#include "claninvitationpacket.h"
+#include "xfireparse.h"
+#include "variablevalue.h"
+#include "xdebug.h"
+
+namespace xfirelib {
+ using namespace std;
+
+ ClanInvitationPacket::ClanInvitationPacket() {
+ }
+ ClanInvitationPacket::~ClanInvitationPacket() {
+ }
+
+ void ClanInvitationPacket::parseContent(char *buf, int length, int numberOfAtts) {
+ int index = 0;
+ numberOfInv = 0;
+ VariableValue val;
+
+ index+=0x3; //einige bytes überspringen
+
+ numberOfInv=buf[index];
+ XDEBUG2("Invs %d\n",numberOfInv);
+
+ index+=2; // überspring 0
+
+ //clan id's überspringen, wird eh nicht gebraucht
+ for(int i=0;i<numberOfInv;i++)
+ index+=4;
+
+ index++; // 0x72 überspringen
+
+ index+=4; // weitere bytes überspringen
+
+ //clanidnamen überspringen
+ for(int i=0;i<numberOfInv;i++)
+ {
+ int length = (unsigned char)buf[index++];
+ index++;
+ index += val.readValue(buf,index,length);
+ string stringvalue = string(val.getValue(),length);
+ XDEBUG2("Clanidnames von %s\n",stringvalue.c_str());
+ }
+
+ //weitere 5 bytes überspringen
+ index+=5;
+
+ for(int i=0;i<numberOfInv;i++)
+ {
+ int length = (unsigned char)buf[index++];
+ index++;
+ index += val.readValue(buf,index,length);
+ string stringvalue = string(val.getValue(),length);
+ XDEBUG2("Inv von %s\n",stringvalue.c_str());
+ clanname[i]=stringvalue;
+ }
+
+ //weitere 5 bytes skippen
+ index+=5;
+
+ //weitere leere bytes skippen, weis nich was für einen sinn haben
+ for(int i=0;i<numberOfInv;i++)
+ index+=4;
+
+ //weitere 5 bytes skippen
+ index+=5;
+
+ //usernames auslesen
+ for(int i=0;i<numberOfInv;i++)
+ {
+ int length = (unsigned char)buf[index++];
+ index++;
+ index += val.readValue(buf,index,length);
+ string stringvalue = string(val.getValue(),length);
+ XDEBUG2("Usernames von %s\n",stringvalue.c_str());
+ invitefromusername[i]=stringvalue;
+ }
+
+ //nochmal weitere 5 bytes skippen
+ index+=5;
+
+ //nicks auslesen
+ for(int i=0;i<numberOfInv;i++)
+ {
+ int length = (unsigned char)buf[index++];
+ index++;
+ index += val.readValue(buf,index,length);
+ string stringvalue = string(val.getValue(),length);
+ XDEBUG2("Nicks von %s\n",stringvalue.c_str());
+ invitefrom[i]=stringvalue;
+ }
+
+ //nochmal weitere 5 bytes skippen
+ index+=5;
+
+ //einladungen auslesen
+ for(int i=0;i<numberOfInv;i++)
+ {
+ int length = (unsigned char)buf[index++];
+ index++;
+ index += val.readValue(buf,index,length);
+ string stringvalue = string(val.getValue(),length);
+ XDEBUG2("Nicks von %s\n",stringvalue.c_str());
+ invitemsg[i]=stringvalue;
+ }
+
+ }
+
+
+};
diff --git a/protocols/Xfire/src/claninvitationpacket.h b/protocols/Xfire/src/claninvitationpacket.h
new file mode 100644
index 0000000000..b595c5ba9c
--- /dev/null
+++ b/protocols/Xfire/src/claninvitationpacket.h
@@ -0,0 +1,61 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __CLANINVITATION_H
+#define __CLANINVITATION_H
+
+#define XFIRE_CLANINVITATION_ID 165
+
+#include <string>
+
+#include "xfirerecvpacketcontent.h"
+#include "variablevalue.h"
+
+namespace xfirelib {
+ using namespace std;
+
+ class ClanInvitationPacket : public XFireRecvPacketContent {
+ public:
+ ClanInvitationPacket();
+ virtual ~ClanInvitationPacket();
+
+ XFirePacketContent* newPacket() { return new ClanInvitationPacket(); }
+
+ virtual int getPacketId() { return XFIRE_CLANINVITATION_ID; }
+ int getPacketContent(char *buf) { return 0; }
+ int getPacketAttributeCount() { return 0; };
+ int getPacketSize() { return 1024; };
+ virtual void parseContent(char *buf, int length, int numberOfAtts);
+
+ //maximal 10 inv, mehr wird denk ich äh nich aufeinmal auftreten
+ string clanname[10];
+ string invitefrom[10];
+ string invitefromusername[10];
+ string invitemsg[10];
+
+ int numberOfInv;
+ };
+};
+
+#endif \ No newline at end of file
diff --git a/protocols/Xfire/src/client.cpp b/protocols/Xfire/src/client.cpp
new file mode 100644
index 0000000000..4800482e27
--- /dev/null
+++ b/protocols/Xfire/src/client.cpp
@@ -0,0 +1,296 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+#include "xdebug.h"
+#include "client.h"
+#include "clientinformationpacket.h"
+#include "clientversionpacket.h"
+#include "xfirepacket.h"
+#include "authpacket.h"
+#include "clientloginpacket.h"
+#include "buddylistnamespacket.h"
+#include "messagepacket.h"
+#include "sendmessagepacket.h"
+#include "messageackpacket.h"
+#include "recvoldversionpacket.h"
+#include "sendkeepalivepacket.h"
+
+#include "baseProtocol.h"
+
+#include <iostream>
+
+//#define XFIRE_HOST "cs.xfire.com"
+#define XFIRE_HOST "206.220.42.147"
+#define XFIRE_PORT 25999
+
+extern BOOL mySleep(int ms,HANDLE evt);
+extern HANDLE hConnectionClose;
+extern WINBASEAPI
+BOOL
+WINAPI
+ResetEvent(
+ __in HANDLE hEvent
+ );
+
+//#define UINT_8 unsigned char
+//#define UINT_32 unsigned long
+
+namespace xfirelib {
+
+using namespace std;
+
+ Client::Client() {
+ XDEBUG(("Client constructor ...\n"));
+ gameResolver = NULL;
+ packetReader = new PacketReader(NULL);
+ packetReader->addPacketListener( this );
+ buddyList = new BuddyList( this );
+ socket=NULL;
+#ifndef NO_PTHREAD
+ sendpingthread.p=NULL;
+ readthread.p=NULL;
+#endif
+ }
+
+ Client::~Client(){
+ XDEBUG(("Client destructor ...\n"));
+ delete username;
+ delete password;
+ delete buddyList;
+ delete packetReader;
+ delete socket;
+ }
+
+ void Client::connect( string username, string password, int useproxy, string proxyip, int proxyport) {
+ try {
+ this->gotBudduyList=FALSE;
+ this->username = new string(username);
+ this->password = new string(password);
+ socket = new Socket( XFIRE_HOST, XFIRE_PORT,useproxy,proxyip,proxyport );
+
+ //bevors losgeht, erstmal die localaddr sichern
+ struct sockaddr_in sa;
+ int iLen = sizeof(sa);
+ getsockname(socket->m_sock, (SOCKADDR*)&sa, &iLen);
+ strcpy(this->localaddr,inet_ntoa(sa.sin_addr));
+ this->llocaladdr=inet_addr(this->localaddr);
+
+ packetReader->setSocket(socket);
+
+ ResetEvent(hConnectionClose);
+
+ startThreads();
+ //packetReader->startListening();
+
+
+ socket->send("UA01");
+ XDEBUG(("Sent UA01\n"));
+ ClientInformationPacket *infoPacket = new ClientInformationPacket();
+ this->send( infoPacket );
+ delete infoPacket;
+ XINFO(("sent ClientInformationPacket\n"));
+
+ ClientVersionPacket *versionPacket = new ClientVersionPacket();
+ versionPacket->setProtocolVersion( protocolVersion);
+ this->send( versionPacket );
+ delete versionPacket;
+
+ XINFO(("sent ClientVersionPacket\n"));
+ this->connected=TRUE;
+ } catch( SocketException ex ) {
+ XERROR(("Socket Exception ?! %s \n",ex.description().c_str() ));
+ this->connected=FALSE;
+ }
+ }
+ XFireGameResolver *Client::getGameResolver() {
+ return gameResolver;
+ }
+ void Client::startThreads() {
+ XINFO(("About to start thread\n"));
+#ifndef NO_PTHREAD
+ void* (*func)(void*) = &xfirelib::Client::startReadThread;
+ pthread_create( &readthread, NULL, func, (void*)this );
+ void* (*func2)(void*) = &xfirelib::Client::startSendPingThread;
+ pthread_create( &sendpingthread, NULL, func2, (void*)this );
+#else
+ //mir_create!!!!
+ mir_forkthread(xfirelib::Client::startReadThread,(LPVOID)this);
+ mir_forkthread(xfirelib::Client::startSendPingThread,(LPVOID)this);
+#endif
+ }
+#ifndef NO_PTHREAD
+ void *Client::startReadThread(void *ptr) {
+#else
+ void Client::startReadThread(LPVOID lParam) {
+ void* ptr=(void*)lParam;
+#endif
+ if(ptr==NULL||((Client*)ptr)->packetReader==NULL)
+#ifndef NO_PTHREAD
+ return NULL;
+#else
+ return;
+#endif
+ try {
+ ((Client*)ptr)->packetReader->run();
+ } catch (SocketException ex) {
+ XERROR(("Socket Exception ?! %s \n",ex.description().c_str() ));
+
+ //miranda bescheid geben, wir haben verbindung verloren
+ if(ptr==NULL||((Client*)ptr)->connected) SetStatus(ID_STATUS_OFFLINE,NULL);
+
+ //((Client*)ptr)->disconnect();
+ }
+#ifndef NO_PTHREAD
+ return NULL;
+#else
+ return;
+#endif
+ }
+
+#ifndef NO_PTHREAD
+ void *Client::startSendPingThread(void *ptr) {
+ Client *me = (Client*)ptr;
+#else
+ void Client::startSendPingThread(LPVOID lParam) {
+ Client *me = (Client*)lParam;
+#endif
+ SendKeepAlivePacket packet;
+
+ while(1) {
+#ifndef NO_PTHREAD
+ pthread_testcancel();
+#endif
+ //Sleep(60000); // Sleep for 40 sek
+ if(mySleep(60000,hConnectionClose))
+ {
+#ifndef NO_PTHREAD
+ return NULL;
+#else
+ return;
+#endif
+ }
+#ifndef NO_PTHREAD
+ pthread_testcancel();
+#endif
+ XDEBUG(( "Sending KeepAlivePacket\n" ));
+ if(!me->send( &packet )) {
+ XINFO(( "Could not send KeepAlivePacket... exiting thread.\n" ));
+ break;
+ }
+ }
+#ifndef NO_PTHREAD
+ return NULL;
+#else
+ return;
+#endif
+ }
+
+ void Client::disconnect() {
+ this->connected=FALSE;
+
+ //socket vom packetreader auf NULL, damit die readschleife geschlossen wird
+ if(this->packetReader!=NULL)
+ this->packetReader->setSocket(NULL);
+
+ XDEBUG( "cancelling readthread ... \n");
+#ifndef NO_PTHREAD
+ if(readthread.p!=NULL) pthread_cancel (readthread);
+ readthread.p=NULL;
+
+ XDEBUG( "cancelling sendpingthread ... \n");
+ if(sendpingthread.p!=NULL) pthread_cancel (sendpingthread);
+ sendpingthread.p=NULL;
+#endif
+
+ XDEBUG( "deleting socket ...\n" );
+ if(socket){
+ delete socket;
+ socket = NULL;
+ }
+ XDEBUG(( "done\n" ));
+ }
+
+ bool Client::send( XFirePacketContent *content ) {
+ if(!socket) {
+ XERROR(( "Trying to send content packet altough socket is NULL ! (ignored)\n" ));
+ return false;
+ }
+ XFirePacket *packet = new XFirePacket(content);
+ packet->sendPacket( socket );
+ delete packet;
+ return true;
+ }
+
+ void Client::addPacketListener( PacketListener *listener ) {
+ packetReader->addPacketListener( listener );
+ }
+
+
+ void Client::receivedPacket( XFirePacket *packet ) {
+ XDEBUG(("Client::receivedPacket\n"));
+ if( packet == NULL ) {
+ XERROR(("packet is NULL !!!\n"));
+ return;
+ }
+ if( packet->getContent() == NULL ) {
+ XERROR(("ERRRR getContent() returns null ?!\n"));
+ return;
+ }
+ XFirePacketContent *content = packet->getContent();
+
+ switch( content->getPacketId() ) {
+ case XFIRE_PACKET_AUTH_ID: {
+ XINFO(("Got Auth Packet .. Sending Login\n"));
+ AuthPacket *authPacket = (AuthPacket*)packet->getContent();
+
+ ClientLoginPacket *login = new ClientLoginPacket();
+ login->setSalt( authPacket->getSalt() );
+ login->setUsername( *username );
+ login->setPassword( *password );
+ send( login );
+ delete login;
+ break;
+ }
+
+ case XFIRE_MESSAGE_ID: {
+ XDEBUG(( "Got Message, sending ACK\n" ));
+ MessagePacket *message = (MessagePacket*)packet->getContent();
+ if(message->getMessageType() == 0){
+ MessageACKPacket *ack = new MessageACKPacket();
+ memcpy(ack->sid,message->getSid(),16);
+ ack->imindex = message->getImIndex();
+ send( ack );
+ delete ack;
+ }else if(message->getMessageType() == 2){
+ send(message);
+ }
+ break;
+ }
+
+ default:
+ //cout << "Nothing here ... " << endl;
+ break;
+ }
+
+ }
+};
diff --git a/protocols/Xfire/src/client.h b/protocols/Xfire/src/client.h
new file mode 100644
index 0000000000..5822c6c27e
--- /dev/null
+++ b/protocols/Xfire/src/client.h
@@ -0,0 +1,96 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __CLIENT_H
+#define __CLIENT_H
+
+#include "stdafx.h"
+
+#ifndef NO_PTHREAD
+ #include <pthread.h>
+#endif
+
+#include <string>
+#include "packetreader.h"
+#include "xfirepacketcontent.h"
+#include "packetlistener.h"
+#include "buddylist.h"
+#include "xfiregameresolver.h"
+
+namespace xfirelib {
+ struct BuddyList;
+
+class Client : public PacketListener {
+ public:
+ Client();
+ ~Client();
+ //proxy hinzugefügt dufte
+ void connect(std::string username, std::string password,int useproxy=0,string proxyip="",int proxyport=0);
+ /**
+ * Sends a XFirePacketContent (does NOT delete content)
+ * Returns true if sent successfully.
+ */
+ bool send(XFirePacketContent *content);
+
+ BuddyList *getBuddyList() { return buddyList; }
+ void addPacketListener(PacketListener *packetListener);
+ void disconnect();
+ void sendMessage(string username, string message);
+ void sendNickChange(string nick);
+ XFireGameResolver *getGameResolver();
+ void setGameResolver(XFireGameResolver *resolver) {
+ delete this->gameResolver;
+ this->gameResolver = resolver;
+ }
+
+ BOOL gotBudduyList;
+ BOOL connected;
+ char protocolVersion;
+ char localaddr[18];
+ unsigned long llocaladdr;
+
+ protected:
+ void receivedPacket( XFirePacket *packet );
+ void startThreads();
+#ifndef NO_PTHREAD
+ static void *startReadThread(void *ptr);
+ static void *startSendPingThread(void *ptr);
+#else
+ static void startReadThread(LPVOID lParam);
+ static void startSendPingThread(LPVOID lParam);
+#endif
+ private:
+ XFireGameResolver *gameResolver;
+ PacketReader *packetReader;
+ std::string *username;
+ std::string *password;
+ Socket *socket;
+ BuddyList *buddyList;
+#ifndef NO_PTHREAD
+ pthread_t readthread;
+ pthread_t sendpingthread;
+#endif
+};
+
+};
+
+#endif
diff --git a/protocols/Xfire/src/clientinformationpacket.cpp b/protocols/Xfire/src/clientinformationpacket.cpp
new file mode 100644
index 0000000000..f0d65e8a00
--- /dev/null
+++ b/protocols/Xfire/src/clientinformationpacket.cpp
@@ -0,0 +1,77 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+#include "clientinformationpacket.h"
+#include "xfireutils.h"
+#include <string.h>
+#include <iostream>
+
+namespace xfirelib {
+ using namespace std;
+
+ int ClientInformationPacket::getPacketContent(char *packet) {
+ int index = 0;
+ int skins = 2;
+ int i;
+
+ index = XFireUtils::addAttributName(packet,index, "skin");/*add skin*/
+ packet[index++] = 0x04;
+ packet[index++] = 0x01;
+ packet[index++] = (char)skins;
+ packet[index++] = 0x00;
+ packet[index++] = strlen("Standard");
+ packet[index++] = 0x00;
+
+ memcpy(packet+index,"Standard",strlen("Standard"));/*add first skin name*/
+ index += strlen("Standard");
+
+ packet[index++] = strlen("XFire");
+ packet[index++] = 0x00;
+
+ memcpy(packet+index,"XFire",strlen("XFire"));/*add second skin name*/
+ index += strlen("XFire");
+
+ VariableValue val;
+ val.setName( "version" );
+ index += val.writeName( packet, index );
+ //index = XFireUtils::addAttributName(packet,index, "version");/*add version of skins*/
+ packet[index++] = 0x04;
+ packet[index++] = 0x02;
+ packet[index++] = (char)skins;
+ packet[index++] = 0x00;
+
+ for(i = 0;i < skins;i++){/*(forEachSkin){ 01 00 00 00 }*/
+ packet[index++] = 0x01;
+ packet[index++] = 0x00;
+ packet[index++] = 0x00;
+ packet[index++] = 0x00;
+ }
+ length = index;
+ return index;
+ }
+
+ int ClientInformationPacket::getPacketAttributeCount() {
+ return 2;
+ }
+
+}
diff --git a/protocols/Xfire/src/clientinformationpacket.h b/protocols/Xfire/src/clientinformationpacket.h
new file mode 100644
index 0000000000..533e3fbc91
--- /dev/null
+++ b/protocols/Xfire/src/clientinformationpacket.h
@@ -0,0 +1,55 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+
+#ifndef __CLIENTINFORMATIONPACKET_H
+#define __CLIENTINFORMATIONPACKET_H
+
+#include "xfiresendpacketcontent.h"
+#include "variablevalue.h"
+
+#include <string>
+
+namespace xfirelib {
+
+ /**
+ * (Internal) packet used by Client::login( std::string, std::string )
+ * Users of xfirelib won't need this packet.
+ */
+ class ClientInformationPacket : public XFireSendPacketContent {
+ public:
+ XFirePacketContent* newPacket() { return new ClientInformationPacket(); }
+
+ int getPacketId() { return 18; }
+ int getPacketContent(char *buf);
+ int getPacketAttributeCount();
+ int getPacketSize() { return 46; };
+ void parseContent(char *buf, int length, int numberOfAtts) { };
+ std::string skinname;
+ private:
+ int length;
+ };
+
+};
+
+#endif
diff --git a/protocols/Xfire/src/clientloginpacket.cpp b/protocols/Xfire/src/clientloginpacket.cpp
new file mode 100644
index 0000000000..30a28cc7eb
--- /dev/null
+++ b/protocols/Xfire/src/clientloginpacket.cpp
@@ -0,0 +1,120 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+#include "clientloginpacket.h"
+#include "xfireutils.h"
+#include "SHA1.h"
+#include <string.h>
+#include <iostream>
+
+namespace xfirelib {
+ using namespace std;
+
+ int ClientLoginPacket::getPacketContent(char *packet) {
+ int index = 0;
+ /*Username*/
+
+ index = XFireUtils::addAttributName(packet,index, "name");/*add username attribute*/
+ packet[index] = 0x01;
+ packet[index+1] = (char)name.length();
+ packet[index+2] = 0x00;
+ index +=3;
+ std::copy(name.begin(),name.end(),packet+index);
+ index += name.size();
+
+ /*Crypted Password*/
+ unsigned char pass[41];
+ pass[40] = 0x00;
+ cryptPassword(pass);
+ index = XFireUtils::addAttributName(packet,index, "password");/*add username attribute*/
+ packet[index] = 0x01;
+ packet[index+1] = (char)40;
+ packet[index+2] = 0x00;
+ index += 3;
+
+ memcpy(packet+index,pass,40);
+ index += 40;
+
+ VariableValue val;
+ val.setName( "flags" );
+ index += val.writeName( packet, index );
+ packet[index++] = 0x02;
+ packet[index++] = 0x00;
+ packet[index++] = 0x00;
+ packet[index++] = 0x00;
+ packet[index++] = 0x00;
+
+ val.setName( "sid" );
+ index += val.writeName( packet, index );
+ packet[index++] = 0x03;
+
+ for(int i=0;i<16;i++)
+ {
+ packet[index++] = 0x0;
+ }
+
+ length = index;
+ return index;
+ }
+
+ int ClientLoginPacket::getPacketAttributeCount() {
+ return 3;
+ }
+
+ void ClientLoginPacket::cryptPassword(unsigned char *crypt){
+ std::string total;
+ char temp[81];
+ CSHA1 sha1;
+
+ total = name+password+"UltimateArena";
+ hashSha1(total.c_str(),crypt);
+ memcpy(temp,crypt,40);
+ memcpy(temp+40,salt->getValue(),40);
+ temp[80] = 0x00;
+
+ hashSha1(temp,crypt);
+ }
+
+
+
+/*give string and you will get the hash*/
+void ClientLoginPacket::hashSha1(const char *string, unsigned char *sha){
+
+ char result[41];
+ unsigned char temp[1024];
+ CSHA1 sha1;
+ sha1.Reset();
+ sha1.Update((UINT_8 *)string, strlen(string));
+ sha1.Final();
+ sha1.GetHash(temp);
+
+ result[0] = 0;
+ char szTemp[16];
+ for(int i = 0 ; i < 20 ; i++) {
+ sprintf(szTemp, "%02x", temp[i]);
+ strcat(result,szTemp);
+ }
+ memcpy(sha,result,40);
+ sha[40] = 0x00;
+}
+}
diff --git a/protocols/Xfire/src/clientloginpacket.h b/protocols/Xfire/src/clientloginpacket.h
new file mode 100644
index 0000000000..56f8641b25
--- /dev/null
+++ b/protocols/Xfire/src/clientloginpacket.h
@@ -0,0 +1,71 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+
+#ifndef __CLIENTLOGINPACKET_H
+#define __CLIENTLOGINPACKET_H
+
+
+
+#include "xfiresendpacketcontent.h"
+#include "variablevalue.h"
+#include <string.h>
+
+namespace xfirelib {
+
+ /**
+ * (Internal) Packet used to send login/authorization data.
+ * Users of xfirelib should not use it, call
+ * Client::connect( std::string username, std::string password )
+ * instead.
+ */
+ class ClientLoginPacket : public XFireSendPacketContent {
+ public:
+ XFirePacketContent* newPacket() { return new ClientLoginPacket(); }
+
+ int getPacketId() { return 1; }
+ int getPacketContent(char *buf);
+ int getPacketAttributeCount();
+ int getPacketSize() { return 1024; };
+ void setUsername(std::string name) {this->name = name;}
+ void setPassword(std::string password) {this->password = password; };
+
+ /**
+ *Set the salt the server sent us to crypt the password
+ *@param salt The VariableValue object that we extracted from the packet
+ */
+ void setSalt(VariableValue *salt) {this->salt = salt; };
+
+ void parseContent(char *buf, int length, int numberOfAtts) { };
+ private:
+ void cryptPassword(unsigned char *crypt);
+ void hashSha1(const char *string, unsigned char *sha);
+ int length;
+ std::string name;
+ std::string password;
+ VariableValue *salt;
+ };
+
+};
+
+#endif
diff --git a/protocols/Xfire/src/clientversionpacket.cpp b/protocols/Xfire/src/clientversionpacket.cpp
new file mode 100644
index 0000000000..3150eac746
--- /dev/null
+++ b/protocols/Xfire/src/clientversionpacket.cpp
@@ -0,0 +1,52 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+#include "clientversionpacket.h"
+#include "xfireutils.h"
+#include <string.h>
+
+namespace xfirelib {
+
+ int ClientVersionPacket::getPacketContent(char *packet) {
+ int index = 0;
+
+ index = XFireUtils::addAttributName(packet,index, "version");/*add xfire version*/
+ packet[index] = 0x02;
+ packet[index+1] = (char) version;//protocol version
+ packet[index+2] = 0x00;
+ packet[index+3] = 0x00;
+ packet[index+4] = 0x00;
+ index += 5;
+ length = index;
+ return index;
+ }
+
+ int ClientVersionPacket::getPacketAttributeCount() {
+ return 1;
+ }
+
+ void ClientVersionPacket::setProtocolVersion(int newVersion){
+ version = newVersion;
+ }
+
+}
diff --git a/protocols/Xfire/src/clientversionpacket.h b/protocols/Xfire/src/clientversionpacket.h
new file mode 100644
index 0000000000..4c40b1875a
--- /dev/null
+++ b/protocols/Xfire/src/clientversionpacket.h
@@ -0,0 +1,54 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+
+#ifndef __CLIENTVERSIONPACKET_H
+#define __CLIENTVERSIONPACKET_H
+
+#include "xfiresendpacketcontent.h"
+
+namespace xfirelib {
+
+ /**
+ * (Internal) Packet used to send client version information.
+ * it is sent in Client::connect( std::string, std::string )
+ * so users of xfirelib won't need this packet.
+ */
+ class ClientVersionPacket : public XFireSendPacketContent {
+ public:
+ XFirePacketContent* newPacket() { return new ClientVersionPacket(); }
+
+ int getPacketId() { return 3; }
+ int getPacketContent(char *buf);
+ int getPacketAttributeCount();
+ int getPacketSize() { return 1024; };
+ void setProtocolVersion(int version);
+ void parseContent(char *buf, int length, int numberOfAtts) { };
+ private:
+ int length;
+ int version;
+ };
+
+};
+
+#endif
diff --git a/protocols/Xfire/src/dummyxfiregameresolver.cpp b/protocols/Xfire/src/dummyxfiregameresolver.cpp
new file mode 100644
index 0000000000..5189c8ef9b
--- /dev/null
+++ b/protocols/Xfire/src/dummyxfiregameresolver.cpp
@@ -0,0 +1,49 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+#include "dummyxfiregameresolver.h"
+#include "xdebug.h"
+
+namespace xfirelib {
+
+ XFireGame *DummyXFireGameResolver::resolveGame(int gameid, int iterator, BuddyListGamesPacket *packet) {
+ XDEBUG2( "Resolving GameId: %d\n", gameid );
+ DummyXFireGame *game = new DummyXFireGame();
+ switch(gameid) {
+ case 2: game->init( gameid, "America's Army: Special Forces", packet,iterator ); break;
+ case 3: game->init( gameid, "Unreal Tournament", packet,iterator ); break;
+ case 4: game->init( gameid, "Unreal Tournament 2003", packet ,iterator); break;
+ case 5: game->init( gameid, "Counter-Strike 1.6", packet ,iterator); break;
+ case 32: game->init( gameid, "Teamspeak", packet ,iterator); break;
+ case 4181: game->init( gameid, "Unreal Tournament 2004", packet,iterator ); break;
+ case 4578: game->init( gameid, "Battlefield 2", packet ,iterator); break;
+ case 4611: game->init( gameid, "Live for Speed", packet,iterator ); break;
+ default:
+ game->init( gameid, "Non Resolvegame", packet,iterator );
+ break;
+ }
+ return game;
+ }
+
+
+};
diff --git a/protocols/Xfire/src/dummyxfiregameresolver.h b/protocols/Xfire/src/dummyxfiregameresolver.h
new file mode 100644
index 0000000000..fdaaeb5c0b
--- /dev/null
+++ b/protocols/Xfire/src/dummyxfiregameresolver.h
@@ -0,0 +1,69 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __DUMMYXFIREGAMERESOLVER_H
+#define __DUMMYXFIREGAMERESOLVER_H
+
+#include "xfiregame.h"
+#include "xfiregameresolver.h"
+#include "xdebug.h"
+#include <string>
+
+namespace xfirelib {
+
+ struct DummyXFireGame;
+ class DummyXFireGameResolver : public XFireGameResolver {
+ public:
+ XFireGame *resolveGame(int gameid, int iterator, BuddyListGamesPacket *packet);
+
+ };
+
+
+ class DummyXFireGame : public XFireGame {
+ public:
+ // TODO !!!!!!!!!!!!! this->packet = packet should NOT be used !!
+ // we need to create a copy of packet, because it will be deleted as soon
+ // as all listeners are notified !!!
+ void init(int gameid, std::string gamename, BuddyListGamesPacket *packet, int iterator) {
+ this->gameid = gameid;
+ this->gamename = gamename;
+ this->packet = packet;
+
+ memcpy(ip,packet->ips->at(iterator),4);
+ port = packet->ports->at(iterator);
+ XDEBUG(( "init .. %d / %s\n", gameid, gamename.c_str() ));
+ }
+
+ int getGameId() { return gameid; }
+ std::string getGameName() { return gamename; }
+
+ BuddyListGamesPacket *packet;
+ int gameid;
+ char ip[4];
+ long port;
+ std::string gamename;
+ };
+
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/friendsoffriendlist.cpp b/protocols/Xfire/src/friendsoffriendlist.cpp
new file mode 100644
index 0000000000..bb2c4f884f
--- /dev/null
+++ b/protocols/Xfire/src/friendsoffriendlist.cpp
@@ -0,0 +1,111 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+#include <vector>
+#include <string>
+
+#include "friendsoffriendlist.h"
+#include "xfireparse.h"
+#include "variablevalue.h"
+#include "xdebug.h"
+
+namespace xfirelib {
+ using namespace std;
+
+ FriendsBuddyListNamesPacket::FriendsBuddyListNamesPacket() {
+ usernames = 0;
+ nicks = 0;
+ userids = 0;
+ }
+ FriendsBuddyListNamesPacket::~FriendsBuddyListNamesPacket() {
+ delete usernames;
+ delete nicks;
+ delete userids;
+ }
+
+ void FriendsBuddyListNamesPacket::parseContent(char *buf, int length, int numberOfAtts) {
+ int index = 0;
+
+ VariableValue friends;
+
+ XDEBUG2( "Len: %ld\n", length );
+
+ index+=8; //paar bytes überspringen
+
+ int numberOfIds = (unsigned char)buf[index];
+ XDEBUG2( "numberofId: %ld\n", numberOfIds );
+ index++;
+ index++;//ignore 00
+ sids = new vector<char *>;
+ for(int i = 0 ; i < numberOfIds ; i++) {
+ index += friends.readValue(buf,index,16);
+ char *sid = new char[16];
+ memcpy(sid,friends.getValue(),16);
+ sids->push_back(sid);
+ }
+
+ XERROR("Sids ausgelesen\n");
+
+ index+=7;
+
+ index+=4;
+
+ userids = new vector<long>;
+ for(int i = 0 ; i < numberOfIds ; i++) {
+ index += friends.readValue(buf,index,4);
+ userids->push_back(friends.getValueAsLong());
+ XDEBUG3( "UserID: %ld %ld\n",i+1, friends.getValueAsLong() );
+ }
+
+ index+=7;
+
+ usernames = new vector<string>;
+ index = readStrings(usernames,buf,index);
+
+ index+=7;
+
+ nicks = new vector<string>;
+ index = readStrings(nicks,buf,index);
+
+ }
+
+ int FriendsBuddyListNamesPacket::readStrings(vector<string> *strings, char *buf, int index) {
+ VariableValue friends;
+ index += friends.readValue(buf,index,2);
+ //index ++; // Ignore 00
+ int numberOfStrings = friends.getValueAsLong();
+ XDEBUG3( "name: %s numberOfStrings: %d\n", friends.getName().c_str(), numberOfStrings );
+ for(int i = 0 ; i < numberOfStrings ; i++) {
+ int length = (unsigned char)buf[index++];
+ index++;
+ index += friends.readValue(buf,index,length);
+ string stringvalue = string(friends.getValue(),length);
+ strings->push_back(stringvalue);
+ XDEBUG(( "String length: %2d : %s\n", length, stringvalue.c_str() ));
+ }
+ return index;
+ }
+
+};
diff --git a/protocols/Xfire/src/friendsoffriendlist.h b/protocols/Xfire/src/friendsoffriendlist.h
new file mode 100644
index 0000000000..70c59a76e9
--- /dev/null
+++ b/protocols/Xfire/src/friendsoffriendlist.h
@@ -0,0 +1,64 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __FRIENDSBUDDYLISTNAMESPACKET_H
+#define __FRIENDSBUDDYLISTNAMESPACKET_H
+
+#define XFIRE_FRIENDS_BUDDYS_NAMES_ID 0x88
+
+#include <vector>
+#include <string>
+
+#include "xfirerecvpacketcontent.h"
+#include "variablevalue.h"
+
+
+namespace xfirelib {
+ using namespace std;
+
+ class FriendsBuddyListNamesPacket : public XFireRecvPacketContent {
+ public:
+ FriendsBuddyListNamesPacket();
+ virtual ~FriendsBuddyListNamesPacket();
+
+ XFirePacketContent* newPacket() { return new FriendsBuddyListNamesPacket(); }
+
+ int getPacketId() { return XFIRE_FRIENDS_BUDDYS_NAMES_ID; }
+ int getPacketContent(char *buf) { return 0; }
+ int getPacketAttributeCount() { return 0; };
+ int getPacketSize() { return 10024; };
+ void parseContent(char *buf, int length, int numberOfAtts);
+
+ //private:
+ int readStrings(vector<string> *strings, char *buf, int index);
+
+ vector<string> *usernames;
+ vector<string> *nicks;
+ vector<long> *userids;
+ vector<char *> *sids;
+ };
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/gameinfopacket.cpp b/protocols/Xfire/src/gameinfopacket.cpp
new file mode 100644
index 0000000000..a134af85c9
--- /dev/null
+++ b/protocols/Xfire/src/gameinfopacket.cpp
@@ -0,0 +1,85 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include <vector>
+#include <string>
+
+#include "gameinfopacket.h"
+#include "xfireparse.h"
+#include "variablevalue.h"
+#include "xdebug.h"
+
+namespace xfirelib {
+ using namespace std;
+
+ GameInfoPacket::GameInfoPacket() {
+ }
+ GameInfoPacket::~GameInfoPacket() {
+ }
+
+ void GameInfoPacket::parseContent(char *buf, int length, int numberOfAtts) {
+ int index = 0;
+ int numberOfSids = 0;
+ VariableValue val;
+
+ index += val.readName(buf,index);
+
+ index++; //ignore 04
+ index++; //ignore 03
+
+ XDEBUG2("Anzahl: %d\n",buf[index]);
+ numberOfSids = buf[index];
+
+ index++; //ignore 01
+ index++; //ignore 0
+
+ sids = new vector<char *>;
+ for(int i = 0 ; i < numberOfSids ; i++) {
+ index += val.readValue(buf,index,16);
+ char *sid = new char[16];
+ memcpy(sid,val.getValue(),16);
+ sids->push_back(sid);
+ }
+ index += val.readName(buf,index);
+
+ index += 4; // nächsten 4 bytes skippen
+
+ gameinfo=new vector<string>;
+ for(int i = 0 ; i < numberOfSids ; i++) {
+ int length = (unsigned char)buf[index++];
+ index++;
+ index += val.readValue(buf,index,length);
+ string stringvalue = string(val.getValue(),length);
+ gameinfo->push_back(stringvalue);
+ XDEBUG(( "String length: %2d : %s\n", length, stringvalue.c_str() ));
+ }
+
+ XDEBUG2("Position: %d\n",index);
+
+ }
+
+
+};
diff --git a/protocols/Xfire/src/gameinfopacket.h b/protocols/Xfire/src/gameinfopacket.h
new file mode 100644
index 0000000000..dfd890e814
--- /dev/null
+++ b/protocols/Xfire/src/gameinfopacket.h
@@ -0,0 +1,56 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GAMEINFOPACKET_H
+#define __GAMEINFOPACKET_H
+
+#define XFIRE_GAMEINFO_ID 156
+
+#include <string>
+
+#include "xfirerecvpacketcontent.h"
+#include "variablevalue.h"
+
+namespace xfirelib {
+ using namespace std;
+
+ class GameInfoPacket : public XFireRecvPacketContent {
+ public:
+ GameInfoPacket();
+ virtual ~GameInfoPacket();
+
+ XFirePacketContent* newPacket() { return new GameInfoPacket(); }
+
+ virtual int getPacketId() { return XFIRE_GAMEINFO_ID; }
+ int getPacketContent(char *buf) { return 0; }
+ int getPacketAttributeCount() { return 0; };
+ int getPacketSize() { return 1024; };
+ virtual void parseContent(char *buf, int length, int numberOfAtts);
+
+ vector<char *> *sids;
+ vector<string> *gameinfo;
+ };
+};
+
+#endif \ No newline at end of file
diff --git a/protocols/Xfire/src/getbuddyinfo.cpp b/protocols/Xfire/src/getbuddyinfo.cpp
new file mode 100644
index 0000000000..6d21742510
--- /dev/null
+++ b/protocols/Xfire/src/getbuddyinfo.cpp
@@ -0,0 +1,56 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+#include "getbuddyinfo.h"
+#include <string.h>
+#include <iostream>
+
+/*
+ mit dem paket kan man buddyinfos anfordern, bei zu aggressiven anfragen kappt xfire die verbindung
+ getestet mit clanbuddy's >270 members
+*/
+
+namespace xfirelib {
+ using namespace std;
+
+ int GetBuddyInfo::getPacketContent(char *packet) {
+ int index = 0;
+
+ VariableValue val;
+ val.setValueFromLong(userid,4);
+
+ packet[index++] = 0x01;
+ packet[index++] = 0x02;
+ index += val.writeValue(packet, index);
+
+ length = index;
+ return index;
+ }
+
+ int GetBuddyInfo::getPacketAttributeCount() {
+ return 1;
+ }
+
+}
diff --git a/protocols/Xfire/src/getbuddyinfo.h b/protocols/Xfire/src/getbuddyinfo.h
new file mode 100644
index 0000000000..efd8ded51d
--- /dev/null
+++ b/protocols/Xfire/src/getbuddyinfo.h
@@ -0,0 +1,55 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+//mit dem packet kann man die buddyinfos anfordern
+
+#ifndef __GETBUDDYINFO_H
+#define __GETBUDDYINFO_H
+
+#include "xfiresendpacketcontent.h"
+#include "variablevalue.h"
+
+#include <string>
+
+namespace xfirelib {
+
+ class GetBuddyInfo : public XFireSendPacketContent {
+ public:
+ XFirePacketContent* newPacket() { return new GetBuddyInfo(); }
+
+ int getPacketId() { return 0x25; }
+ int getPacketContent(char *buf);
+ int getPacketAttributeCount();
+ int getPacketSize() { return 1000; };
+ void parseContent(char *buf, int length, int numberOfAtts) { };
+
+ unsigned int userid;
+
+ private:
+ int length;
+ };
+
+};
+
+#endif
diff --git a/protocols/Xfire/src/iniupdater.cpp b/protocols/Xfire/src/iniupdater.cpp
new file mode 100644
index 0000000000..61b99884ed
--- /dev/null
+++ b/protocols/Xfire/src/iniupdater.cpp
@@ -0,0 +1,128 @@
+//iniupdater.cpp by dufte, großen dank an xfireplus.com
+
+#include "stdafx.h"
+
+#include "iniupdater.h"
+#include "baseProtocol.h"
+
+extern HANDLE XFireWorkingFolder;
+extern HANDLE XFireIconFolder;
+
+BOOL CALLBACK DlgUpdateDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+
+ char*buf=NULL; //leeren zeiger für den empfangen buffer
+ GetWWWContent2(INI_WHATSNEW,NULL,FALSE,&buf);
+
+ if(buf!=NULL)
+ {
+ SetDlgItemText(hwndDlg,IDC_UPDATEGAMES,buf);
+ delete[] buf;
+ }
+
+ SetFocus(GetDlgItem(hwndDlg,IDOK));
+
+ return TRUE;
+ }
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+ EndDialog(hwndDlg,IDOK);
+ return TRUE;
+
+ case IDCANCEL:
+ EndDialog(hwndDlg,IDCANCEL);
+ return TRUE;
+ }
+ break;
+ }
+
+ return FALSE;
+}
+
+void UpdateMyXFireIni(LPVOID dummy) {
+ char request[1024];
+ char file[1024];
+ char file2[1024];
+ char file3[1024];
+
+ //ini pfad rausbekommen
+ FoldersGetCustomPath( XFireWorkingFolder, file, 1024, "" );
+ strcat(file,"\\");
+ strcpy(file2,file);
+ strcpy(file3,file);
+ strcat(file,"xfire_games.new");
+ strcat(file2,"xfire_games.ini");
+ strcat(file3,"xfire_games.old");
+
+ sprintf_s(request,1024,"%s%d",INI_URLREQUEST,getfilesize(file2));
+
+ if(CheckWWWContent(request))
+ {
+ if(DBGetContactSettingByte(NULL,protocolname,"dontaskforupdate",0)==1||DialogBox(hinstance,MAKEINTRESOURCE(IDD_UPDATE),NULL,DlgUpdateDialogProc)==IDOK)
+ {
+ if(GetWWWContent2(request,file,FALSE))
+ {
+ //altes backup löschen
+ remove(file3);
+ //derzeitige ini und sichern
+ rename(file2,file3);
+ //lösche .old, wenn aktiv
+ if(DBGetContactSettingByte(NULL,protocolname,"nobackupini",0))
+ remove(file3);
+ //neue aktiv schalten
+ rename(file,file2);
+
+ if(DBGetContactSettingByte(NULL,protocolname,"dontaskforupdate",0)==0) MSGBOX(Translate("The xfire_games.ini was updated."));
+ }
+ else
+ MSGBOX(Translate("Error during xfire_games Update."));
+ }
+ }
+}
+
+void UpdateMyIcons(LPVOID dummy) {
+ char request[1024];
+ char file[1024];
+ char file2[1024];
+ char file3[1024];
+
+ //ini pfad rausbekommen
+ FoldersGetCustomPath( XFireIconFolder, file, 1024, "" );
+ strcat(file,"\\");
+ strcpy(file2,file);
+ strcpy(file3,file);
+ strcat(file,"icons.new");
+ strcat(file2,"icons.dll");
+ strcat(file3,"icons.old");
+
+ sprintf_s(request,1024,"%s%d",ICO_URLREQUEST,getfilesize(file2));
+
+ if(CheckWWWContent(request))
+ {
+ if(DBGetContactSettingByte(NULL,protocolname,"dontaskforupdate",0)==1||MessageBox(NULL,Translate("There is a new Icons.dll online, do you want to update now?"),"Miranda XFire Protocol Plugin",MB_YESNO|MB_ICONQUESTION)==IDYES)
+ {
+ if(GetWWWContent2(request,file,FALSE)) {
+ //altes backup löschen
+ remove(file3);
+ //derzeitige ini und sichern
+ rename(file2,file3);
+ //lösche .old, wenn aktiv
+ if(DBGetContactSettingByte(NULL,protocolname,"nobackupini",0))
+ remove(file3);
+ //neue aktiv schalten
+ rename(file,file2);
+
+ if(DBGetContactSettingByte(NULL,protocolname,"dontaskforupdate",0)==0) MSGBOX(Translate("The Icons.dll was updated."));
+ }
+ else
+ MSGBOX(Translate("Error during Icons.dll Update."));
+ }
+ }
+} \ No newline at end of file
diff --git a/protocols/Xfire/src/iniupdater.h b/protocols/Xfire/src/iniupdater.h
new file mode 100644
index 0000000000..f89174ae7d
--- /dev/null
+++ b/protocols/Xfire/src/iniupdater.h
@@ -0,0 +1,10 @@
+//iniupdater.h by dufte
+
+#define INI_UPDATERHOST "xfireplus.com"
+#define INI_REQUEST "/xfire_games/xfire_games.php?format=miranda"
+
+
+//#define INI_URLREQUEST "http://xfireplus.com/xfire_games/xfire_games.php?format=miranda"
+#define INI_URLREQUEST "http://xfire.pro-laming.de/getini.php?fsize="
+#define INI_WHATSNEW "http://xfire.pro-laming.de/whatsnew.txt"
+#define ICO_URLREQUEST "http://xfire.pro-laming.de/getini.php?mode=ico&fsize=" \ No newline at end of file
diff --git a/protocols/Xfire/src/invitebuddypacket.cpp b/protocols/Xfire/src/invitebuddypacket.cpp
new file mode 100644
index 0000000000..f9e46cdebf
--- /dev/null
+++ b/protocols/Xfire/src/invitebuddypacket.cpp
@@ -0,0 +1,93 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "stdafx.h"
+#include "invitebuddypacket.h"
+#include "variablevalue.h"
+
+namespace xfirelib {
+ using namespace std;
+
+ InviteBuddyPacket::InviteBuddyPacket() {
+ names = new vector<string>;
+ msgs = new vector<string>;
+ }
+ InviteBuddyPacket::~InviteBuddyPacket() {
+ delete names;
+ delete msgs;
+ }
+
+ void InviteBuddyPacket::parseContent(char *buf, int length, int numberOfAtts) {
+ /* Useless.. we only receive Packet 138 for invitations
+ VariableValue val;
+ int index = 0;
+ index += val.readName( buf, index );
+ int namecount = (unsigned char)buf[index++];
+ for(int i = 0 ; i < namecount ; i++) {
+ int namelen = (unsigned char)buf[index++];
+ index++; // ignore 00
+ index += val.readValue( buf, index, namelen );
+ this->msg->push_back(string(val.getValue(),val.getValueLength()));
+ }
+ index += val.readName( buf, index );
+
+ int msgcount = (unsigned char)buf[index++];
+ for(int i = 0 ; i < msgcount ; i++) {
+ int msglen = (unsigned char)buf[index++];
+ index++; // ignore 00
+ index += val.readValue(buf,index,msglen);
+ this->msg->push_back(string(val.getValue(),val.getValueLength()));
+ }
+ */
+ }
+ int InviteBuddyPacket::getPacketContent(char *buf) {
+ int index = 0;
+ VariableValue val;
+ val.setName("name");
+ index += val.writeName(buf,index);
+ buf[index++] = names->size();
+ for(uint i = 0 ; i < names->size() ; i++) {
+ string name = names->at(i);
+ buf[index++] = name.length();
+ buf[index++] = 0;
+ memcpy(buf+index,name.c_str(),name.length());
+ index+=name.length();
+ }
+ val.setName("msg");
+ index += val.writeName(buf,index);
+ buf[index++] = msgs->size();
+ for(uint i = 0 ; i < msgs->size() ; i++) {
+ string msg = msgs->at(i);
+ buf[index++] = msg.length();
+ buf[index++] = 0;
+ memcpy(buf+index,msg.c_str(),msg.length());
+ index+=msg.length();
+ }
+ return index;
+ }
+
+ void InviteBuddyPacket::addInviteName(string name, string msg) {
+ this->names->push_back(name);
+ this->msgs->push_back(msg);
+ }
+
+
+};
diff --git a/protocols/Xfire/src/invitebuddypacket.h b/protocols/Xfire/src/invitebuddypacket.h
new file mode 100644
index 0000000000..055898d04a
--- /dev/null
+++ b/protocols/Xfire/src/invitebuddypacket.h
@@ -0,0 +1,66 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __INVITEBUDDYPACKET_H
+#define __INVITEBUDDYPACKET_H
+
+#include "xfiresendpacketcontent.h"
+#include <vector>
+#include <string>
+
+#define XFIRE_PACKET_INVITE_BUDDY 6
+
+using namespace xfirelib;
+
+namespace xfirelib {
+ using namespace std;
+
+ /**
+ * Packet Used to Invite Buddy into Contact List
+ * (Received is InviteRequestPacket)
+ */
+ class InviteBuddyPacket : public XFireSendPacketContent {
+ public:
+ InviteBuddyPacket();
+ ~InviteBuddyPacket();
+
+ XFirePacketContent* newPacket() { return new InviteBuddyPacket(); }
+
+
+ int getPacketId() { return XFIRE_PACKET_INVITE_BUDDY; }
+ int getPacketContent(char *buf);
+ int getPacketAttributeCount() { return 2; };
+ int getPacketSize() { return 1024; };
+ void parseContent(char *buf, int length, int numberOfAtts);
+
+ void addInviteName(string name, string msg);
+
+ vector<string> *names;
+ vector<string> *msgs;
+ private:
+ };
+
+};
+
+
+
+#endif
diff --git a/protocols/Xfire/src/inviterequestpacket.cpp b/protocols/Xfire/src/inviterequestpacket.cpp
new file mode 100644
index 0000000000..dc105d31ff
--- /dev/null
+++ b/protocols/Xfire/src/inviterequestpacket.cpp
@@ -0,0 +1,51 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "inviterequestpacket.h"
+#include "variablevalue.h"
+#include <string>
+
+namespace xfirelib {
+ using namespace std;
+
+ void InviteRequestPacket::parseContent(char *buf, int length, int numberOfAtts) {
+ VariableValue val;
+ int index = 0;
+ index += val.readName(buf,index);
+ index += 4; // Ignore 04 01 01 00
+ index += val.readValue(buf,index,-1,1);
+ name = string(val.getValue(),val.getValueLength());
+
+ index += val.readName(buf,index);
+ index += 4; // Ignore 04 01 01 00
+ index += val.readValue(buf,index,-1,1);
+ nick = string(val.getValue(),val.getValueLength());
+
+ index += val.readName(buf,index);
+ index += 4; // Ignore 04 01 01 00
+ index += val.readValue(buf,index,-1,1);
+ msg = string(val.getValue(),val.getValueLength());
+ }
+
+};
diff --git a/protocols/Xfire/src/inviterequestpacket.h b/protocols/Xfire/src/inviterequestpacket.h
new file mode 100644
index 0000000000..5f8bac43cb
--- /dev/null
+++ b/protocols/Xfire/src/inviterequestpacket.h
@@ -0,0 +1,60 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __INVITEREQUESTPACKET_H
+#define __INVITEREQUESTPACKET_H
+
+#include <string>
+#include "xfirerecvpacketcontent.h"
+
+#define XFIRE_PACKET_INVITE_REQUEST_PACKET 138
+
+namespace xfirelib {
+ using namespace std;
+
+ /**
+ * Received when someone invites you to his buddylist
+ * (For sending invitations see InviteBuddyPacket)
+ */
+ class InviteRequestPacket : public XFireRecvPacketContent {
+ public:
+ XFirePacketContent* newPacket() { return new InviteRequestPacket(); }
+
+
+ int getPacketId() { return XFIRE_PACKET_INVITE_REQUEST_PACKET; }
+ int getPacketContent(char *buf) { return 0;}
+ int getPacketAttributeCount() { return 3; };
+ int getPacketSize() { return 1024; };
+ void parseContent(char *buf, int length, int numberOfAtts);
+
+ string name;
+ string nick;
+ string msg;
+
+ private:
+ };
+
+};
+
+
+#endif
+
diff --git a/protocols/Xfire/src/loginfailedpacket.cpp b/protocols/Xfire/src/loginfailedpacket.cpp
new file mode 100644
index 0000000000..9d6490dfb2
--- /dev/null
+++ b/protocols/Xfire/src/loginfailedpacket.cpp
@@ -0,0 +1,38 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+
+#include "stdafx.h"
+#include "loginfailedpacket.h"
+#include "xfireparse.h"
+#include "variablevalue.h"
+
+namespace xfirelib {
+ using namespace std;
+ using namespace xfirelib;
+
+ void LoginFailedPacket::parseContent(char *buf, int length, int numberOfAtts) {
+ cout << "Login failed, incorrect username or password" << endl;
+ }
+
+};
diff --git a/protocols/Xfire/src/loginfailedpacket.h b/protocols/Xfire/src/loginfailedpacket.h
new file mode 100644
index 0000000000..20f955bc51
--- /dev/null
+++ b/protocols/Xfire/src/loginfailedpacket.h
@@ -0,0 +1,47 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __LOGINFAILEDPACKET_H
+#define __LOGINFAILEDPACKET_H
+
+#include "xfirerecvpacketcontent.h"
+#include "variablevalue.h"
+
+#define XFIRE_LOGIN_FAILED_ID 129
+
+namespace xfirelib {
+
+ class LoginFailedPacket : public XFireRecvPacketContent {
+ public:
+ XFirePacketContent* newPacket() { return new LoginFailedPacket(); }
+
+
+ int getPacketId() { return XFIRE_LOGIN_FAILED_ID; }
+ int getPacketContent(char *buf) { return 0; }
+ int getPacketAttributeCount() { return 0; };
+ int getPacketSize() { return 1024; };
+ void parseContent(char *buf, int length, int numberOfAtts);
+ };
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/loginsuccesspacket.cpp b/protocols/Xfire/src/loginsuccesspacket.cpp
new file mode 100644
index 0000000000..483c2fbb4b
--- /dev/null
+++ b/protocols/Xfire/src/loginsuccesspacket.cpp
@@ -0,0 +1,74 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "xdebug.h"
+#include "loginsuccesspacket.h"
+
+namespace xfirelib {
+
+ void LoginSuccessPacket::parseContent(char *buf, int length, int numberOfAtts) {
+
+ int read = 0;
+ for(int i = 0 ; i < numberOfAtts ; i++) {
+ VariableValue *val = new VariableValue();
+ read += val->readName(buf, read);
+ XDEBUG(( "Read Variable Name: %s\n", val->getName().c_str() ));
+ if(val->getName() == "userid") {
+ read++; // ignore 02
+ read += val->readValue(buf, read, 3);
+ read++; // ignore 00
+ XDEBUG2( "My userid: %lu\n", val->getValueAsLong() );
+ this->myuid=val->getValueAsLong();
+ } else if(val->getName() == "sid") {
+ read++; // ignore 03
+ read+=val->readValue(buf, read, 16);
+ //XDEBUG(( "My SID: %u\n", val->getValue() ));
+ } else if(val->getName() == "nick") {
+ //int lengthLength = (int)val->getValueAsLong();
+ read++; // ignore 01
+ //read+=val->readValue(buf, read, -1, 1);
+
+ unsigned int l = (unsigned char)buf[read++]; //dufte - nick wird benötigt
+ XDEBUG2( "Nick Length: %d\n", l );
+ read++;
+ read += val->readValue(buf,read,l);
+ XDEBUG2( "Nick Length: %s\n", val->getValue() );
+
+ this->nick=std::string(val->getValue(),l);
+
+ } else if(val->getName() == "status") {
+ read+=5; // ignore everything
+ } else if(val->getName() == "dlset") {
+ read+=3; // ignore everything
+ } else {
+ i = numberOfAtts;
+ // If we find something we don't know .. we stop parsing the
+ // packet.. who cares about the rest...
+ }
+ delete val;
+ }
+ }
+
+
+};
diff --git a/protocols/Xfire/src/loginsuccesspacket.h b/protocols/Xfire/src/loginsuccesspacket.h
new file mode 100644
index 0000000000..55dae54b01
--- /dev/null
+++ b/protocols/Xfire/src/loginsuccesspacket.h
@@ -0,0 +1,51 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __LOGINSUCCESSPACKET_H
+#define __LOGINSUCCESSPACKET_H
+
+#include "xfirerecvpacketcontent.h"
+#include "variablevalue.h"
+#include <string.h> // benötigten header eingefügt
+
+#define XFIRE_LOGIN_SUCCESS_ID 130
+
+namespace xfirelib {
+
+ class LoginSuccessPacket : public XFireRecvPacketContent {
+ public:
+ XFirePacketContent* newPacket() { return new LoginSuccessPacket(); }
+
+ int getPacketId() { return XFIRE_LOGIN_SUCCESS_ID; }
+ int getPacketContent(char *buf) { return 0; }
+ int getPacketAttributeCount() { return 0; };
+ int getPacketSize() { return 1024; };
+ void parseContent(char *buf, int length, int numberOfAtts);
+
+ std::string nick;
+ long myuid;
+ };
+
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/m8.h b/protocols/Xfire/src/m8.h
new file mode 100644
index 0000000000..94a25be3bf
--- /dev/null
+++ b/protocols/Xfire/src/m8.h
@@ -0,0 +1,9 @@
+#ifndef _M8_H
+#define _M8_H
+
+#include "baseProtocol.h"
+
+class Xfire_m8 : public PROTO_INTERFACE {
+};
+
+#endif \ No newline at end of file
diff --git a/protocols/Xfire/src/main.cpp b/protocols/Xfire/src/main.cpp
new file mode 100644
index 0000000000..82cf23243e
--- /dev/null
+++ b/protocols/Xfire/src/main.cpp
@@ -0,0 +1,3754 @@
+#include "stdafx.h"
+
+/*
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ *
+ * Copyright (C) 2010 by
+ * dufte <dufte@justmail.de>
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Based on J. Lawler - BaseProtocol
+ * Herbert Poul/Beat Wolf - xfirelib
+ *
+ * Miranda ICQ: the free icq client for MS Windows
+ * Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
+ *
+ */
+
+//xfire stuff
+#include "client.h"
+#include "xfirepacket.h"
+#include "loginfailedpacket.h"
+#include "otherloginpacket.h"
+#include "loginsuccesspacket.h"
+#include "messagepacket.h"
+#include "sendstatusmessagepacket.h"
+#include "sendmessagepacket.h"
+#include "invitebuddypacket.h"
+#include "sendacceptinvitationpacket.h"
+#include "senddenyinvitationpacket.h"
+#include "sendremovebuddypacket.h"
+#include "sendnickchangepacket.h"
+#include "sendgamestatuspacket.h"
+#include "sendgamestatus2packet.h"
+#include "dummyxfiregameresolver.h"
+#include "sendgameserverpacket.h"
+#include "recvstatusmessagepacket.h"
+#include "recvoldversionpacket.h"
+#include "packetlistener.h"
+#include "inviterequestpacket.h"
+#include "buddylistgames2packet.h"
+#include "dummyxfiregameresolver.h"
+#include "sendtypingpacket.h"
+#include "xfireclanpacket.h"
+#include "recvremovebuddypacket.h"
+#include "gameinfopacket.h"
+#include "claninvitationpacket.h"
+#include "xfireprefpacket.h"
+#include "searchbuddy.h"
+#include "xfirefoundbuddys.h"
+#include "getbuddyinfo.h"
+#include "buddyinfo.h"
+#include "variables.h"
+#include "passworddialog.h"
+#include "setnickname.h"
+#include "all_statusmsg.h"
+#include "processbuddyinfo.h"
+#include "recvprefspacket.h"
+#include "sendsidpacket.h"
+#include "friendsoffriendlist.h"
+#include "recvbuddychangednick.h"
+
+//miranda stuff
+#include "baseProtocol.h"
+#include "Xfire_gamelist.h"
+#include "Xfire_proxy.h"
+#include "Xfire_avatar_loader.h"
+#include "Xfire_voicechat.h"
+
+#include <stdexcept>
+
+Xfire_gamelist xgamelist;
+Xfire_voicechat voicechat;
+
+HANDLE hLogEvent;
+int bpStatus = ID_STATUS_OFFLINE;
+int previousMode;
+int OptInit(WPARAM wParam,LPARAM lParam);
+int OnDetailsInit(WPARAM wParam,LPARAM lParam);
+HANDLE hFillListEvent = 0;
+CONTACT user;
+HINSTANCE hinstance = NULL;
+int hLangpack;
+HANDLE heventXStatusIconChanged;
+HANDLE copyipport,gotoclansite,vipport,joingame,startthisgame,removefriend,blockfriend;
+int foundgames=0;
+Gdiplus::GdiplusStartupInput gdiplusStartupInput;
+ULONG_PTR gdiplusToken;
+
+//xfire preferences, wichtige variablen
+xfire_prefitem xfireconfig[XFIRE_RECVPREFSPACKET_MAXCONFIGS];
+extern xfireconfigitem xfireconfigitems[XFIRE_RECVPREFSPACKET_SUPPORTEDONFIGS];
+
+CRITICAL_SECTION modeMsgsMutex;
+CRITICAL_SECTION avatarMutex;
+CRITICAL_SECTION connectingMutex;
+
+DWORD pid=NULL; //processid des gefunden spiels
+DWORD ts2pid=NULL; // processid vom teamspeak/ventrilo
+
+HANDLE XFireAvatarFolder = NULL;
+HANDLE XFireWorkingFolder = NULL;
+HANDLE XFireIconFolder = NULL;
+HANDLE hookgamestart = NULL;
+char statusmessage[2][1024];
+BOOL sendonrecieve=FALSE;
+HANDLE hNetlib=NULL;
+pGetExtendedUdpTable _GetExtendedUdpTable=NULL;
+extern LPtsrGetServerInfo tsrGetServerInfo;
+
+//eventhandles
+HANDLE hGameDetection = CreateEvent(NULL,FALSE,FALSE,NULL);
+HANDLE hConnectionClose = CreateEvent(NULL,TRUE,FALSE,NULL);
+
+PLUGININFOEX pluginInfoEx={
+ sizeof(PLUGININFOEX),
+ "Xfire protocol",
+ PLUGIN_MAKE_VERSION(0,1,8,4),
+ "Xfire Protocol Plugin by dufte [Built: "__DATE__" "__TIME__"]",
+ "dufte",
+ "dufte@justmail.de",
+ "(c) 2012 Xfirelib by Herbert Poul, Xfire Miranda protocol plugin by dufte",
+ "http://miranda-ng.org",
+ 0,
+ // {9B8E1735-970D-4ce0-930C-A561956BDCA2}
+ { 0x9b8e1735, 0x970d, 0x4ce0, { 0x93, 0xc, 0xa5, 0x61, 0x95, 0x6b, 0xdc, 0xa2 } }
+};
+
+int FillList(WPARAM wParam, LPARAM lParam);
+HANDLE CList_AddContact(XFireContact xfc, bool InList, bool SetOnline,int clan);
+HANDLE CList_FindContact (int uid);
+void CList_MakeAllOffline();
+int RecvMessage(WPARAM wParam, LPARAM lParam);
+int SendMessage(WPARAM wParam, LPARAM lParam);
+static int UserIsTyping(WPARAM wParam, LPARAM lParam);
+HANDLE LoadGameIcon(char* g, int id, HICON* ico,BOOL onyico=FALSE,char * gamename=NULL,int*uu=NULL);
+void SetIcon(HANDLE hcontact,HANDLE hicon,int ctype=EXTRA_ICON_ADV1);
+BOOL GetAvatar(char* username,XFireAvatar* av);
+//void SetAvatar(HANDLE hContact, char* username);
+static void SetAvatar(LPVOID lparam);
+static int GetIPPort(WPARAM /*wParam*/,LPARAM lParam);
+static int GetVIPPort(WPARAM /*wParam*/,LPARAM lParam);
+int RebuildContactMenu( WPARAM wParam, LPARAM lParam );
+int doneQuery( WPARAM wParam, LPARAM lParam );
+static int GotoProfile(WPARAM wParam,LPARAM lParam);
+static int GotoProfileAct(WPARAM wParam,LPARAM lParam);
+static int GotoXFireClanSite(WPARAM wParam,LPARAM lParam);
+static int ReScanMyGames(WPARAM wParam,LPARAM lParam);
+static int SetNickDlg(WPARAM wParam,LPARAM lParam);
+static int CustomGameSetup(WPARAM wParam,LPARAM lParam);
+
+#ifndef NO_PTHREAD
+ void *gamedetectiont(void *ptr);
+ void *inigamedetectiont(void *ptr);
+ pthread_t gamedetection;
+#else
+ void inigamedetectiont(LPVOID lParam);
+ void gamedetectiont(LPVOID lparam);
+#endif
+
+static int GotoProfile2(WPARAM wParam,LPARAM lParam);
+HANDLE handlingBuddys(BuddyListEntry *entry, int clan=0,char* group=NULL,BOOL dontscan=FALSE);
+int StatusIcon(WPARAM wParam,LPARAM lParam);
+int AddtoList( WPARAM wParam, LPARAM lParam );
+int BasicSearch(WPARAM wParam,LPARAM lParam);
+int GetAvatarInfo(WPARAM wParam, LPARAM lParam); //GAIR_NOAVATAR
+static int SearchAddtoList(WPARAM wParam,LPARAM lParam);
+void CreateGroup(char*grpn,char*field); //void CreateGroup(char*grp);
+int SetAwayMsg(WPARAM wParam, LPARAM lParam);
+int GetAwayMsg(WPARAM /*wParam*/, LPARAM lParam);
+int ContactDeleted(WPARAM wParam,LPARAM /*lParam*/);
+int JoinGame(WPARAM wParam,LPARAM lParam);
+extern void Scan4Games( LPVOID lparam );
+int RemoveFriend(WPARAM wParam,LPARAM lParam);
+int BlockFriend(WPARAM wParam,LPARAM lParam);
+int GetXStatusIcon(WPARAM wParam, LPARAM lParam);
+int StartThisGame(WPARAM wParam,LPARAM lParam);
+int IconLibChanged(WPARAM wParam, LPARAM lParam);
+int SendPrefs(WPARAM wparam, LPARAM lparam);
+void SetAvatar2(LPVOID lparam);
+int ExtraListRebuild(WPARAM wparam, LPARAM lparam);
+int ExtraImageApply(WPARAM wparam, LPARAM lparam);
+
+//XFire Stuff
+using namespace xfirelib;
+
+class XFireClient : public PacketListener {
+
+ public:
+ Client* client;
+ Xfire_avatar_loader* avatarloader;
+ BOOL useutf8;
+
+ XFireClient(string username, string password,char protover,int useproxy=0,string proxyip="",int proxyport=0);
+ ~XFireClient();
+ void run();
+
+ void Status(string s);
+
+ void receivedPacket(XFirePacket *packet);
+
+ void getBuddyList();
+ void sendmsg(char*usr,char*msg);
+ void setNick(char*nnick);
+ void handlingBuddy(HANDLE handle);
+ void CheckAvatar(BuddyListEntry* entry);
+
+ private:
+ vector<string> explodeString(string s, string e);
+ string joinString(vector<string> s, int startindex, int endindex=-1, string delimiter=" ");
+ void BuddyList();
+
+ string *lastInviteRequest;
+
+ string username;
+ string password;
+ string proxyip;
+ int useproxy;
+ int proxyport;
+ BOOL connected;
+ unsigned int myuid;
+ };
+
+XFireClient* myClient=NULL;
+
+void XFireClient::CheckAvatar(BuddyListEntry* entry) {
+ //kein entry, zurück
+ if(!entry)
+ return;
+
+ //keine avatars?
+ if(DBGetContactSettingByte(NULL,protocolname,"noavatars",-1)==0)
+ {
+ //avatar gelocked?
+ if(DBGetContactSettingByte(entry->hcontact, "ContactPhoto", "Locked", -1)!=1)
+ {
+ //avatar lade auftrag übergeben
+ this->avatarloader->loadAvatar(entry->hcontact,(char*)entry->username.c_str(),entry->userid);
+ }
+ }
+}
+
+void XFireClient::handlingBuddy(HANDLE handle){
+ vector<BuddyListEntry*> *entries = client->getBuddyList()->getEntries();
+ for(uint i = 0 ; i < entries->size() ; i ++) {
+ BuddyListEntry *entry = entries->at(i);
+ if(entry->hcontact==handle)
+ {
+ handlingBuddys(entry,0,NULL);
+ break;
+ }
+ }
+ //mir_forkthread(
+}
+
+void XFireClient::setNick(char*nnick) {
+ /*if(strlen(nnick)==0)
+ return;*/
+ SendNickChangePacket nick;
+ if(this->useutf8)
+ nick.nick = ( char* )nnick;
+ else
+ nick.nick = mir_utf8encode(( char* )nnick);
+ client->send( &nick );
+}
+
+
+void XFireClient::sendmsg(char*usr,char*cmsg) {
+ SendMessagePacket msg;
+ // if(strlen(cmsg)>255)
+ // *(cmsg+255)=0;
+ msg.init(client, usr, cmsg);
+ client->send( &msg );
+ }
+
+
+ XFireClient::XFireClient(string username_,string password_,char protover,int useproxy,string proxyip,int proxyport)
+ : username(username_), password(password_) {
+ client = new Client();
+ client->setGameResolver( new DummyXFireGameResolver() );
+ client->protocolVersion=protover;
+ avatarloader = new Xfire_avatar_loader(client);
+ this->useproxy=useproxy;
+ this->proxyip=proxyip;
+ this->proxyport=proxyport;
+ useutf8=FALSE;
+
+ avatarloader=new Xfire_avatar_loader(client);
+
+ lastInviteRequest = NULL;
+ connected = FALSE;
+ }
+
+ XFireClient::~XFireClient() {
+ if(client!=NULL) {
+ client->disconnect();
+ delete client;
+ }
+ if(avatarloader) {
+ delete avatarloader;
+ avatarloader=NULL;
+ }
+ if(lastInviteRequest!=NULL) delete lastInviteRequest;
+ }
+
+ void XFireClient::run() {
+ client->connect(username,password,useproxy,proxyip,proxyport);
+ client->addPacketListener(this);
+ }
+
+ void XFireClient::Status(string s) {
+ //da bei xfire statusmsg nur 100bytes länge unterstützt werden, wird gecutted
+ if(!client->gotBudduyList)
+ return;
+
+ if(s.length()>100)
+ {
+ char* temp=(char*)s.c_str();
+ *(temp+100)=0;
+ }
+ SendStatusMessagePacket *packet = new SendStatusMessagePacket();
+
+ if(myClient->useutf8)
+ packet->awaymsg = s.c_str();
+ else
+ packet->awaymsg = mir_utf8encode(s.c_str());
+
+ client->send( packet );
+ delete packet;
+ }
+
+ void XFireClient::receivedPacket(XFirePacket *packet) {
+ XFirePacketContent *content = packet->getContent();
+
+ switch(content->getPacketId())
+ {
+ /*case XFIRE_RECVBUDDYCHANGEDNICK:
+ {
+ RecvBuddyChangedNick *changednick = (RecvBuddyChangedNick*)content;
+ if(changednick) {
+ handlingBuddys((BuddyListEntry*)changednick->entry,0,NULL);
+ }
+ break;
+ }*/
+ //Konfigpacket empfangen
+ case XFIRE_RECVPREFSPACKET:
+ {
+ //Konfigarray leeren
+ memset(&xfireconfig,0,sizeof(xfire_prefitem)*XFIRE_RECVPREFSPACKET_MAXCONFIGS);
+ RecvPrefsPacket *config = (RecvPrefsPacket*)content;
+ //konfigs in array speichern
+ if(config!=NULL)
+ {
+ //ins preferenes array sichern
+ for(int i=0;i<XFIRE_RECVPREFSPACKET_MAXCONFIGS;i++)
+ {
+ xfireconfig[i]=config->config[i];
+ }
+ //datenbank einträge durchführen
+ for(int i=0;i<XFIRE_RECVPREFSPACKET_SUPPORTEDONFIGS;i++)
+ {
+ char temp=1;
+ if(xfireconfig[xfireconfigitems[i].xfireconfigid].wasset==1)
+ {
+ temp=0;
+ }
+ DBWriteContactSettingByte(NULL,protocolname,xfireconfigitems[i].dbentry,temp);
+ }
+ }
+ break;
+ }
+ case XFIRE_FOUNDBUDDYS_ID:
+ {
+ PROTOSEARCHRESULT psr;
+ ZeroMemory(&psr, sizeof(psr));
+ psr.cbSize = sizeof(psr);
+
+ XFireFoundBuddys *fb = (XFireFoundBuddys*)content;
+ for(uint i = 0 ; i < fb->usernames->size() ; i++) {
+ if((char*)fb->usernames->at(i).c_str()!=NULL)
+ psr.nick = (char*)fb->usernames->at(i).c_str();
+ if((char*)fb->fname->at(i).c_str()!=NULL)
+ psr.firstName = (char*)fb->fname->at(i).c_str();
+ if((char*)fb->lname->at(i).c_str()!=NULL)
+ psr.lastName = (char*)fb->lname->at(i).c_str();
+ ProtoBroadcastAck(protocolname, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE) 1, (LPARAM) & psr);
+ }
+
+ ProtoBroadcastAck(protocolname, NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
+ break;
+ }
+ case XFIRE_BUDDYINFO:
+ {
+ BuddyInfoPacket *buddyinfo = (BuddyInfoPacket*)content;
+ BuddyListEntry *entry = client->getBuddyList()->getBuddyById( buddyinfo->userid );
+
+ //wenn die uid die gleiche wie die eigene ist, dann avatar auch selbst zuweisen
+ if(buddyinfo->userid==this->myuid) {
+ ProcessBuddyInfo(buddyinfo,NULL,"myxfireavatar");
+ }
+
+ if(entry)
+ ProcessBuddyInfo(buddyinfo,entry->hcontact,(char*)entry->username.c_str());
+
+ break;
+ }
+ case XFIRE_CLANINVITATION_ID:
+ {
+ ClanInvitationPacket *claninv = (ClanInvitationPacket*)content;
+ for(int i=0;i<claninv->numberOfInv;i++)
+ {
+ char msg[XFIRE_MAX_STATIC_STRING_LEN];
+ sprintf(msg,Translate("%s (Nickname: %s) has invited you to join the %s clan. Message: %s%sPlease go to the XFireclan-Site to accept the Invitation."),claninv->invitefromusername[i].c_str(),
+ claninv->invitefrom[i].c_str(),
+ claninv->clanname[i].c_str(),
+ claninv->invitemsg[i].c_str(),"\n");
+ MSGBOX(msg);
+ }
+ break;
+ }
+ case XFIRE_GAMEINFO_ID:
+ {
+ GameInfoPacket *gameinfo = (GameInfoPacket*)content;
+ for(uint i = 0 ; i < gameinfo->sids->size() ; i++) {
+ BuddyListEntry *entry = client->getBuddyList()->getBuddyBySid( gameinfo->sids->at(i) );
+ if(entry){
+ entry->gameinfo = gameinfo->gameinfo->at(i);
+ handlingBuddys(entry,0,NULL);
+ }
+ }
+ break;
+ }
+ case XFIRE_RECVREMOVEBUDDYPACKET:
+ {
+ RecvRemoveBuddyPacket *remove = (RecvRemoveBuddyPacket*)content;
+ CallService( MS_DB_CONTACT_DELETE, (WPARAM) remove->handle, 1 );
+ break;
+ }
+ case XFIRE_BUDDYS_NAMES_ID:
+ {
+ //status nachricht nach der buddylist senden
+ client->gotBudduyList=TRUE;
+ if(sendonrecieve)
+ {
+ if(myClient!=NULL)
+ {
+ if(myClient->client->connected)
+ {
+ //
+ if (bpStatus == ID_STATUS_AWAY)
+ myClient->Status(statusmessage[1]);
+ else
+ myClient->Status(statusmessage[0]);
+ }
+ }
+ sendonrecieve=FALSE;
+ }
+ sendonrecieve=FALSE;
+
+/* GetBuddyInfo buddyinfo;
+
+ vector<BuddyListEntry*> *entries = client->getBuddyList()->getEntries();
+ for(uint i = 0 ; i < entries->size() ; i ++) {
+ BuddyListEntry *entry = entries->at(i);
+ handlingBuddys(entry,0,NULL);
+ }*/
+ break;
+ }
+ /* case XFIRE_CLAN_BUDDYS_NAMES_ID:
+ {
+ vector<BuddyListEntry*> *entries = client->getBuddyList()->getEntriesClan();
+
+ char temp[255];
+ char * dummy;
+ ClanBuddyListNamesPacket *clan = (ClanBuddyListNamesPacket*)content;
+ sprintf(temp,"Clan_%d",clan->clanid);
+
+ DBVARIANT dbv;
+ if(!DBGetContactSetting(NULL,protocolname,temp,&dbv))
+ {
+ dummy=dbv.pszVal;
+ }
+ else
+ dummy=NULL;
+
+ for(uint i = 0 ; i < entries->size() ; i ++) {
+ BuddyListEntry *entry = entries->at(i);
+ if(entry->clanid==clan->clanid) {
+ handlingBuddys(entry,clan->clanid,dummy);
+ }
+ }
+ break;
+ }*/
+ case XFIRE_FRIENDS_BUDDYS_NAMES_ID:
+ {
+ for(uint i = 0 ; i < ((FriendsBuddyListNamesPacket*)content)->userids->size() ; i++) {
+ BuddyListEntry *entry = client->getBuddyList()->getBuddyById( ((FriendsBuddyListNamesPacket*)content)->userids->at(i) );
+ if(entry) {
+ char fofname[128]="Friends of Friends Playing";
+ DBVARIANT dbv;
+ //gruppennamen überladen
+ if(!DBGetContactSetting(NULL,protocolname,"overload_fofgroupname",&dbv))
+ {
+ strcpy_s(fofname,128,dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+ CreateGroup(Translate(fofname),"fofgroup");
+ HANDLE hc=handlingBuddys(entry,-1,Translate(fofname));
+ if(hc)
+ {
+ CheckAvatar(entry);
+ DBWriteContactSettingByte(hc,protocolname,"friendoffriend",1);
+ }
+ }
+ }
+ break;
+ }
+ /*case XFIRE_BUDDYS_ONLINE_ID:
+ {
+ for(uint i = 0 ; i < ((BuddyListOnlinePacket*)content)->userids->size() ; i++) {
+ BuddyListEntry *entry = client->getBuddyList()->getBuddyById( ((BuddyListOnlinePacket*)content)->userids->at(i) );
+ if(entry){
+ handlingBuddys(entry,0,NULL);
+ }
+ }
+ break;
+ }*/
+ /*case XFIRE_RECV_STATUSMESSAGE_PACKET_ID:
+ {
+ for(uint i=0;i<((RecvStatusMessagePacket*)content)->sids->size();i++)
+ {
+ BuddyListEntry *entry = this->client->getBuddyList()->getBuddyBySid( ((RecvStatusMessagePacket*)content)->sids->at(i) );
+ if(entry) //crashbug entfernt
+ setBuddyStatusMsg(entry,entry->statusmsg); //auf eine funktion reduziert, verringert cpuauslastung und beseitigt das
+ //das problem der fehlenden statusmsg
+ //handlingBuddys(entry,0,NULL);
+ }
+ break;
+ }*/
+ case XFIRE_BUDDYS_GAMES_ID:
+ {
+ vector<char *> *sids=NULL; //dieses array dient zu zwischensicherung von unbekannten sids
+ for(uint i=0;i<((BuddyListGamesPacket*)content)->sids->size();i++)
+ {
+ BuddyListEntry *entry = this->client->getBuddyList()->getBuddyBySid( ((BuddyListGamesPacket*)content)->sids->at(i) );
+ if(entry!=NULL)
+ {
+ //wir haben einen unbekannten user
+ if(entry->username.length()==0)
+ {
+ //sid array ist noch nicht init
+ if(sids==NULL)
+ {
+ sids = new vector<char *>;
+ }
+ //kopie der sid anlegen
+ char *sid = new char[16];
+ memcpy(sid,((BuddyListGamesPacket*)content)->sids->at(i),16);
+ //ab ins array damit
+ sids->push_back(sid);
+ }
+ else
+ {
+ if(entry->game==0&&
+ entry->hcontact!=0&&
+ DBGetContactSettingByte(entry->hcontact,protocolname,"friendoffriend",0)==1)
+ {
+ DBWriteContactSettingWord(entry->hcontact,protocolname,"Status",ID_STATUS_OFFLINE);
+ //CallService( MS_DB_CONTACT_DELETE, (WPARAM) entry->hcontact, 0);
+ }
+ else
+ {
+ handlingBuddys(entry,0,NULL);
+ }
+ }
+ }
+ }
+ //sid anfragen nur senden, wenn das sids array init wurde
+ if(sids)
+ {
+ SendSidPacket sp;
+ sp.sids=sids;
+ client->send( &sp );
+ delete sids;
+ }
+ break;
+ }
+ case XFIRE_BUDDYS_GAMES2_ID:
+ {
+ for(uint i=0;i<((BuddyListGames2Packet*)content)->sids->size();i++)
+ {
+ BuddyListEntry *entry = this->client->getBuddyList()->getBuddyBySid( ((BuddyListGames2Packet*)content)->sids->at(i) );
+ if(entry!=NULL) handlingBuddys(entry,0,NULL);
+ }
+ break;
+ }
+ case XFIRE_PACKET_INVITE_REQUEST_PACKET: //friend request
+ {
+ InviteRequestPacket *invite = (InviteRequestPacket*)content;
+
+ //nur nich blockierte buddy's durchlassen
+ if(!DBGetContactSettingByte(NULL,"XFireBlock",(char*)invite->name.c_str(),0))
+ {
+ XFireContact xfire_newc;
+ xfire_newc.username=(char*)invite->name.c_str();
+ xfire_newc.nick=(char*)invite->nick.c_str();
+ xfire_newc.id=0;
+
+ HANDLE handle=CList_AddContact(xfire_newc,TRUE,TRUE,0);
+
+ if(handle) { // invite nachricht mitsenden
+ string str;
+ CCSDATA ccs;
+ PROTORECVEVENT pre;
+
+ str=(char*)invite->msg.c_str();
+
+ time_t t = time(NULL);
+ ccs.szProtoService = PSR_MESSAGE;
+ ccs.hContact = handle;
+ ccs.wParam = 0;
+ ccs.lParam = (LPARAM) & pre;
+ pre.flags = 0;
+ pre.timestamp = t;
+ pre.szMessage = (char*)mir_utf8decode((char*)str.c_str(),NULL);
+ //invite nachricht konnte nicht zugewiesen werden?!?!?!
+ if(!pre.szMessage)
+ pre.szMessage=(char*)str.c_str();
+ pre.lParam = 0;
+ CallService(MS_PROTO_CHAINRECV, 0, (LPARAM) &ccs);
+ }
+ }
+ else
+ {
+ SendDenyInvitationPacket deny;
+ deny.name = invite->name;
+ client->send( &deny );
+ }
+ break;
+ }
+ case XFIRE_CLAN_PACKET:
+ {
+ char temp[100];
+ XFireClanPacket *clan = (XFireClanPacket*)content;
+
+ for(int i=0;i<clan->count;i++)
+ {
+ sprintf(temp,"Clan_%d",clan->clanid[i]);
+ DBWriteContactSettingTString(NULL, protocolname, temp, (char*)clan->name[i].c_str());
+
+ sprintf(temp,"ClanUrl_%d",clan->clanid[i]);
+ DBWriteContactSettingTString(NULL, protocolname, temp, (char*)clan->url[i].c_str());
+
+ if(!DBGetContactSettingByte(NULL,protocolname,"noclangroups",0)) {
+ CreateGroup((char*)clan->name[i].c_str(),"mainclangroup");
+ }
+ }
+ break;
+ }
+ case XFIRE_LOGIN_FAILED_ID:
+ MSGBOXE(Translate("Login failed."));
+ SetStatus(ID_STATUS_OFFLINE,NULL);
+ break;
+ case XFIRE_LOGIN_SUCCESS_ID: //login war erfolgreich
+ {
+ LoginSuccessPacket *login = (LoginSuccessPacket*)content;
+ char * temp = mir_utf8decode((char*)login->nick.c_str(),NULL);
+ //nick speichern
+ DBWriteContactSettingString(NULL,protocolname,"Nick",temp);
+ //uid speichern
+ DBWriteContactSettingDword(NULL,protocolname,"myuid",login->myuid);
+ this->myuid=login->myuid;
+ //avatar auslesen
+ GetBuddyInfo* buddyinfo=new GetBuddyInfo();
+ buddyinfo->userid=login->myuid;
+ mir_forkthread(SetAvatar2,(LPVOID)buddyinfo);
+ break;
+ }
+
+ case XFIRE_RECV_OLDVERSION_PACKET_ID:
+ {
+ RecvOldVersionPacket *version = (RecvOldVersionPacket*)content;
+ char temp[255];
+
+ if((unsigned int)client->protocolVersion<(unsigned int)version->newversion)
+ {
+ DBWriteContactSettingByte(NULL,protocolname,"protover",version->newversion);
+ //recprotoverchg
+ if(DBGetContactSettingWord(NULL,protocolname,"recprotoverchg",0)==0)
+ {
+ sprintf_s(temp,255,Translate("The protocol version is too old. Changed current version from %d to %d. You can reconnect now."),client->protocolVersion,version->newversion);
+ MSGBOXE(temp);
+ }
+ else
+ {
+ SetStatus(ID_STATUS_RECONNECT,NULL);
+ return;
+ }
+ }
+ else
+ {
+ sprintf_s(temp,255,Translate("The protocol version is too old. Cannot detect a new version number."));
+ MSGBOXE(temp);
+ SetStatus(ID_STATUS_OFFLINE,NULL);
+ }
+ break;
+ }
+
+ case XFIRE_OTHER_LOGIN:
+ MSGBOXE(Translate("Someone loged in with your account.disconnect."));
+ SetStatus(ID_STATUS_OFFLINE,NULL);
+ break;
+
+ //ne nachricht für mich, juhu
+ case XFIRE_MESSAGE_ID: {
+ string str;
+ CCSDATA ccs;
+ PROTORECVEVENT pre;
+
+ if( (( MessagePacket*)content)->getMessageType() == 0){
+ BuddyListEntry *entry = client->getBuddyList()->getBuddyBySid( ((MessagePacket*)content)->getSid() );
+ if(entry!=NULL)
+ {
+ str=((MessagePacket*)content)->getMessage();
+ time_t t = time(NULL);
+ ccs.szProtoService = PSR_MESSAGE;
+ ccs.hContact = entry->hcontact;
+ ccs.wParam = 0;
+ ccs.lParam = (LPARAM) & pre;
+ pre.flags = 0;
+ pre.timestamp = t;
+ if(this->useutf8)
+ {
+ pre.szMessage = (char*)str.c_str();
+ pre.flags = PREF_UTF;
+ }
+ else
+ pre.szMessage = (char*)mir_utf8decode((char*)str.c_str(),NULL);
+ pre.lParam = 0;
+
+ CallService(MS_PROTO_CONTACTISTYPING,(WPARAM)ccs.hContact,PROTOTYPE_CONTACTTYPING_OFF);
+ CallService(MS_PROTO_CHAINRECV, 0, (LPARAM) &ccs);
+
+ }
+ }
+ else if( (( MessagePacket*)content)->getMessageType() == 3) {
+ BuddyListEntry *entry = client->getBuddyList()->getBuddyBySid( ((MessagePacket*)content)->getSid() );
+ if(entry!=NULL)
+ {
+ CallService(MS_PROTO_CONTACTISTYPING,(WPARAM)entry->hcontact,5);
+ }
+ }
+
+ break;
+ }
+
+ //refresh buddy's
+ /* if(content->getPacketId()==XFIRE_RECV_STATUSMESSAGE_PACKET_ID||
+ content->getPacketId()==XFIRE_BUDDYS_GAMES_ID||
+ content->getPacketId()==XFIRE_BUDDYS_GAMES2_ID)
+ CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)-1, (LPARAM)FU_TBREDRAW | FU_FMREDRAW);*/
+ }
+
+ //
+ }
+
+//=====================================================
+
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+{
+ return &pluginInfoEx;
+}
+
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_PROTOCOL, MIID_LAST};
+
+//=====================================================
+// Unloads plugin
+//=====================================================
+
+extern "C" __declspec(dllexport) int Unload(void)
+{
+ //urlprefix raushaun
+ if(ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE))
+ CallService(MS_ASSOCMGR_REMOVEURLTYPE, 0, (LPARAM)"xfire:");
+
+ //gamedetetion das dead signal geben
+ SetEvent(hGameDetection);
+
+#ifndef NO_PTHREAD
+ pthread_cancel (gamedetection);
+ pthread_win32_process_detach_np ();
+#endif
+
+ DeleteCriticalSection(&modeMsgsMutex);
+ DeleteCriticalSection(&connectingMutex);
+ DeleteCriticalSection(&avatarMutex);
+
+ Gdiplus::GdiplusShutdown(gdiplusToken);
+
+ return 0;
+}
+
+void __stdcall XFireLog( const char* fmt, ... )
+{
+ va_list vararg;
+ va_start( vararg, fmt );
+ char* str = ( char* )alloca( 32000 );
+ mir_vsnprintf( str, 32000, fmt, vararg );
+ va_end( vararg );
+
+ CallService( MS_NETLIB_LOG, ( WPARAM )hNetlib, ( LPARAM )str );
+}
+
+//=====================================================
+// WINAPI DllMain
+//=====================================================
+
+BOOL WINAPI DllMain(HINSTANCE hinst,DWORD fdwReason,LPVOID lpvReserved)
+{
+ hinstance = hinst;
+ //AtlAxWinInit();
+ return TRUE;
+}
+
+//suche nach ini und danach starte gamedetection thread
+void StartIniUpdateAndDetection(LPVOID dummy)
+{
+ EnterCriticalSection(&connectingMutex);
+
+ //ini/ico updater, nur wenn aktiv
+ if(DBGetContactSettingByte(NULL,protocolname,"autoiniupdate",0))
+ UpdateMyXFireIni(NULL);
+ if(DBGetContactSettingByte(NULL,protocolname,"autoicodllupdate",0))
+ UpdateMyIcons(NULL);
+
+#ifndef NO_PTHREAD
+ void* (*func)(void*) = &inigamedetectiont;
+ pthread_create( &gamedetection, NULL, func , NULL);
+#else
+ mir_forkthread(inigamedetectiont,NULL);
+#endif
+
+ LeaveCriticalSection(&connectingMutex);
+}
+
+int UrlCall(WPARAM wparam,LPARAM lparam) {
+ //lparam!=0?
+ if(lparam) {
+ //nach dem doppelpunkt suchen
+ char*type=strchr((char*)lparam,':');
+ //gefunden, dann anch fragezeichen suchen
+ if(type)
+ {
+ type++;
+ char*q=strchr(type,'?');
+ //gefunden? dann urltype ausschneiden
+ if(q)
+ {
+ //abschneiden
+ *q=0;
+ //ein addfriend url request?
+ if(strcmp("add_friend",type)==0)
+ {
+ q++;
+ //nach = suchen
+ char*g=strchr(q,'=');
+ //gefunden? dann abschneiden
+ if(g)
+ {
+ *g=0;
+ g++;
+ //user parameter?
+ if(strcmp("user",q)==0)
+ {
+ //tempbuffer für die frage and en user
+ char temp[100];
+
+ if(strlen(g)>25) //zugroße abschneiden
+ *(g+25)=0;
+
+ sprintf_s(temp,100,Translate("Do you really want to add %s to your friend list?"),g);
+ //Nutzer vorher fragen, ob er wirklich user xyz adden möchte
+ if(MessageBoxA(NULL,temp,"Miranda XFire Protocol Plugin",MB_YESNO|MB_ICONQUESTION)==IDYES)
+ {
+ if(myClient!=NULL)
+ {
+ if(myClient->client->connected)
+ {
+ InviteBuddyPacket invite;
+ invite.addInviteName(g, Translate("Add me to your friends list."));
+ myClient->client->send(&invite);
+ }
+ else
+ MSGBOXE(Translate("XFire is not connected."));
+ }
+ else
+ MSGBOXE(Translate("XFire is not connected."));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ }
+ return 0;
+}
+
+//wenn alle module geladen sind
+static int OnSystemModulesLoaded(WPARAM wParam,LPARAM lParam)
+{
+ char servicefunction[100];
+
+ /*NETLIB***********************************/
+ NETLIBUSER nlu;
+ ZeroMemory(&nlu, sizeof(nlu));
+ nlu.cbSize = sizeof(nlu);
+ nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS;
+ nlu.szSettingsModule = protocolname;
+ nlu.szDescriptiveName = "XFire server connection";
+ hNetlib = (HANDLE) CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM) & nlu);
+ /*NETLIB***********************************/
+
+ HookEvent(ME_USERINFO_INITIALISE, OnDetailsInit);
+ HookEvent(ME_DB_CONTACT_DELETED, ContactDeleted);
+
+ //hook das queryplugin
+ HookEvent("GameServerQuery/doneQuery" , doneQuery);
+
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, PS_SETAWAYMSG);
+ CreateServiceFunction(servicefunction, SetAwayMsg);
+
+ /*NETLIBUSER nlu;
+ ZeroMemory(&nlu, sizeof(nlu));
+ nlu.cbSize = sizeof(nlu);
+ nlu.flags = NUF_NOHTTPSOPTION;
+ nlu.szSettingsModule = protocolname;
+ nlu.szDescriptiveName = "XFire Gamedetectionthread";
+ hNetlibUser = (HANDLE) CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM) & nlu);*/
+
+
+ // Variables support
+ if (ServiceExists(MS_VARS_REGISTERTOKEN))
+ {
+ TOKENREGISTER tr = {0};
+ tr.cbSize = sizeof(TOKENREGISTER);
+ tr.memType = TR_MEM_MIRANDA;
+ tr.flags = TRF_FREEMEM | TRF_PARSEFUNC | TRF_FIELD;
+
+ tr.tszTokenString = _T("xfiregame");
+ tr.parseFunction = Varxfiregame;
+ tr.szHelpText = "XFire\tCurrent Game";
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+
+ tr.tszTokenString = _T("myxfiregame");
+ tr.parseFunction = Varmyxfiregame;
+ tr.szHelpText = "XFire\tMy Current Game";
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+
+ tr.tszTokenString = _T("xfireserverip");
+ tr.parseFunction = Varxfireserverip;
+ tr.szHelpText = "XFire\tServerIP";
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+
+ tr.tszTokenString = _T("myxfireserverip");
+ tr.parseFunction = Varmyxfireserverip;
+ tr.szHelpText = "XFire\tMy Current ServerIP";
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+
+ tr.tszTokenString = _T("xfirevoice");
+ tr.parseFunction = Varxfirevoice;
+ tr.szHelpText = "XFire\tVoice";
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+
+ tr.tszTokenString = _T("myxfirevoice");
+ tr.parseFunction = Varmyxfirevoice;
+ tr.szHelpText = "XFire\tMy Current Voice";
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+
+ tr.tszTokenString = _T("xfirevoiceip");
+ tr.parseFunction = Varxfirevoiceip;
+ tr.szHelpText = "XFire\tVoice ServerIP";
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+
+ tr.tszTokenString = _T("myxfirevoiceip");
+ tr.parseFunction = Varmyxfirevoiceip;
+ tr.szHelpText = "XFire\tMy Voice ServerIP";
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+
+ }
+
+ //File Association Manager support
+ if(ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE))
+ {
+ AssocMgr_AddNewUrlType("xfire:",Translate("Xfire Link Protocol"),hinstance,IDI_TM,XFIRE_URLCALL,0);
+ }
+
+ //sound einfügen
+ SkinAddNewSoundEx(Translate("xfirebstartgame"),protocolname,Translate("Buddy start a game"));
+
+ //hook für mbot einfügen, nur wenn mbot option aktiv
+ if(DBGetContactSettingByte(NULL,protocolname,"mbotsupport",0))
+ HookEvent(XFIRE_INGAMESTATUSHOOK, mBotNotify);
+
+ //init der extraicons wenn service vorhanden
+ /*if(ServiceExists(MS_EXTRAICON_REGISTER))
+ {
+ extraiconGAME=ExtraIcon_Register("Game Icon","Xfire game icons.","XFIRE_main",RebuildIcons,ApplyIcons);
+ extraiconGAME=ExtraIcon_Register("Voice Icon","Xfire voice icons.","XFIRE_main");
+ }*/
+
+ //initialisiere teamspeak und co detection
+ voicechat.initVoicechat();
+
+ mir_forkthread(StartIniUpdateAndDetection,NULL);
+
+ return 0;
+}
+
+//=====================================================
+// Called when plugin is loaded into Miranda
+//=====================================================
+
+/*placebo funktionen*/
+/*PROTO_INTERFACE* xfireProtoInit( const char* pszProtoName, const TCHAR* tszUserName )
+{
+ Xfire_m8 m8=new Xfire_m8();
+ return m8;
+}
+/*placebo funktionen*/
+/*static int xfireProtoUninit( void* ppro )
+{
+ return 0;
+}
+
+*/
+
+int ExtraListRebuild(WPARAM wparam, LPARAM lparam)
+{
+ //für alle gameicons ein neues handle setzen
+ return xgamelist.iconmngr.resetIconHandles();
+}
+
+int ExtraImageApply(WPARAM wparam, LPARAM lparam)
+{
+ HANDLE hContact=(HANDLE)wparam;
+ // TODO: maybe need to fix extra icons
+ char *szProto;
+ szProto = ( char* ) CallService( MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
+ if ( szProto != NULL && !lstrcmpiA( szProto, protocolname ) && DBGetContactSettingWord(hContact, protocolname, "Status", ID_STATUS_OFFLINE)!=ID_STATUS_OFFLINE) {
+ int gameid=DBGetContactSettingWord(hContact, protocolname, "GameId", 0);
+ int gameid2=DBGetContactSettingWord(hContact, protocolname, "VoiceId", 0);
+
+ if(gameid!=0)
+ {
+ SetIcon(hContact,xgamelist.iconmngr.getGameIconHandle(gameid));
+ }
+ if(gameid2!=0)
+ {
+ SetIcon(hContact,xgamelist.iconmngr.getGameIconHandle(gameid2),EXTRA_ICON_ADV2);
+ }
+ }
+ return 0;
+}
+
+
+
+extern "C" __declspec(dllexport) int Load(void)
+{
+ mir_getLP(&pluginInfoEx);
+
+ InitializeCriticalSection(&modeMsgsMutex);
+ InitializeCriticalSection(&connectingMutex);
+ InitializeCriticalSection(&avatarMutex);
+
+ Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
+
+ //void* init = GetProcAddress(LoadLibrary("atl"),"AtlAxWinInit"); _asm call init;
+
+ //keine protoversion in der db, dann wohl der erste start von xfire
+ if(DBGetContactSettingByte(NULL,protocolname,"protover",0)==0)
+ {
+ DBWriteContactSettingByte(NULL,protocolname,"protover",0x84);
+ DBWriteContactSettingWord(NULL,protocolname,"avatarloadlatency",1000);
+ DBWriteContactSettingByte(NULL,protocolname,"gameico",0);
+ DBWriteContactSettingByte(NULL,protocolname,"voiceico",1);
+ DBWriteContactSettingByte(NULL,protocolname,"specialavatarload",1);
+ DBWriteContactSettingByte(NULL,protocolname,"xfiresitegameico",1);
+ DBWriteContactSettingByte(NULL,protocolname,"recprotoverchg",1);
+
+ if(MessageBoxA(NULL,Translate("It seems that is the first time you use this plugin. Do you want to automatically download the latest available xfire_games.ini und icons.dll?\r\nWithout the ini xfire cant detect any games on your computer."),"Miranda XFire Protocol Plugin",MB_YESNO|MB_ICONQUESTION)==IDYES)
+ {
+ DBWriteContactSettingByte(NULL,protocolname,"autoiniupdate",1);
+ DBWriteContactSettingByte(NULL,protocolname,"autoicodllupdate",1);
+ }
+ }
+
+
+ XDEBUGS("-----------------------------------------------------\n");
+
+ //statusmessages setzen
+ strcpy(statusmessage[0],"");
+ strcpy(statusmessage[1],"(AFK) Away from Keyboard");
+
+ char servicefunction[100];
+
+ HookEvent(ME_OPT_INITIALISE, OptInit);
+ HookEvent(ME_SYSTEM_MODULESLOADED, OnSystemModulesLoaded);
+
+ PROTOCOLDESCRIPTOR pd = {0};
+ pd.cbSize = PROTOCOLDESCRIPTOR_V3_SIZE;
+ pd.szName = protocolname;
+ pd.type = PROTOTYPE_PROTOCOL;
+ CallService(MS_PROTO_REGISTERMODULE,0,(LPARAM)&pd);
+
+
+ hLogEvent=CreateHookableEvent("XFireProtocol/Log");
+
+ CList_MakeAllOffline();
+
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, PS_GETCAPS);
+ CreateServiceFunction(servicefunction, GetCaps);
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, PS_GETNAME);
+ CreateServiceFunction(servicefunction, GetName);
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, PS_LOADICON);
+ CreateServiceFunction(servicefunction, TMLoadIcon);
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, PS_SETSTATUS);
+ CreateServiceFunction(servicefunction, SetStatus);
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, PS_GETSTATUS);
+ CreateServiceFunction(servicefunction, GetStatus);
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, PSS_ADDED);
+ CreateServiceFunction(servicefunction, AddtoList);
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, PS_ADDTOLIST);
+ CreateServiceFunction(servicefunction, SearchAddtoList);
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, PS_GETAVATARINFO);
+ CreateServiceFunction(servicefunction, GetAvatarInfo);
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, PS_GETMYAVATAR);
+ CreateServiceFunction(servicefunction, GetMyAvatar);
+
+ HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, ExtraImageApply);
+ HookEvent(ME_CLIST_EXTRA_LIST_REBUILD, ExtraListRebuild);
+
+ //erstell eine hook für andere plugins damit diese nachprüfen können, ab wann jemand ingame ist oer nicht
+ hookgamestart = CreateHookableEvent(XFIRE_INGAMESTATUSHOOK);
+
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, PS_BASICSEARCH);
+ CreateServiceFunction(servicefunction, BasicSearch);
+
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, PSS_MESSAGE);
+ CreateServiceFunction( servicefunction, SendMessage );
+
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, PSS_USERISTYPING);
+ CreateServiceFunction( servicefunction, UserIsTyping );
+
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, PSR_MESSAGE);
+ CreateServiceFunction( servicefunction, RecvMessage );
+
+ strcpy(servicefunction, XFIRE_URLCALL);
+ CreateServiceFunction( servicefunction, UrlCall );
+
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, PSS_GETAWAYMSG);
+ CreateServiceFunction( servicefunction, GetAwayMsg );
+
+ strcpy(servicefunction, XFIRE_SET_NICK);
+ CreateServiceFunction( servicefunction, SetNickName );
+
+ strcpy(servicefunction, XFIRE_SEND_PREFS);
+ CreateServiceFunction( servicefunction, SendPrefs );
+
+ //für mtipper, damit man das statusico übertragen kann
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, "/GetXStatusIcon");
+ CreateServiceFunction( servicefunction, GetXStatusIcon );
+
+ char AvatarsFolder[MAX_PATH]= "";
+ CallService(MS_DB_GETPROFILEPATH, (WPARAM) MAX_PATH, (LPARAM)AvatarsFolder);
+ strcat(AvatarsFolder, "\\");
+ strcat(AvatarsFolder, "XFire");
+ XFireWorkingFolder = FoldersRegisterCustomPath(protocolname, "Working Folder", AvatarsFolder);
+ XFireIconFolder = FoldersRegisterCustomPath(protocolname, "Game Icon Folder", AvatarsFolder);
+ strcat(AvatarsFolder, "\\Avatars");
+ XFireAvatarFolder = FoldersRegisterCustomPath(protocolname, "Avatars", AvatarsFolder);
+
+ //kein folders plugin, verzeichnisse anlegen
+ if (!ServiceExists(MS_FOLDERS_REGISTER_PATH)) {
+ CreateDirectory("XFire",NULL);
+ CreateDirectory("XFire\\Avatars",NULL);
+ }
+
+ //erweiterte Kontextmenüpunkte
+ CLISTMENUITEM mi = { 0 };
+ memset(&mi,0,sizeof(CLISTMENUITEM));
+ mi.cbSize = sizeof( mi );
+ mi.pszPopupName = protocolname;
+
+ //gotoprofilemenüpunkt
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, "GotoProfile");
+ CreateServiceFunction(servicefunction,GotoProfile);
+ mi.pszService = servicefunction;
+ mi.position = 500090000;
+ mi.pszContactOwner=protocolname;
+ mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
+ mi.pszName = LPGEN("&XFire Online Profile");
+ Menu_AddContactMenuItem(&mi);
+
+ //gotoxfireclansitemenüpunkt
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, "GotoXFireClanSite");
+ CreateServiceFunction(servicefunction,GotoXFireClanSite);
+ mi.pszService = servicefunction;
+ mi.position = 500090000;
+ mi.pszContactOwner=protocolname;
+ mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
+ mi.pszName = LPGEN("XFire &Clan Site");
+ gotoclansite=Menu_AddContactMenuItem(&mi);
+
+ //kopiermenüpunkt
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, "GetIPPort");
+ CreateServiceFunction(servicefunction,GetIPPort);
+ mi.pszService = servicefunction;
+ mi.position = 500090000;
+ mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner=protocolname;
+ mi.pszName = LPGEN("C&opy Server Address and Port");
+ copyipport=Menu_AddContactMenuItem(&mi);
+
+ //kopiermenüpunkt
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, "VoiceIPPort");
+ CreateServiceFunction(servicefunction,GetVIPPort);
+ mi.pszService = servicefunction;
+ mi.position = 500090000;
+ mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner=protocolname;
+ mi.pszName = LPGEN("Cop&y Voice Server Address and Port");
+ vipport=Menu_AddContactMenuItem(&mi);
+
+ //joinmenüpunkt
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, "JoinGame");
+ CreateServiceFunction(servicefunction,JoinGame);
+ mi.pszService = servicefunction;
+ mi.position = 500090000;
+ mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner=protocolname;
+ mi.pszName = LPGEN("Join &Game ...");
+ joingame=Menu_AddContactMenuItem(&mi);
+
+ //joinmenüpunkt
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, "StartThisGame");
+ CreateServiceFunction(servicefunction,StartThisGame);
+ mi.pszService = servicefunction;
+ mi.position = 500090000;
+ mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner=protocolname;
+ mi.pszName = LPGEN("Play this Game ...");
+ startthisgame=Menu_AddContactMenuItem(&mi);
+
+ //remove friend
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, "RemoveFriend");
+ CreateServiceFunction(servicefunction,RemoveFriend);
+ mi.pszService = servicefunction;
+ mi.position = 2000070000;
+ mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner=protocolname;
+ mi.pszName = LPGEN("Remove F&riend ...");
+ removefriend=Menu_AddContactMenuItem(&mi);
+
+ //block user
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, "BlockFriend");
+ CreateServiceFunction(servicefunction,BlockFriend);
+ mi.pszService = servicefunction;
+ mi.position = 2000070000;
+ mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner=protocolname;
+ mi.pszName = LPGEN("Block U&ser ...");
+ blockfriend=Menu_AddContactMenuItem(&mi);
+
+ //my fire profile
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, "GotoProfile2");
+ CreateServiceFunction(servicefunction,GotoProfile2);
+ mi.pszService = servicefunction;
+ mi.position = 500090000;
+ mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner=protocolname;
+ mi.pszName = LPGEN("&My XFire Online Profile");
+ Menu_AddMainMenuItem(&mi);
+
+ //my activity protocol
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, "GotoProfileAct");
+ CreateServiceFunction(servicefunction,GotoProfileAct);
+ mi.pszService = servicefunction;
+ mi.position = 500090000;
+ mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner=protocolname;
+ mi.pszName = LPGEN("&Activity Report");
+ Menu_AddMainMenuItem(&mi);
+
+ //rescan my games
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, "ReScanMyGames");
+ CreateServiceFunction(servicefunction,ReScanMyGames);
+ mi.pszService = servicefunction;
+ mi.position = 500090000;
+ mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner=protocolname;
+ mi.pszName = LPGEN("&Rescan my Games ...");
+ Menu_AddMainMenuItem(&mi);
+
+ strcpy(servicefunction, protocolname);
+ strcat(servicefunction, "SetNick");
+ CreateServiceFunction(servicefunction,SetNickDlg);
+ mi.pszService = servicefunction;
+ mi.position = 500090000;
+ mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner=protocolname;
+ mi.pszName = LPGEN("Set &Nickname");
+ Menu_AddMainMenuItem(&mi);
+
+ HookEvent( ME_CLIST_PREBUILDCONTACTMENU, RebuildContactMenu );
+
+ //lade GetExtendedUdpTable Funktion
+ HMODULE hmod=LoadLibraryA("IpHlpApi.dll");
+ _GetExtendedUdpTable=(pGetExtendedUdpTable)GetProcAddress(hmod,"GetExtendedUdpTable");
+ if(_GetExtendedUdpTable==NULL&&DBGetContactSettingByte(NULL,protocolname,"ipportdetec",0))
+ {
+ //MessageBoxA(0,"GetExtendedUdpTable not found. ServerIP/Port detection feature will be disabled.","Miranda XFire Protocol Plugin",MB_OK|MB_ICONINFORMATION);
+ DBWriteContactSettingByte(NULL,protocolname,"ipportdetec",0);
+ XFireLog("Wasn't able to get GetExtendedUdpTable function");
+ }
+
+ char szFile[MAX_PATH];
+ GetModuleFileNameA(hinstance, szFile, MAX_PATH);
+
+ SKINICONDESC sid = {0};
+ sid.cbSize = sizeof(SKINICONDESC);
+ sid.pszDefaultFile = szFile;
+ sid.cx = sid.cy = 16;
+ sid.pszSection = (char*)LPGEN( "Protocols/XFire" );
+ sid.pszName = "XFIRE_main";
+ sid.pszDescription = (char*)Translate("Protocol icon");
+ sid.iDefaultIndex = -IDI_TM;
+ Skin_AddIcon(&sid);
+ return 0;
+}
+
+//funktion liefert für xstatusid den passenden ico zurück, für tipper zb notwendig
+int GetXStatusIcon(WPARAM wParam, LPARAM lParam) {
+ if(lParam == LR_SHARED)
+ {
+ if(wParam>1)
+ return (int)xgamelist.iconmngr.getGameIconFromId(wParam-2); //icocache[(int)wParam-2].hicon;
+ }
+ else
+ {
+ if(wParam>1)
+ return (int)CopyIcon((HICON)xgamelist.iconmngr.getGameIconFromId(wParam-2)/*icocache[(int)wParam-2].hicon*/);
+ }
+
+ return 0;
+}
+
+int RecvMessage(WPARAM wParam, LPARAM lParam)
+{
+ CCSDATA *ccs = ( CCSDATA* )lParam;
+ DBDeleteContactSetting(ccs->hContact, "CList", "Hidden");
+
+ char *szProto;
+ szProto = ( char* ) CallService( MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) ccs->hContact, 0);
+ if ( szProto != NULL && !lstrcmpiA( szProto, protocolname ))
+ return CallService( MS_PROTO_RECVMSG, wParam, lParam );
+
+ return 1;
+}
+
+static void SetMeAFK( LPVOID param )
+{
+ if(bpStatus==ID_STATUS_ONLINE)
+ {
+ SetStatus(ID_STATUS_AWAY,(LPARAM)param);
+ }
+}
+
+static void SetStatusLate( LPVOID param )
+{
+ Sleep(1000);
+ if(bpStatus==ID_STATUS_OFFLINE)
+ {
+ SetStatus((WPARAM)param,0);
+ }
+}
+
+static void SendAck( LPVOID param )
+{
+ ProtoBroadcastAck(protocolname, param, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
+}
+
+static void SendBadAck( LPVOID param )
+{
+ ProtoBroadcastAck(protocolname, param, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE) 0, LPARAM(Translate("XFire does not support offline messaging!")));
+}
+
+static int UserIsTyping(WPARAM wParam, LPARAM lParam)
+{
+ HANDLE hContact = ( HANDLE )wParam;
+ DBVARIANT dbv;
+
+ if(lParam==PROTOTYPE_SELFTYPING_ON)
+ {
+ if(DBGetContactSettingByte(NULL,protocolname,"sendtyping",1)==1)
+ {
+ if(myClient!=NULL)
+ if(myClient->client->connected)
+ if(!DBGetContactSettingTString(hContact, protocolname, "Username",&dbv))
+ {
+ SendTypingPacket typing;
+ typing.init(myClient->client, dbv.pszVal);
+ myClient->client->send( &typing );
+ DBFreeVariant(&dbv);
+ }
+ }
+ }
+ else if(lParam==PROTOTYPE_SELFTYPING_OFF)
+ {
+ }
+
+ return 0;
+}
+
+int SendMessage(WPARAM wParam, LPARAM lParam)
+{
+ CCSDATA *ccs = (CCSDATA *) lParam;
+ PROTORECVEVENT* pre = (PROTORECVEVENT*)ccs->lParam;
+ ACKDATA * ack = (ACKDATA*) lParam;
+ DBVARIANT dbv;
+ int sended=0;
+
+ DBGetContactSettingTString(ccs->hContact, protocolname, "Username",&dbv);
+ if(myClient!=NULL)
+ if(myClient->client->connected&&DBGetContactSettingWord(ccs->hContact, protocolname, "Status", -1)!=ID_STATUS_OFFLINE)
+ {
+ /*if(myClient->useutf8)
+ myClient->sendmsg(dbv.pszVal, ( char* )ccs->lParam);
+ else*/
+ myClient->sendmsg(dbv.pszVal, mir_utf8encode(( char* )ccs->lParam));
+
+ mir_forkthread(SendAck,ccs->hContact);
+ sended=1;
+ }
+ else
+ {
+ mir_forkthread(SendBadAck,ccs->hContact);
+ }
+ DBFreeVariant(&dbv);
+
+ return sended;
+}
+
+//=======================================================
+//GetCaps
+//=======================================================
+
+int GetCaps(WPARAM wParam,LPARAM lParam)
+{
+ if(wParam==PFLAGNUM_1)
+ return PF1_BASICSEARCH|PF1_MODEMSG|PF1_IM;
+ else if(wParam==PFLAGNUM_2)
+ return PF2_ONLINE|PF2_SHORTAWAY; // add the possible statuses here.
+ else if(wParam==PFLAGNUM_3)
+ return PF2_ONLINE|(DBGetContactSettingByte(NULL,protocolname,"nocustomaway",0)==1?0:PF2_SHORTAWAY);
+ else if(wParam==PFLAGNUM_4)
+ return PF4_SUPPORTTYPING|PF4_AVATARS;
+ else if(wParam==PFLAG_UNIQUEIDTEXT)
+ return (int) Translate("Username");
+ else if(wParam==PFLAG_UNIQUEIDSETTING)
+ return (int)"Username";
+ else if(wParam==PFLAG_MAXLENOFMESSAGE)
+ return 3996; //255;
+ return 0;
+}
+
+//=======================================================
+//GetName (tray icon)
+//=======================================================
+int GetName(WPARAM wParam,LPARAM lParam)
+{
+ lstrcpyn((char*)lParam,"XFire",wParam);
+ return 0;
+}
+
+//=======================================================
+//TMLoadIcon
+//=======================================================
+int TMLoadIcon(WPARAM wParam,LPARAM lParam)
+{
+ if(LOWORD( wParam ) == PLI_PROTOCOL) {
+ if(wParam & PLIF_ICOLIB)
+ return (int)Skin_GetIcon("XFIRE_main");
+ return (int)CopyIcon( Skin_GetIcon("XFIRE_main"));
+ }
+ return NULL;
+}
+
+
+static void ConnectingThread(LPVOID params)
+{
+ WPARAM wParam=(WPARAM)params;
+
+ EnterCriticalSection(&connectingMutex);
+
+ if(myClient!=NULL&&myClient->client!=NULL)
+ myClient->run();
+ else
+ {
+ EnterCriticalSection(&connectingMutex);
+ return;
+ }
+
+ if(myClient->client->connected)
+ {
+ sendonrecieve=TRUE;
+ }
+ else
+ {
+ if(DBGetContactSettingWord(NULL,protocolname,"noconnectfailedbox",0)==0) MSGBOXE(Translate("Unable to connect to XFire."));
+ wParam =ID_STATUS_OFFLINE;
+ }
+
+ int oldStatus;
+ oldStatus = bpStatus;
+ bpStatus = wParam;
+
+ ProtoBroadcastAck(protocolname,NULL,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)oldStatus,wParam);
+
+ LeaveCriticalSection(&connectingMutex);
+}
+
+//=======================================================
+//SetStatus
+//=======================================================
+int SetStatus(WPARAM wParam,LPARAM lParam)
+{
+ int oldStatus;
+
+ oldStatus = bpStatus;
+
+ if(bpStatus==ID_STATUS_CONNECTING)
+ return 0;
+
+ if(wParam!=ID_STATUS_ONLINE&&wParam!=ID_STATUS_OFFLINE&&wParam!=ID_STATUS_AWAY&&wParam!=ID_STATUS_RECONNECT)
+ if(DBGetContactSettingByte(NULL,protocolname,"oninsteadafk",0)==0)
+ wParam=ID_STATUS_AWAY; //protokoll auf away schalten
+ else
+ wParam=ID_STATUS_ONLINE; //protokoll auf online schalten
+
+ if (
+ (wParam == ID_STATUS_ONLINE && bpStatus!=ID_STATUS_ONLINE) || // offline --> online
+ (wParam == ID_STATUS_AWAY && bpStatus==ID_STATUS_OFFLINE) // offline --> away
+ )
+ {
+ if(bpStatus == ID_STATUS_AWAY) // away --> online
+ {
+ myClient->Status(statusmessage[0]);
+ }
+ else
+ {
+ // the status has been changed to online (maybe run some more code)
+ DBVARIANT dbv;
+ DBVARIANT dbv2;
+
+ if(DBGetContactSetting(NULL,protocolname,"login",&dbv))
+ {
+ MSGBOXE(Translate("No Loginname is set!"));
+ wParam=ID_STATUS_OFFLINE;
+ }
+ else if(DBGetContactSetting(NULL,protocolname,"password",&dbv2))
+ {
+ MSGBOXE(Translate("No Password is set!"));
+ wParam=ID_STATUS_OFFLINE;
+ }
+ else
+ {
+ CallService(MS_DB_CRYPT_DECODESTRING,strlen(dbv2.pszVal)+1,(LPARAM)dbv2.pszVal);
+
+ if(myClient!=NULL)
+ delete myClient;
+
+ //alter proxycode, entfernt da über netlib die proxysache geregelt wird
+ /* if(DBGetContactSettingByte(NULL, protocolname, "useproxy" ,0))
+ {
+ //verbindung über proxy
+ DBVARIANT dbv3;
+ DBVARIANT dbv4;
+ if(!DBGetContactSetting(NULL,protocolname,"proxyip",&dbv3))
+ {
+ if(!DBGetContactSetting(NULL,protocolname,"proxyport",&dbv4))
+ {
+ myClient = new XFireClient(dbv.pszVal,dbv2.pszVal,DBGetContactSettingByte(NULL,protocolname,"protover",0),1,dbv3.pszVal,atoi(dbv4.pszVal));
+ DBFreeVariant(&dbv4);
+ }
+ DBFreeVariant(&dbv3);
+ }
+ }
+ else */
+ myClient = new XFireClient(dbv.pszVal,dbv2.pszVal,DBGetContactSettingByte(NULL,protocolname,"protover",0));
+
+ //prüfe ob utf8 option aktiv, dann schlater auf true
+ if(DBGetContactSettingByte(NULL,protocolname,"useutf8",0))
+ {
+ myClient->useutf8=TRUE;
+ }
+
+
+ //verbindung als thread
+ bpStatus = ID_STATUS_CONNECTING;
+ ProtoBroadcastAck(protocolname,NULL,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)oldStatus,ID_STATUS_CONNECTING);
+
+ mir_forkthread(ConnectingThread,(LPVOID)wParam);
+ //alte verb
+ /*
+ myClient->run();
+
+ if(myClient->client->connected)
+ {
+ sendonrecieve=TRUE;
+ }
+ else
+ {
+ MSGBOXE(Translate("Unable to connect to XFire."));
+ wParam =ID_STATUS_OFFLINE;
+ }
+ */
+ //für die vars
+ DBDeleteContactSetting(NULL,protocolname,"currentgamename");
+ DBDeleteContactSetting(NULL,protocolname,"currentvoicename");
+ DBDeleteContactSetting(NULL,protocolname,"VServerIP");
+ DBDeleteContactSetting(NULL,protocolname,"ServerIP");
+
+ DBFreeVariant(&dbv);
+ DBFreeVariant(&dbv2);
+ return 0;
+ }
+ }
+ }
+ else if (wParam == ID_STATUS_AWAY && bpStatus!=ID_STATUS_AWAY)
+ {
+ if(bpStatus == ID_STATUS_OFFLINE) // nix
+ {
+ }
+ else if(myClient!=NULL&&myClient->client->connected) // online --> afk
+ {
+ //setze bei aktivem nocustomaway die alte awaystatusmsg zurück, bugfix
+ if(DBGetContactSettingByte(NULL,protocolname,"nocustomaway",0))
+ strcpy_s(statusmessage[1],1024,"(AFK) Away from Keyboard");
+
+ myClient->Status(statusmessage[1]);
+ }
+ }
+ else if ((wParam == ID_STATUS_OFFLINE || wParam == ID_STATUS_RECONNECT) && bpStatus!=ID_STATUS_OFFLINE) // * --> offline
+ {
+ SetEvent(hConnectionClose);
+
+ // the status has been changed to offline (maybe run some more code)
+ if(myClient!=NULL)
+ if(myClient->client->connected)
+ myClient->client->disconnect();
+ CList_MakeAllOffline();
+
+ //teamspeak/ventrilo pid sowie gamepid auf NULL setzen, damit bei einem reconnect die neuerkannt werden
+ pid=NULL;
+ ts2pid=NULL;
+ DBWriteContactSettingWord(NULL,protocolname,"currentgame",0);
+ DBWriteContactSettingWord(NULL,protocolname,"currentvoice",0);
+ DBDeleteContactSetting(NULL,protocolname, "VServerIP");
+ DBDeleteContactSetting(NULL,protocolname, "ServerIP");
+
+ if(wParam == ID_STATUS_RECONNECT)
+ {
+ mir_forkthread(SetStatusLate,(LPVOID)oldStatus);
+ wParam = ID_STATUS_OFFLINE;
+ }
+ }
+ else
+ {
+ // the status has been changed to unknown (maybe run some more code)
+ }
+ //broadcast the message
+ bpStatus = wParam;
+ ProtoBroadcastAck(protocolname,NULL,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)oldStatus,wParam);
+
+
+ return 0;
+}
+
+//=======================================================
+//GetStatus
+//=======================================================
+int GetStatus(WPARAM wParam,LPARAM lParam)
+{
+ if (bpStatus == ID_STATUS_ONLINE)
+ return ID_STATUS_ONLINE;
+ else if (bpStatus == ID_STATUS_AWAY)
+ return ID_STATUS_AWAY;
+ else if (bpStatus == ID_STATUS_CONNECTING)
+ return ID_STATUS_CONNECTING;
+ else
+ return ID_STATUS_OFFLINE;
+}
+
+HANDLE CList_AddContact(XFireContact xfc, bool InList, bool SetOnline,int clan)
+{
+ HANDLE hContact;
+
+ if (xfc.username == NULL)
+ return 0;
+
+ // here we create a new one since no one is to be found
+ hContact = (HANDLE) CallService( MS_DB_CONTACT_ADD, 0, 0);
+ if ( hContact ) {
+ CallService( MS_PROTO_ADDTOCONTACT, (WPARAM) hContact, (LPARAM)protocolname );
+
+ if ( InList )
+ DBDeleteContactSetting(hContact, "CList", "NotOnList");
+ else
+ DBWriteContactSettingByte(hContact, "CList", "NotOnList", 1);
+ DBDeleteContactSetting(hContact, "CList", "Hidden");
+
+ if(strlen(xfc.nick)>0)
+ {
+ if(myClient->useutf8)
+ DBWriteContactSettingUTF8String(hContact, protocolname, "Nick", xfc.nick);
+ else
+ DBWriteContactSettingTString(hContact, protocolname, "Nick", mir_utf8decode(( char* )xfc.nick,NULL));
+ }
+ else if(strlen(xfc.username)>0)
+ DBWriteContactSettingTString(hContact, protocolname, "Nick", xfc.username);
+
+ DBWriteContactSettingTString(hContact, protocolname, "Username", xfc.username);
+
+ //DBWriteContactSettingTString(hContact, protocolname, "Screenname", xfc.nick);
+ DBWriteContactSettingDword(hContact, protocolname, "UserId", xfc.id);
+
+ if(clan>0)
+ DBWriteContactSettingDword(hContact, protocolname, "Clan", clan);
+
+ DBWriteContactSettingWord(hContact, protocolname, "Status", SetOnline ? ID_STATUS_ONLINE:ID_STATUS_OFFLINE);
+
+ if(DBGetContactSettingByte(NULL,protocolname,"noavatars",-1)==0)
+ {
+ if(!DBGetContactSettingByte(NULL,protocolname,"specialavatarload",0))
+ {
+ XFire_SetAvatar* xsa=new XFire_SetAvatar;
+ xsa->hContact=hContact;
+ xsa->username=new char[strlen(xfc.username)+1];
+ strcpy(xsa->username,xfc.username);
+ mir_forkthread(SetAvatar,(LPVOID)xsa);
+ }
+ else
+ {
+ /*
+ scheinbar unterpricht xfire bei zu agressiven nachfragen der buddyinfos die verbindung , deshalb erstmal auskommentiert
+ getestet mit clanbuddy's >270 members
+
+ mit hilfe der buddyinfos kann man den avatar laden und screenshot infos etc bekommt man auch
+ */
+ GetBuddyInfo* buddyinfo=new GetBuddyInfo();
+ buddyinfo->userid=xfc.id;
+ mir_forkthread(SetAvatar2,(LPVOID)buddyinfo);
+ }
+
+
+ }
+
+ if (xfc.id==0) {
+ DBWriteContactSettingByte( hContact, "CList", "NotOnList", 1 );
+ DBWriteContactSettingByte( hContact, "CList", "Hidden", 1 );
+ }
+
+ return hContact;
+ }
+ return false;
+}
+
+BOOL IsXFireContact(HANDLE hContact)
+{
+ char *szProto;
+ szProto = ( char* ) CallService( MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
+ if ( szProto != NULL && !lstrcmpiA( szProto, protocolname )) {
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+HANDLE CList_FindContact (int uid)
+{
+ char *szProto;
+
+ HANDLE hContact = (HANDLE) CallService( MS_DB_CONTACT_FINDFIRST, 0, 0);
+ while (hContact) {
+ szProto = ( char* ) CallService( MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
+ if ( szProto != NULL && !lstrcmpiA( szProto, protocolname )) {
+ if ( DBGetContactSettingDword(hContact, protocolname, "UserId",-1)==uid)
+ {
+ return (HANDLE)hContact;
+ }
+ }
+ hContact = (HANDLE) CallService( MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
+ }
+ return 0;
+}
+
+void CList_MakeAllOffline()
+{
+ vector<HANDLE> fhandles;
+ char *szProto;
+ HANDLE hContact = (HANDLE) CallService( MS_DB_CONTACT_FINDFIRST, 0, 0);
+ while (hContact) {
+ szProto = ( char* ) CallService( MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
+ if ( szProto != NULL && !lstrcmpiA( szProto, protocolname )) {
+ //freunde von freunden in eine seperate liste setzen
+ //nur wenn das nicht abgestellt wurde
+ if(DBGetContactSettingByte(hContact,protocolname,"friendoffriend",0)==1&&
+ DBGetContactSettingByte(NULL,protocolname,"fofdbremove",0)==1)
+ {
+ fhandles.push_back(hContact);
+ }
+
+ //DBDeleteContactSetting(hContact, protocolname, "XStatusMsg");
+ //DBDeleteContactSetting(hContact, protocolname, "XStatusId");
+ //DBDeleteContactSetting(hContact, protocolname, "XStatusName");
+ //DBDeleteContactSetting(hContact, "CList", "StatusMsg");
+ DBDeleteContactSetting(hContact, protocolname, "ServerIP");
+ DBDeleteContactSetting(hContact, protocolname, "Port");
+ DBDeleteContactSetting(hContact, protocolname, "ServerName");
+ DBDeleteContactSetting(hContact, protocolname, "GameType");
+ DBDeleteContactSetting(hContact, protocolname, "Map");
+ DBDeleteContactSetting(hContact, protocolname, "Players");
+ DBDeleteContactSetting(hContact, protocolname, "Passworded");
+
+ DBWriteContactSettingTString(hContact, "CList", "StatusMsg", "");
+ DBDeleteContactSetting(hContact, protocolname, "XStatusMsg");
+ DBDeleteContactSetting(hContact, protocolname, "XStatusId");
+ DBDeleteContactSetting(hContact, protocolname, "XStatusName");
+
+ if(DBGetContactSettingByte(NULL,protocolname,"noavatars",-1)==1)
+ {
+ DBDeleteContactSetting(hContact, "ContactPhoto", "File");
+ DBDeleteContactSetting(hContact, "ContactPhoto", "RFile");
+ DBDeleteContactSetting(hContact, "ContactPhoto", "Backup");
+ DBDeleteContactSetting(hContact, "ContactPhoto", "Format");
+ DBDeleteContactSetting(hContact, "ContactPhoto", "ImageHash");
+ DBDeleteContactSetting(hContact, "ContactPhoto", "XFireAvatarId");
+ DBDeleteContactSetting(hContact, "ContactPhoto", "XFireAvatarMode");
+ }
+ else
+ {
+ //prüf ob der avatar noch existiert
+ DBVARIANT dbv;
+ if(!DBGetContactSettingTString(hContact, "ContactPhoto", "File",&dbv))
+ {
+ FILE*f=fopen(dbv.pszVal,"r");
+ if(f==NULL)
+ {
+ DBDeleteContactSetting(hContact, "ContactPhoto", "File");
+ DBDeleteContactSetting(hContact, "ContactPhoto", "RFile");
+ DBDeleteContactSetting(hContact, "ContactPhoto", "Backup");
+ DBDeleteContactSetting(hContact, "ContactPhoto", "Format");
+ DBDeleteContactSetting(hContact, "ContactPhoto", "ImageHash");
+ DBDeleteContactSetting(hContact, "ContactPhoto", "XFireAvatarId");
+ DBDeleteContactSetting(hContact, "ContactPhoto", "XFireAvatarMode");
+ }
+ else
+ {
+ fclose(f);
+ }
+ DBFreeVariant(&dbv);
+ }
+ }
+ DBWriteContactSettingWord(hContact,protocolname,"Status",ID_STATUS_OFFLINE);
+ }
+ hContact = (HANDLE) CallService( MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
+ }
+ //alle gefundenen handles lsöchen
+ for(uint i=0;i<fhandles.size();i++)
+ {
+ CallService( MS_DB_CONTACT_DELETE, (WPARAM) fhandles.at(i), 0);
+ }
+}
+
+void SetIcon(HANDLE hcontact,HANDLE hicon,int ctype)
+{
+ IconExtraColumn iec;
+ iec.cbSize = sizeof(iec);
+ iec.hImage = hicon;
+ iec.ColumnType = ctype;
+ CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM)hcontact, (LPARAM)&iec);
+}
+
+void SetAvatar2(LPVOID lparam) {
+ static int lasttime=0;
+ int sleep=DBGetContactSettingWord(NULL,protocolname,"avatarloadlatency",1000);
+ lasttime+=sleep;
+
+ if(mySleep(lasttime,hConnectionClose))
+ {
+ delete lparam;
+ lasttime-=sleep;
+ return;
+ }
+
+ GetBuddyInfo* buddyinfo=(GetBuddyInfo*)lparam;
+ if(myClient!=NULL)
+ if(myClient->client->connected)
+ myClient->client->send( buddyinfo );
+
+ delete lparam;
+ lasttime-=sleep;
+}
+
+void SetAvatar(LPVOID lparam)
+//void SetAvatar(HANDLE hContact, char* username)
+{
+ //EnterCriticalSection(&avatarMutex);
+ //WaitForSingleObject(hMutex, INFINITE);
+ static int lasttime=0;
+ int sleep=DBGetContactSettingWord(NULL,protocolname,"avatarloadlatency",250);
+
+ if(bpStatus==ID_STATUS_OFFLINE)
+ return;
+
+ lasttime+=sleep;
+ //Sleep(lasttime);
+ if(mySleep(lasttime,hConnectionClose))
+ {
+ delete lparam;
+ lasttime-=sleep;
+ return;
+ }
+
+ if(bpStatus==ID_STATUS_OFFLINE)
+ return;
+
+ XFireAvatar av;
+
+ XFire_SetAvatar* xsa=(XFire_SetAvatar*)lparam;
+
+ if(xsa->hContact==NULL)
+ return;
+
+ if(GetAvatar(xsa->username,&av))
+ {
+ PROTO_AVATAR_INFORMATION AI;
+ AI.cbSize = sizeof(AI);
+ AI.format = av.type;
+ AI.hContact = xsa->hContact;
+ lstrcpy(AI.filename,av.file);
+ ProtoBroadcastAck(protocolname, xsa->hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS,(HANDLE) &AI, 0);
+ }
+
+ delete(xsa);
+ //ReleaseMutex(hMutex);
+
+ lasttime-=sleep;
+}
+
+BOOL GetAvatar(char* username,XFireAvatar* av)
+{
+ BOOL status=FALSE;
+
+ if(av==NULL||username==NULL)
+ return FALSE;
+
+ char address[256]="http://www.xfire.com/profile/";
+ strcat_s(address,256,username);
+ strcat_s(address,256,"/");
+
+ //netlib request
+ NETLIBHTTPREQUEST nlhr={0},*nlhrReply;
+ nlhr.cbSize = sizeof(nlhr);
+ nlhr.requestType= REQUEST_GET;
+ nlhr.flags = NLHRF_NODUMP|NLHRF_GENERATEHOST|NLHRF_SMARTAUTHHEADER;
+ nlhr.szUrl = address;
+
+ nlhrReply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,(WPARAM)hNetlib,(LPARAM)&nlhr);
+
+ if(nlhrReply) {
+ //nicht auf dem server
+ if (nlhrReply->resultCode != 200) {
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
+ return FALSE;
+ }
+ //keine daten für mich
+ else if (nlhrReply->dataLength < 1 || nlhrReply->pData == NULL)
+ {
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
+ return FALSE;
+ }
+ else
+ {
+ //fwrite(nlhrReply->pData,nlhrReply->dataLength,1,f);
+
+ //id wo angefangen wird, die adresse "rauszuschneiden"
+ char avatarid[]="m_user_avatar_img_wrapper";
+ char* pointer_av=avatarid;
+ //ende des datenbuffers
+ char* deathend=nlhrReply->pData+nlhrReply->dataLength;
+ char* pointer=nlhrReply->pData;
+ //status ob gefunden oder nich
+ BOOL found=FALSE;
+
+ while(pointer<deathend&&*pointer_av!=0)
+ {
+ if(*pointer_av==*pointer)
+ {
+ pointer_av++;
+ if(pointer_av-avatarid>4)
+ found=TRUE;
+ }
+ else
+ pointer_av=avatarid;
+
+ pointer++;
+ }
+ //was gefunden, nun das bild raustrennen
+ if(*pointer_av==0)
+ {
+ char * pos = NULL;
+ pos=strchr(pointer,'/');
+ pos-=5;
+ pointer=pos;
+
+ pos=strchr(pointer,' ');
+ if(pos)
+ {
+ pos--;
+ *pos=0;
+
+ //analysieren, welchent typ das bild hat
+ pos=strrchr(pointer,'.');
+ if(pos)
+ {
+ char filename[512];
+ FoldersGetCustomPath( XFireAvatarFolder, filename, 1024, "" );
+ strcat(filename,"\\");
+ strcat(filename,username);
+
+ pos++;
+ //gif?!?!
+ if(*pos=='g'&&
+ *(pos+1)=='i'&&
+ *(pos+2)=='f')
+ {
+ av->type=PA_FORMAT_GIF;
+ strcat(filename,".gif");
+ }
+ else//dann kanns nur jpg sein
+ {
+ av->type=PA_FORMAT_JPEG;
+ strcat(filename,".jpg");
+ }
+
+ //verusch das bild runterladen
+ if(GetWWWContent2(pointer,filename,FALSE))
+ {
+ strcpy_s(av->file,256,filename); //setzte dateinamen
+ status=TRUE; //avatarladen hat geklappt, cool :)
+ }
+ }
+ }
+ }
+ }
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
+ }
+
+ return status;
+}
+
+static int GetIPPort(WPARAM wParam,LPARAM lParam)
+{
+ char temp[XFIRE_MAX_STATIC_STRING_LEN];
+ HGLOBAL clipbuffer;
+ char* buffer;
+
+ if(DBGetContactSettingWord((HANDLE)wParam, protocolname, "Port", -1)==0)
+ return 0;
+
+ DBVARIANT dbv;
+ if(DBGetContactSettingTString((HANDLE)wParam, protocolname, "ServerIP",&dbv))
+ return 0;
+
+ sprintf(temp,"%s:%d",dbv.pszVal,DBGetContactSettingWord((HANDLE)wParam, protocolname, "Port", -1));
+
+ DBFreeVariant(&dbv);
+
+ if(OpenClipboard(NULL))
+ {
+ EmptyClipboard();
+
+ clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(temp)+1);
+ buffer = (char*)GlobalLock(clipbuffer);
+ strcpy(buffer, LPCSTR(temp));
+ GlobalUnlock(clipbuffer);
+
+ SetClipboardData(CF_TEXT, clipbuffer);
+ CloseClipboard();
+ }
+
+ return 0;
+}
+
+static int GetVIPPort(WPARAM wParam,LPARAM lParam)
+{
+ char temp[XFIRE_MAX_STATIC_STRING_LEN];
+ HGLOBAL clipbuffer;
+ char* buffer;
+
+ if(DBGetContactSettingWord((HANDLE)wParam, protocolname, "VPort", -1)==0)
+ return 0;
+
+ DBVARIANT dbv;
+ if(DBGetContactSettingTString((HANDLE)wParam, protocolname, "VServerIP",&dbv))
+ return 0;
+
+ sprintf(temp,"%s:%d",dbv.pszVal,DBGetContactSettingWord((HANDLE)wParam, protocolname, "VPort", -1));
+
+ DBFreeVariant(&dbv);
+
+ if(OpenClipboard(NULL))
+ {
+ EmptyClipboard();
+
+ clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(temp)+1);
+ buffer = (char*)GlobalLock(clipbuffer);
+ strcpy(buffer, LPCSTR(temp));
+ GlobalUnlock(clipbuffer);
+
+ SetClipboardData(CF_TEXT, clipbuffer);
+ CloseClipboard();
+ }
+
+ return 0;
+}
+
+static int GotoProfile(WPARAM wParam,LPARAM lParam)
+{
+ DBVARIANT dbv;
+ char temp[64]="";
+
+ if(DBGetContactSettingTString((HANDLE)wParam, protocolname, "Username",&dbv))
+ return 0;
+
+ strcpy(temp,"http://xfire.com/profile/");
+ strcat_s(temp,64,dbv.pszVal);
+ DBFreeVariant(&dbv);
+
+ CallService( MS_UTILS_OPENURL, 1, (LPARAM)temp );
+
+ return 0;
+}
+
+static int GotoXFireClanSite(WPARAM wParam,LPARAM lParam) {
+ DBVARIANT dbv;
+ char temp[64]="";
+
+ int clanid=DBGetContactSettingDword((HANDLE)wParam, protocolname, "Clan",-1);
+ sprintf(temp,"ClanUrl_%d",clanid);
+
+ if(DBGetContactSettingTString(NULL, protocolname, temp,&dbv))
+ return 0;
+
+ strcpy(temp,"http://xfire.com/clans/");
+ strcat_s(temp,64,dbv.pszVal);
+ DBFreeVariant(&dbv);
+
+ CallService( MS_UTILS_OPENURL, 1, (LPARAM)temp );
+
+ return 0;
+}
+
+static int GotoProfile2(WPARAM wParam,LPARAM lParam)
+{
+ DBVARIANT dbv;
+ char temp[64]="";
+
+ if(DBGetContactSettingTString(NULL, protocolname, "login",&dbv))
+ return 0;
+
+ strcpy(temp,"http://xfire.com/profile/");
+ strcat_s(temp,64,dbv.pszVal);
+ DBFreeVariant(&dbv);
+
+ CallService( MS_UTILS_OPENURL, 1, (LPARAM)temp );
+
+ //prefrences pakcet senden
+ //XFirePrefPacket *packet2 = new XFirePrefPacket();
+ //myClient->client->send( packet2 );
+ //delete(packet2);
+
+ return 0;
+}
+
+static int GotoProfileAct(WPARAM wParam,LPARAM lParam)
+{
+ DBVARIANT dbv;
+ char temp[64]="";
+
+ if(DBGetContactSettingTString(NULL, protocolname, "login",&dbv))
+ return 0;
+
+ strcpy(temp,"http://www.xfire.com/?username=");
+ strcat_s(temp,64,dbv.pszVal);
+ DBFreeVariant(&dbv);
+
+ CallService( MS_UTILS_OPENURL, 1, (LPARAM)temp );
+
+ //prefrences pakcet senden
+ //XFirePrefPacket *packet2 = new XFirePrefPacket();
+ //myClient->client->send( packet2 );
+ //delete(packet2);
+
+ return 0;
+}
+
+int RebuildContactMenu( WPARAM wParam, LPARAM lParam )
+{
+ CLISTMENUITEM clmi = { 0 };
+ clmi.cbSize = sizeof( clmi );
+ CLISTMENUITEM clmi2 = { 0 };
+ clmi2.cbSize = sizeof( clmi2 );
+ CLISTMENUITEM clmi3 = { 0 };
+ clmi3.cbSize = sizeof( clmi3 );
+ CLISTMENUITEM clmi4 = { 0 };
+ clmi4.cbSize = sizeof( clmi4 );
+ CLISTMENUITEM clmi5 = { 0 };
+ clmi5.cbSize = sizeof( clmi5 );
+ CLISTMENUITEM clmi6 = { 0 };
+ clmi6.cbSize = sizeof( clmi6 );
+ CLISTMENUITEM clmi7 = { 0 };
+ clmi7.cbSize = sizeof( clmi7 );
+ CLISTMENUITEM clmi8 = { 0 };
+ clmi8.cbSize = sizeof( clmi8 );
+
+ //kopieren von port und ip nur erlauben, wenn verfügbar
+ clmi.flags = CMIM_FLAGS;
+ clmi2.flags = CMIM_FLAGS;
+ clmi3.flags = CMIM_FLAGS;
+ clmi4.flags = CMIM_FLAGS;
+ clmi5.flags = CMIM_FLAGS;
+ clmi6.flags = CMIM_FLAGS;
+ clmi7.flags = CMIM_FLAGS;
+ clmi8.flags = CMIM_FLAGS;
+
+ DBVARIANT dbv;
+ if(DBGetContactSettingTString((HANDLE)wParam, protocolname, "ServerIP",&dbv))
+ clmi.flags|= CMIF_HIDDEN;
+ else
+ DBFreeVariant(&dbv);
+
+ CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )copyipport, ( LPARAM )&clmi );
+
+ //kopieren von voice port und ip nur erlauben, wenn verfügbar
+ DBVARIANT dbv2;
+ if(DBGetContactSettingTString((HANDLE)wParam, protocolname, "VServerIP",&dbv2))
+ {
+ clmi2.flags|= CMIF_HIDDEN;
+ }
+ else
+ DBFreeVariant(&dbv2);
+
+ CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )vipport, ( LPARAM )&clmi2 );
+
+ //clansite nur bei clanmembern anbieten
+ if(DBGetContactSettingDword((HANDLE)wParam, protocolname, "Clan",0)==0)
+ clmi3.flags|= CMIF_HIDDEN;
+
+ CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )gotoclansite, ( LPARAM )&clmi3 );
+
+ //NotOnList
+ if(DBGetContactSettingDword((HANDLE)wParam, "CList", "NotOnList",0)==0)
+ clmi5.flags|= CMIF_HIDDEN;
+
+ CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )blockfriend, ( LPARAM )&clmi5 );
+
+ //speichere gameid ab
+ int gameid=DBGetContactSettingWord((HANDLE)wParam, protocolname, "GameId",0);
+ //spiel in xfirespieliste?
+ if(!xgamelist.Gameinlist(gameid))
+ {
+ //nein, dann start und join auf unsichbar schalten
+ clmi7.flags|= CMIF_HIDDEN;
+ clmi4.flags|= CMIF_HIDDEN;
+ }
+ else
+ {
+ //gameobject holen
+ Xfire_game* game=xgamelist.getGamebyGameid(gameid);
+ //hat das spiel netzwerkparameter?
+ if(game)
+ {
+ if(game->networkparams)
+ {
+ //is beim buddy ein port hinterlegt, also spielt er im internet?
+ if(!DBGetContactSettingDword((HANDLE)wParam, protocolname, "Port",0))
+ {
+ //nein, dann join button auch ausblenden
+ clmi4.flags|= CMIF_HIDDEN;
+ }
+ }
+ else
+ clmi4.flags|= CMIF_HIDDEN;
+ }
+ else
+ clmi4.flags|= CMIF_HIDDEN;
+ }
+
+ CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )joingame, ( LPARAM )&clmi4 );
+ CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )startthisgame, ( LPARAM )&clmi7 );
+
+
+ //remove freind nur bei noramlen buddies
+ if(DBGetContactSettingByte((HANDLE)wParam, protocolname, "friendoffriend",0)==1)
+ clmi8.flags|= CMIF_HIDDEN;
+
+ CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )removefriend, ( LPARAM )&clmi8 );
+
+ return 0;
+}
+
+//wird beim miranda start ausgeführt, lädt spiele und startet gamedetection
+#ifndef NO_PTHREAD
+void *inigamedetectiont(void *ptr)
+#else
+void inigamedetectiont(LPVOID lParam)
+#endif
+{
+ Scan4Games(NULL);
+#ifndef NO_PTHREAD
+ return gamedetectiont(ptr);
+#else
+ gamedetectiont(NULL);
+#endif
+
+}
+
+void SetXFireGameStatusMsg(Xfire_game* game)
+{
+ char inipath[XFIRE_MAX_STATIC_STRING_LEN]="";
+ static char statusmsg[100]="";
+
+ //kein gameobject, dann abbrechen
+ if(!game) return;
+
+ if(!game->statusmsg)
+ {
+ xgamelist.getIniValue(game->id,"XUSERStatusMsg",statusmsg,100);
+ }
+ else
+ {
+ strcpy_s(statusmsg,100,game->statusmsg);
+ }
+
+ if(statusmsg[0]!=0)
+ if(myClient!=NULL)
+ if(myClient->client->connected)
+ myClient->Status(statusmsg);
+
+}
+
+#ifndef NO_PTHREAD
+void *gamedetectiont(void *ptr)
+#else
+void gamedetectiont(LPVOID lparam)
+#endif
+{
+ DWORD ec; //exitcode der processid
+ int ts2port=0;
+ int vid=0;
+ char ts2ip[4]={0,0,0,0};
+ char temp[200];
+ Xfire_game* currentgame=NULL;
+ BOOL disabledsound=FALSE;
+ BOOL disabledpopups=FALSE;
+
+ //vaiable zum spielzeit messen
+ time_t t1;
+
+
+ if(DBGetContactSettingByte(NULL,protocolname,"nogamedetect",0))
+#ifndef NO_PTHREAD
+ return ptr;
+#else
+ return;
+#endif
+
+ DWORD lowpids=DBGetContactSettingByte(NULL,protocolname,"skiplowpid",100);
+
+ //XFireLog("XFire Gamedetectionthread started ...","");
+
+ while(1)
+ {
+ //Sleep(12000);
+ //XFireLog("12 Sek warten ...","");
+ if(mySleep(12000,hGameDetection))
+ {
+#ifndef NO_PTHREAD
+ return ptr;
+#else
+ return;
+#endif
+ }
+
+#ifndef NO_PTHREAD
+ pthread_testcancel();
+#else
+ if(Miranda_Terminated())
+ return;
+#endif
+
+ if(myClient!=NULL)
+ if(!myClient->client->connected)
+ {
+ //XFireLog("PID und TSPID resett ...","");
+ ts2pid=pid=0;
+ //voicechat internen status zurücksetzen
+ voicechat.resetCurrentvoicestatus();
+ }
+ /*
+ else*/
+ {
+ //erstmal nach TS2 suchen
+ //XFireLog("Teamspeak detection ...","");
+ if(DBGetContactSettingByte(NULL,protocolname,"ts2detection",0))
+ {
+ SendGameStatus2Packet *packet = new SendGameStatus2Packet();
+ if(voicechat.checkVoicechat(packet)) {
+ if(myClient!=NULL)
+ {
+ XFireLog("Send voicechat infos ...");
+ myClient->client->send( packet );
+ }
+ }
+ delete packet;
+
+ //nach ts3 mapfile suchen
+ //HANDLE hMapObject = OpenFileMappingA(FILE_MAP_READ, FALSE, "$ts3info4xfire$");
+ //if (hMapObject) {
+ //}
+ //wenn remote feature aktiviert, darüber ip erkennen
+ /*if(DBGetContactSettingByte(NULL,protocolname,"ts2useremote",0))
+ {
+ //ipholen
+ SendGameStatus2Packet *packet = new SendGameStatus2Packet();
+ if(TSSetupPacket(packet,&ts2pid,&ts2port))
+ {
+ DBWriteContactSettingWord(NULL,protocolname,"currentvoice",packet->gameid);
+
+ if(packet->ip[3]!=0)
+ {
+ sprintf(temp,"%d.%d.%d.%d:%d",(unsigned char)packet->ip[3],(unsigned char)packet->ip[2],(unsigned char)packet->ip[1],(unsigned char)packet->ip[0],packet->port);
+ DBWriteContactSettingTString(NULL, protocolname, "VServerIP", temp);
+ DBWriteContactSettingTString(NULL, protocolname, "currentvoicename", "Teamspeak");
+ }
+ else
+ {
+ DBDeleteContactSetting(NULL,protocolname, "VServerIP");
+ DBDeleteContactSetting(NULL,protocolname, "currentvoicename");
+ }
+
+ if(myClient!=NULL)
+ myClient->client->send( packet );
+ }
+ delete packet;
+
+ }
+ else
+ {
+ if(!ts2pid)
+ {
+ if(FindTeamSpeak(&ts2pid,&vid))
+ {
+ //gefunden, serverdaten scannen
+ SendGameStatus2Packet *packet = new SendGameStatus2Packet();
+ if(myClient!=NULL)
+ if(GetServerIPPort2(ts2pid,myClient->client->localaddr,myClient->client->llocaladdr,&packet->ip[3],&packet->ip[2],&packet->ip[1],&packet->ip[0],&packet->port))
+ {
+ if(packet->port!=0)
+ {
+ packet->gameid=vid;
+
+ if(vid==32)
+ DBWriteContactSettingTString(NULL, protocolname, "currentvoicename", "Teamspeak");
+ else if(vid==33)
+ DBWriteContactSettingTString(NULL, protocolname, "currentvoicename", "Ventrilo");
+ else if(vid==34)
+ DBWriteContactSettingTString(NULL, protocolname, "currentvoicename", "Mumble");
+
+ DBWriteContactSettingWord(NULL,protocolname,"currentvoice",vid);
+
+ sprintf(temp,"%d.%d.%d.%d:%d",(unsigned char)packet->ip[3],(unsigned char)packet->ip[2],(unsigned char)packet->ip[1],(unsigned char)packet->ip[0],packet->port);
+ DBWriteContactSettingTString(NULL, protocolname, "VServerIP", temp);
+
+ if(myClient!=NULL)
+ myClient->client->send( packet );
+ }
+ }
+ delete packet;
+ }
+ }
+ else
+ {
+ //HANDLE op=OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, ts2pid);
+ //if(op!=NULL) GetExitCodeProcess(op,&ec);
+
+ //if(ec!=STILL_ACTIVE) //nicht mehr offen
+ if (GetProcessVersion(ts2pid) == 0)
+ {
+ SendGameStatus2Packet *packet = new SendGameStatus2Packet();
+ packet->gameid=0;
+ DBWriteContactSettingWord(NULL,protocolname,"currentvoice",0);
+ DBDeleteContactSetting(NULL,protocolname, "VServerIP");
+ DBDeleteContactSetting(NULL,protocolname, "currentvoicename");
+
+ if(myClient!=NULL)
+ myClient->client->send( packet );
+ ts2pid=0;
+ delete packet;
+ }
+ else
+ {
+ SendGameStatus2Packet *packet = new SendGameStatus2Packet();
+ if(myClient!=NULL)
+ if(GetServerIPPort2(ts2pid,myClient->client->localaddr,myClient->client->llocaladdr,&packet->ip[3],&packet->ip[2],&packet->ip[1],&packet->ip[0],&packet->port))
+ {
+ if(packet->port!=0)
+ {
+ packet->gameid=vid;
+ DBWriteContactSettingWord(NULL,protocolname,"currentvoice",vid);
+
+ sprintf(temp,"%d.%d.%d.%d:%d",(unsigned char)packet->ip[3],(unsigned char)packet->ip[2],(unsigned char)packet->ip[1],(unsigned char)packet->ip[0],packet->port);
+ DBWriteContactSettingTString(NULL, protocolname, "VServerIP", temp);
+
+ if(myClient!=NULL)
+ myClient->client->send( packet );
+ }
+ }
+ delete packet;
+ }
+ //if(op!=NULL) CloseHandle(op);
+ }
+ }*/
+ }
+
+ if(currentgame!=NULL)
+ {
+
+ //XFireLog("XFire Gamedetection - Game still running ...","");
+
+ //prüf ob das spiel noch offen
+ ec=0;
+ //HANDLE op=OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
+ //if(op!=NULL) GetExitCodeProcess(op,&ec);
+
+ //if(GetLastError()==5) //anwendung ist noch offen und der zugriff wird noch darauf blockiert
+ //{
+ //
+ //}
+ //else if(ec!=STILL_ACTIVE) //nicht mehr offen
+
+ if (!xgamelist.isValidPid(pid))
+ {
+ //XFireLog("XFire Gamedetection - Game was closed ID: %i",currentgame);
+ SendGameStatusPacket *packet = new SendGameStatusPacket();
+ packet->gameid=0;
+ if(DBGetContactSettingByte(NULL,protocolname,"sendgamestatus",1))
+ if(myClient!=NULL)
+ myClient->client->send( packet );
+
+ //spielzeit messen
+ time_t t2=time(NULL);
+ time_t t3=t2-t1;
+ tm * mytm=gmtime(&t3);
+
+ //statusmsg von xfire zurücksetzen
+ if(currentgame->setstatusmsg)
+ {
+ if(myClient!=NULL)
+ if(myClient->client->connected)
+ if(bpStatus==ID_STATUS_ONLINE)
+ myClient->Status(statusmessage[0]);
+ else if(bpStatus==ID_STATUS_AWAY)
+ myClient->Status(statusmessage[1]);
+ }
+
+ sprintf(temp,Translate("Last game: %s playtime: %.2d:%.2d:%.2d"),currentgame->name,mytm->tm_hour,mytm->tm_min,mytm->tm_sec);
+ DBWriteContactSettingTString(NULL, protocolname, "LastGame", temp);
+
+ if(currentgame->noicqstatus!=TRUE&&DBGetContactSettingByte(NULL,protocolname,"autosetstatusmsg",0))
+ SetOldStatusMsg();
+
+ DBWriteContactSettingWord(NULL,protocolname,"currentgame",0);
+ DBDeleteContactSetting(NULL,protocolname,"currentgamename");
+
+ //popup wieder aktivieren, menuservice funk aufrufen, nur wenn popups vorher abgestellt wurden
+ if(disabledpopups)
+ if(DBGetContactSettingByte(NULL,protocolname,"nopopups",0))
+ {
+ if(ServiceExists("PopUp/EnableDisableMenuCommand"))
+ {
+ CallService("PopUp/EnableDisableMenuCommand",NULL,NULL);
+ }
+ else if(ServiceExists("PopUp/ToggleEnabled"))
+ {
+ CallService("PopUp/ToggleEnabled",NULL,NULL);
+ }
+ disabledpopups=FALSE;
+ }
+ //sound wieder aktivieren, nur wenn es vorher abgestellt wurde
+ if(disabledsound)
+ if(DBGetContactSettingByte(NULL,protocolname,"nosoundev",0))
+ {
+ DBWriteContactSettingByte(NULL,"Skin","UseSound",1);
+ disabledsound=FALSE;
+ }
+
+ //bug beseitigt, wenn spiel beendet, alte ip entfernen
+ DBDeleteContactSetting(NULL,protocolname, "ServerIP");
+
+ pid=NULL;
+ currentgame=NULL;
+ xgamelist.SetGameStatus(FALSE);
+
+ NotifyEventHooks(hookgamestart,0,0);
+
+ delete packet;
+ }
+ else //noch offen
+ {
+ //XFireLog("Spiel noch offen ...","");
+ //nur nwspiele nach ip/port scannen
+ if(DBGetContactSettingByte(NULL,protocolname,"ipportdetec",0))
+ if(currentgame->networkparams!=NULL&&currentgame->send_gameid>0)
+ {
+ SendGameStatusPacket *packet = new SendGameStatusPacket();
+ //verscueh serverip und port zu scannen
+
+ //XFireLog("IPPort detection ...","");
+ if(GetServerIPPort(pid,myClient->client->localaddr,myClient->client->llocaladdr,&packet->ip[3],&packet->ip[2],&packet->ip[1],&packet->ip[0],&packet->port))
+ {
+
+ if(packet->ip[3]!=0)
+ {
+ sprintf(temp,"%d.%d.%d.%d:%d",(unsigned char)packet->ip[3],(unsigned char)packet->ip[2],(unsigned char)packet->ip[1],(unsigned char)packet->ip[0],packet->port);
+ DBWriteContactSettingTString(NULL, protocolname, "ServerIP", temp);
+ }
+ else
+ DBDeleteContactSetting(NULL,protocolname, "ServerIP");
+
+ packet->gameid=currentgame->send_gameid;
+ if(DBGetContactSettingByte(NULL,protocolname,"sendgamestatus",1))
+ if(myClient!=NULL)
+ myClient->client->send( packet );
+
+ if(currentgame->noicqstatus!=TRUE&&DBGetContactSettingByte(NULL,protocolname,"autosetstatusmsg",0))
+ SetGameStatusMsg();
+ }
+ delete packet;
+ }
+ //XFireLog("fertig ...","");
+ //packet->=xf[currentgame].gameid2;
+ }
+
+ //if(op!=NULL) CloseHandle(op);
+ }
+ else
+ {
+ //XFireLog("nach spiel suchen ...","");
+ //hardcoded game detection
+ HANDLE hSnapShot = CreateToolhelp32Snapshot ( TH32CS_SNAPALL, 0);
+ PROCESSENTRY32* processInfo = new PROCESSENTRY32;
+ processInfo->dwSize = sizeof ( PROCESSENTRY32);
+
+ XFireLog("XFire Gamedetection - Suche laufende Spiele ...");
+
+ //gamelist blocken
+ xgamelist.Block(TRUE);
+
+
+ while ( Process32Next ( hSnapShot,processInfo ) != FALSE && currentgame==NULL)
+ {
+ //überspringe niedrige pids
+ if(processInfo->th32ProcessID<lowpids)
+ continue;
+
+ Xfire_game* nextgame;
+ while(xgamelist.getnextGame(&nextgame))
+ {
+ if(nextgame->checkpath(processInfo))
+ {
+ SendGameStatusPacket *packet = new SendGameStatusPacket() ;
+
+ XFireLog("XFire Gamedetection - Spiel gefunden: %i",nextgame->id);
+
+ if(myClient!=NULL)
+ if(myClient->client->connected)
+ {
+ currentgame=nextgame;
+ pid=processInfo->th32ProcessID;
+ DBWriteContactSettingWord(NULL,protocolname,"currentgame",currentgame->id);
+ DBWriteContactSettingString(NULL,protocolname,"currentgamename",currentgame->name);
+ packet->gameid=currentgame->send_gameid;
+ t1=time(NULL);
+
+ if(DBGetContactSettingByte(NULL,protocolname,"sendgamestatus",1))
+ {
+ XFireLog("XFire Gamedetection - Sendgame-ID: %i",currentgame->send_gameid);
+ if(currentgame->send_gameid>0)
+ {
+ XFireLog("XFire Gamedetection - Setzte Status für XFire");
+ myClient->client->send( packet );
+ }
+ }
+
+ xgamelist.SetGameStatus(TRUE);
+
+ //eventhook triggern
+ NotifyEventHooks(hookgamestart,1,0);
+
+ //statusmsg für xfire setzen
+ if(currentgame->setstatusmsg)
+ {
+ SetXFireGameStatusMsg(currentgame);
+ }
+
+ if(currentgame->noicqstatus!=TRUE&&DBGetContactSettingByte(NULL,protocolname,"autosetstatusmsg",0))
+ {
+ BackupStatusMsg();
+ SetGameStatusMsg();
+ }
+ //popup abschalten, menuservice funk aufrufen
+ if(DBGetContactSettingByte(NULL,protocolname,"nopopups",0))
+ {
+ if(ServiceExists("PopUp/EnableDisableMenuCommand")&&DBGetContactSettingByte(NULL,"PopUp","ModuleIsEnabled",0)==1&&DBGetContactSettingByte(NULL,"PopUp","DisableWhenFullscreen",0)==0) /**/
+ {
+ disabledpopups=TRUE;
+ CallService("PopUp/EnableDisableMenuCommand",NULL,NULL);
+ }
+ else if(ServiceExists("PopUp/ToggleEnabled")&&DBGetContactSettingByte(NULL,"YAPP","Enabled",0)==1)
+ {
+ disabledpopups=TRUE;
+ CallService("PopUp/ToggleEnabled",NULL,NULL);
+ }
+ }
+ //sound abschalten
+ if(DBGetContactSettingByte(NULL,protocolname,"nosoundev",0)&&DBGetContactSettingByte(NULL,"Skin","UseSound",0)==1)
+ {
+ DBWriteContactSettingByte(NULL,"Skin","UseSound",0);
+ disabledsound=TRUE;
+ }
+ }
+
+ delete packet;
+
+ break;
+ }
+ }
+ }
+ CloseHandle ( hSnapShot);
+
+ //gamelist unblocken
+ xgamelist.Block(FALSE);
+ }
+ }
+ }
+}
+
+static int ReScanMyGames(WPARAM wParam,LPARAM lParam)
+{
+ DBDeleteContactSetting(NULL, protocolname, "foundgames");
+
+ mir_forkthread(Scan4Games,NULL);
+
+ return 0;
+}
+
+static int CustomGameSetup(WPARAM wParam,LPARAM lParam)
+{
+ //DialogBox(hinstance,MAKEINTRESOURCE(IDD_GAMELIST),NULL,DlgAddGameProc);
+ return 0;
+}
+
+void setBuddyStatusMsg(BuddyListEntry *entry,string statusmsg)
+{
+ char status[300];
+ int mystatus=ID_STATUS_ONLINE;
+
+ if(entry==NULL)
+ return;
+
+ if(IsContactMySelf(entry->username))
+ return;
+
+ if(strlen(entry->statusmsg.c_str())>5)
+ {
+ char* away=(char*)entry->statusmsg.c_str();
+ if(
+ (*(away)=='('
+ && *(away+1)=='A'
+ && *(away+2)=='F'
+ && *(away+3)=='K'
+ && *(away+4)==')')
+ ||
+ (*(away)=='('
+ &&*(away+1)=='A'
+ && *(away+2)=='B'
+ && *(away+3)=='S'
+ && *(away+4)==')')
+ )
+ {
+ mystatus=ID_STATUS_AWAY;
+ }
+ }
+
+ //statusmsg umwandeln
+ char * temp = mir_utf8decode((char*)entry->statusmsg.c_str(),NULL);
+ if(temp==NULL) temp=(char*)entry->statusmsg.c_str();
+
+ //DBDeleteContactSetting(hContact, "CList", "StatusMsg");
+ DBWriteContactSettingWord(entry->hcontact, protocolname, "Status", mystatus);
+
+ if(entry->game!=0)
+ {
+ char temp2[255];
+ temp2[0]=0;
+
+ DBVARIANT dbv;
+ if(!DBGetContactSettingTString(entry->hcontact,protocolname, "RGame",&dbv))
+ {
+ strcat(temp2,dbv.pszVal);
+ strcat(temp2," ");
+ DBFreeVariant(&dbv);
+ }
+
+ if(DBGetContactSettingByte(NULL,protocolname,"noipportinstatus",0)==0)
+ {
+ if(!DBGetContactSettingTString(entry->hcontact,protocolname, "ServerName",&dbv))
+ {
+ strcat(temp2,dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+ else
+ {
+ if(!DBGetContactSettingTString(entry->hcontact,protocolname, "ServerIP",&dbv))
+ {
+ strcat(temp2,"(");
+ strcat(temp2,dbv.pszVal);
+ sprintf(status,":%d)",DBGetContactSettingWord(entry->hcontact, protocolname, "Port", 0));
+ strcat(temp2,status);
+ DBFreeVariant(&dbv);
+ }
+ }
+ }
+
+ strncpy(status,temp2,97);
+
+ if(strlen(entry->statusmsg.c_str())>0)
+ {
+ strcat(status," - ");
+ strcat(status,temp);
+ }
+ DBWriteContactSettingTString(entry->hcontact, "CList", "StatusMsg", status );
+ DBWriteContactSettingTString(entry->hcontact, protocolname, "XStatusMsg", status );
+ }
+ else
+ {
+ DBWriteContactSettingTString(entry->hcontact, "CList", "StatusMsg", temp );
+ DBWriteContactSettingTString(entry->hcontact, protocolname, "XStatusMsg", temp );
+ DBWriteContactSettingByte(entry->hcontact, protocolname, "XStatusId", 1);
+ DBWriteContactSettingTString(entry->hcontact, protocolname, "XStatusName", "");
+ }
+}
+
+/*void CheckAvatar(void *ventry)
+{
+ BuddyListEntry* entry=(BuddyListEntry*)ventry;
+ DBVARIANT dbv;
+ if(entry==NULL)
+ return;
+ if(DBGetContactSettingByte(NULL,protocolname,"noavatars",-1)==0)
+ {
+ if(DBGetContactSettingByte(entry->hcontact, "ContactPhoto", "Locked", -1)!=1)
+ {
+ if(!DBGetContactSettingByte(NULL,protocolname,"specialavatarload",0))
+ {
+ if(DBGetContactSetting(entry->hcontact,"ContactPhoto", "File",&dbv))
+ {
+ XFire_SetAvatar* xsa=new XFire_SetAvatar;
+ xsa->hContact=entry->hcontact;
+ xsa->username=new char[strlen(entry->username.c_str())+1];
+ strcpy(xsa->username,entry->username.c_str());
+
+ mir_forkthread(SetAvatar,(LPVOID)xsa);
+ }
+ }
+ else
+ {
+ /*
+ scheinbar unterpricht xfire bei zu agressiven nachfragen der buddyinfos die verbindung , deshalb erstmal auskommentiert
+ getestet mit clanbuddy's >270 members
+
+ mit hilfe der buddyinfos kann man den avatar laden und screenshot infos etc bekommt man auch
+ */
+/* GetBuddyInfo* buddyinfo=new GetBuddyInfo();
+ buddyinfo->userid=entry->userid;
+ mir_forkthread(SetAvatar2,(LPVOID)buddyinfo);
+ }
+ }
+ }
+}*/
+
+HANDLE handlingBuddys(BuddyListEntry *entry, int clan,char*group,BOOL dontscan)
+{
+ HANDLE hContact;
+ string game;
+
+ if(entry==NULL)
+ return NULL;
+
+ //wenn der buddy ich selbst ist, dann ignorieren
+ if(IsContactMySelf(entry->username))
+ return NULL;
+
+ if(entry->hcontact==NULL)
+ {
+ entry->hcontact=CList_FindContact(entry->userid);
+ if(entry->hcontact&&clan==-1)
+ {
+ DBWriteContactSettingWord(entry->hcontact, protocolname, "Status", ID_STATUS_ONLINE);
+ DBWriteContactSettingString(entry->hcontact, protocolname, "MirVer", "xfire");
+ }
+ }
+
+ if(entry->hcontact==NULL)
+ {
+ XFireContact xfire_newc;
+ xfire_newc.username=(char*)entry->username.c_str();
+ xfire_newc.nick=(char*)entry->nick.c_str();
+ xfire_newc.id=entry->userid;
+
+ entry->hcontact=CList_AddContact(xfire_newc,TRUE,entry->isOnline()?TRUE:FALSE,clan);
+ }
+
+
+ hContact=entry->hcontact;
+
+ if(hContact!=0)
+ {
+ if(strlen(entry->nick.c_str())>0&&DBGetContactSettingByte(NULL,protocolname,"shownicks",1))
+ {
+ char*nick=NULL;
+
+ if(myClient->useutf8)
+ nick=( char* )entry->nick.c_str();
+ else
+ nick=mir_utf8decode(( char* )entry->nick.c_str(),NULL);
+
+ if(nick)
+ {
+ if(myClient->useutf8)
+ DBWriteContactSettingUTF8String(hContact, protocolname, "Nick", nick);
+ else
+ DBWriteContactSettingTString(hContact, protocolname, "Nick", nick);
+ }
+ else
+ DBWriteContactSettingString(hContact, protocolname, "Nick", entry->username.c_str());
+
+ //DBWriteContactSettingStringUtf(hContact, protocolname, "Nick", entry->nick.c_str());
+ //DBWriteContactSettingUTF8String(hContact, protocolname, "Nick", ( char* )entry->nick.c_str());
+ }
+ else
+ DBWriteContactSettingString(hContact, protocolname, "Nick", entry->username.c_str());
+
+ if(!entry->isOnline())
+ {
+ DBWriteContactSettingWord(hContact, protocolname, "Status", ID_STATUS_OFFLINE);
+ DBDeleteContactSetting(hContact, protocolname, "XStatusMsg");
+ DBDeleteContactSetting(hContact, protocolname, "XStatusId");
+ DBDeleteContactSetting(hContact, protocolname, "XStatusName");
+ DBDeleteContactSetting(hContact, "CList", "StatusMsg");
+ DBWriteContactSettingTString(hContact, protocolname, "XStatusName", "");
+ DBDeleteContactSetting(hContact, protocolname, "ServerIP");
+ DBDeleteContactSetting(hContact, protocolname, "Port");
+ DBDeleteContactSetting(hContact, protocolname, "VServerIP");
+ DBDeleteContactSetting(hContact, protocolname, "VPort");
+ DBDeleteContactSetting(hContact, protocolname, "RVoice");
+ DBDeleteContactSetting(hContact, protocolname, "RGame");
+ DBDeleteContactSetting(hContact, protocolname, "GameId");
+ DBDeleteContactSetting(hContact, protocolname, "VoiceId");
+ DBDeleteContactSetting(hContact, protocolname, "GameInfo");
+ }
+ else if(entry->game>0||entry->game2>0)
+ {
+ char temp[XFIRE_MAX_STATIC_STRING_LEN]="";
+ char gname[255]="";
+
+ DummyXFireGame *gameob;
+
+ if(strlen(entry->gameinfo.c_str())>0)
+ DBWriteContactSettingTString(hContact, protocolname, "GameInfo", entry->gameinfo.c_str());
+
+ //beim voicechat foglendes machn
+ if(entry->game2>0)
+ {
+ gameob=(DummyXFireGame*)entry->game2Obj; //obj wo ip und port sind auslesen
+
+ xgamelist.getGamename(entry->game2,gname,255);
+
+ DBWriteContactSettingTString(hContact, protocolname, "RVoice", gname);
+
+ if(gameob)
+ {
+ if((unsigned char)gameob->ip[3]!=0) // wenn ip, dann speichern
+ {
+ sprintf(temp,"%d.%d.%d.%d",(unsigned char)gameob->ip[3],(unsigned char)gameob->ip[2],(unsigned char)gameob->ip[1],(unsigned char)gameob->ip[0]);
+ DBWriteContactSettingTString(hContact, protocolname, "VServerIP", temp);
+ DBWriteContactSettingWord(hContact, protocolname, "VPort", (unsigned long)gameob->port);
+ }
+ else
+ {
+ DBDeleteContactSetting(hContact, protocolname, "VServerIP");
+ DBDeleteContactSetting(hContact, protocolname, "VPort");
+ }
+ }
+
+ DBWriteContactSettingWord(hContact, protocolname, "VoiceId", entry->game2);
+
+ SetIcon(hContact,xgamelist.iconmngr.getGameIconHandle(entry->game2),EXTRA_ICON_ADV2); //icon seperat setzen
+ }
+ else
+ {
+ DBDeleteContactSetting(hContact, protocolname, "VServerIP");
+ DBDeleteContactSetting(hContact, protocolname, "VPort");
+ DBDeleteContactSetting(hContact, protocolname, "RVoice");
+ DBDeleteContactSetting(hContact, protocolname, "VoiceId");
+ SetIcon(hContact,(HANDLE)-1,EXTRA_ICON_ADV2);
+ }
+
+ //beim game folgendes machen
+ if(entry->game>0)
+ {
+ HICON hicongame=xgamelist.iconmngr.getGameIcon(entry->game);
+
+ xgamelist.getGamename(entry->game,gname,255);
+
+ DBWriteContactSettingTString(hContact, protocolname, "RGame", gname);
+
+ //beinhaltet ip und port
+ gameob=(DummyXFireGame*)entry->gameObj;
+
+ //popup, wenn jemand was spielt
+ if(DBGetContactSettingByte(NULL,protocolname,"gamepopup",0)==1) {
+ char temp[256]="";
+
+ sprintf(temp,Translate("%s playing %s."),
+ //ist ein nick gesetzt?
+ (entry->nick.length()==0?
+ //nein dann username
+ entry->username.c_str():
+ //klar, dann nick nehmen
+ entry->nick.c_str())
+ ,gname);
+
+ if(gameob)
+ {
+ if((unsigned char)gameob->ip[3]!=0)
+ {
+ sprintf(temp,Translate("%s playing %s on server %d.%d.%d.%d:%d."),
+ //ist ein nick gesetzt?
+ (entry->nick.length()==0?
+ //nein dann username
+ entry->username.c_str():
+ //klar, dann nick nehmen
+ entry->nick.c_str())
+ ,gname,(unsigned char)gameob->ip[3],(unsigned char)gameob->ip[2],(unsigned char)gameob->ip[1],(unsigned char)gameob->ip[0],(unsigned long)gameob->port);
+ }
+ }
+
+ /*
+ POPUP-Filter
+ Nur Popups anzeigen die noch nicht angezeigt wurden
+ */
+ if(entry->lastpopup==NULL)
+ {
+ //größe des popupstrings
+ int size=strlen(temp)+1;
+ //popup darstellen
+ displayPopup(NULL,temp,"Miranda XFire Protocol Plugin",0,hicongame);
+ //letzten popup definieren
+ entry->lastpopup=new char[size];
+ //string kopieren
+ strcpy_s(entry->lastpopup,size,temp);
+ }
+ else
+ {
+ if(strcmp(entry->lastpopup,temp)!=0)
+ {
+ delete[] entry->lastpopup;
+ entry->lastpopup=NULL;
+
+ //größe des popupstrings
+ int size=strlen(temp)+1;
+ //popup darstellen
+ displayPopup(NULL,temp,"Miranda XFire Protocol Plugin",0,hicongame);
+ //letzten popup definieren
+ entry->lastpopup=new char[size];
+ //string kopieren
+ strcpy_s(entry->lastpopup,size,temp);
+ }
+ }
+ }
+
+ if(gameob)
+ {
+ if((unsigned char)gameob->ip[3]!=0)
+ {
+ //ip und port in kontakt speichern
+ sprintf(temp,"%d.%d.%d.%d",(unsigned char)gameob->ip[3],(unsigned char)gameob->ip[2],(unsigned char)gameob->ip[1],(unsigned char)gameob->ip[0]);
+ DBWriteContactSettingTString(hContact, protocolname, "ServerIP", temp);
+ DBWriteContactSettingWord(hContact, protocolname, "Port", (unsigned long)gameob->port);
+
+ //lass das query arbeiten
+ if(dontscan==FALSE)
+ if(ServiceExists("GameServerQuery/Query")&&DBGetContactSettingByte(NULL,protocolname,"gsqsupport",0))
+ {
+ GameServerQuery_query gsqq={0};
+ gsqq.port=gameob->port;
+ gsqq.xfiregameid=entry->game;
+ strcpy(gsqq.ip,temp);
+ CallService("GameServerQuery/Query" , (WPARAM) entry, (LPARAM)&gsqq);
+ }
+ }
+ else
+ {
+ DBDeleteContactSetting(hContact, protocolname, "ServerName");
+ DBDeleteContactSetting(hContact, protocolname, "ServerIP");
+ DBDeleteContactSetting(hContact, protocolname, "Port");
+ }
+ }
+
+ SetIcon(hContact,xgamelist.iconmngr.getGameIconHandle(entry->game));
+
+ //DBDeleteContactSetting(hContact, "CList", "StatusMsg");
+ DBWriteContactSettingWord(hContact, protocolname, "Status", ID_STATUS_ONLINE);
+ DBWriteContactSettingTString(hContact, protocolname, "XStatusName", Translate("Playing"));
+ setBuddyStatusMsg(entry,entry->statusmsg);
+ DBWriteContactSettingByte(hContact, protocolname, "XStatusId", xgamelist.iconmngr.getGameIconId(entry->game)+2);
+
+ //buddy vorher ein spielgestartet, wenn nicht sound spielen?
+ if(!DBGetContactSettingWord(hContact, protocolname, "GameId",0))
+ SkinPlaySound( Translate( "xfirebstartgame" ) );
+
+ DBWriteContactSettingWord(hContact, protocolname, "GameId", entry->game);
+ }
+ else
+ {
+ SetIcon(hContact,(HANDLE)-1);
+ DBDeleteContactSetting(hContact, protocolname, "ServerIP");
+ DBDeleteContactSetting(hContact, protocolname, "Port");
+ if(strlen(entry->statusmsg.c_str())==0)
+ {
+ DBDeleteContactSetting(hContact, protocolname, "XStatusMsg");
+ DBDeleteContactSetting(hContact, protocolname, "XStatusId");
+ DBDeleteContactSetting(hContact, protocolname, "XStatusName");
+ }
+ DBDeleteContactSetting(hContact, protocolname, "RGame");
+ DBDeleteContactSetting(hContact, protocolname, "GameId");
+ setBuddyStatusMsg(entry,entry->statusmsg);
+ }
+ }
+ else if(strlen(entry->statusmsg.c_str())>0)
+ {
+ setBuddyStatusMsg(entry,entry->statusmsg);
+
+ SetIcon(hContact,(HANDLE)-1);
+ SetIcon(hContact,(HANDLE)-1,EXTRA_ICON_ADV2);
+ DBDeleteContactSetting(hContact, protocolname, "ServerIP");
+ DBDeleteContactSetting(hContact, protocolname, "Port");
+ DBDeleteContactSetting(hContact, protocolname, "VServerIP");
+ DBDeleteContactSetting(hContact, protocolname, "VPort");
+ DBDeleteContactSetting(hContact, protocolname, "RVoice");
+ DBDeleteContactSetting(hContact, protocolname, "RGame");
+ DBDeleteContactSetting(hContact, protocolname, "GameId");
+ DBDeleteContactSetting(hContact, protocolname, "VoiceId");
+ }
+ else
+ {
+ if(DBGetContactSettingWord(entry->hcontact, protocolname, "Status", -1)==ID_STATUS_OFFLINE)
+ {
+ if(DBGetContactSettingByte(NULL, protocolname, "noclanavatars", 0)==1&&clan>0)
+ ;
+ else
+ if(myClient) myClient->CheckAvatar(entry);
+ }
+
+ SetIcon(hContact,(HANDLE)-1);
+ SetIcon(hContact,(HANDLE)-1,EXTRA_ICON_ADV2);
+ DBWriteContactSettingWord(hContact, protocolname, "Status", ID_STATUS_ONLINE);
+ DBWriteContactSettingString(entry->hcontact, protocolname, "MirVer", "xfire");
+ if(clan>0) DBWriteContactSettingDword(hContact, protocolname, "Clan", clan);
+ DBWriteContactSettingTString(hContact, "CList", "StatusMsg", "");
+ DBDeleteContactSetting(hContact, protocolname, "XStatusMsg");
+ DBDeleteContactSetting(hContact, protocolname, "XStatusId");
+ DBDeleteContactSetting(hContact, protocolname, "XStatusName");
+ //DBDeleteContactSetting(hContact, "CList", "StatusMsg");
+ DBDeleteContactSetting(hContact, protocolname, "ServerIP");
+ DBDeleteContactSetting(hContact, protocolname, "Port");
+ DBDeleteContactSetting(hContact, protocolname, "VServerIP");
+ DBDeleteContactSetting(hContact, protocolname, "VPort");
+ DBDeleteContactSetting(hContact, protocolname, "RVoice");
+ DBDeleteContactSetting(hContact, protocolname, "RGame");
+ DBDeleteContactSetting(hContact, protocolname, "GameId");
+ DBDeleteContactSetting(hContact, protocolname, "VoiceId");
+ }
+ }
+ if(group!=NULL)
+ {
+ if(!DBGetContactSettingByte(NULL,protocolname,"noclangroups",0))
+ {
+ if(clan>0)
+ {
+ int val=DBGetContactSettingByte(NULL,protocolname,"mainclangroup",0);
+
+ if( DBGetContactSettingByte(NULL,protocolname,"skipfriendsgroups",0)==0 ||
+ (DBGetContactSettingByte(NULL,protocolname,"skipfriendsgroups",0)==1&&
+ DBGetContactSettingByte(entry->hcontact, protocolname, "isfriend", 0)==0)
+ )
+ {
+ if(val==0)
+ {
+ DBWriteContactSettingTString(entry->hcontact, "CList", "Group", group);
+ }
+ else
+ {
+ char temp[256];
+ DBVARIANT dbv;
+ sprintf_s(temp,256,"%d",val-1);
+ DBGetContactSettingString(NULL,"CListGroups",temp,&dbv);
+ if(dbv.pszVal!=NULL)
+ {
+ sprintf_s(temp,256,"%s\\%s",&dbv.pszVal[1],group);
+ DBWriteContactSettingTString(entry->hcontact, "CList", "Group", temp);
+ DBFreeVariant(&dbv);
+ }
+ }
+ }
+ }
+ else if(clan==-1)//hauptgruppe für fof
+ {
+ int val=DBGetContactSettingByte(NULL,protocolname,"fofgroup",0);
+
+ if(val==0)
+ {
+ DBWriteContactSettingTString(entry->hcontact, "CList", "Group", group);
+ }
+ else
+ {
+ char temp[256];
+ DBVARIANT dbv;
+ sprintf_s(temp,256,"%d",val-1);
+ DBGetContactSettingString(NULL,"CListGroups",temp,&dbv);
+ if(dbv.pszVal!=NULL)
+ {
+ sprintf_s(temp,256,"%s\\%s",&dbv.pszVal[1],group);
+ DBWriteContactSettingTString(entry->hcontact, "CList", "Group", temp);
+ DBFreeVariant(&dbv);
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ DBWriteContactSettingByte(entry->hcontact, protocolname, "isfriend", 1);
+ }
+
+ return hContact;
+}
+
+int AddtoList( WPARAM wParam, LPARAM lParam ) {
+ CCSDATA* ccs = (CCSDATA*)lParam;
+
+ if (ccs->hContact)
+ {
+ DBVARIANT dbv2;
+ if(!DBGetContactSetting(ccs->hContact,protocolname,"Username",&dbv2)) {
+
+ if(myClient!=NULL)
+ if(myClient->client->connected)
+ {
+ SendAcceptInvitationPacket accept;
+ accept.name = dbv2.pszVal;
+ myClient->client->send(&accept );
+ }
+
+ //temporären buddy entfernen, da eh ein neues packet kommt
+ DBWriteContactSettingByte(ccs->hContact, protocolname, "DontSendDenyPacket", 1);
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM) ccs->hContact, 0);
+ }
+ }
+ return 0;
+}
+
+
+static void __cdecl AckBasicSearch(void * pszNick)
+{
+ if(pszNick!=NULL)
+ {
+ if(myClient!=NULL)
+ if(myClient->client->connected)
+ {
+ SearchBuddy search;
+ search.searchfor(( char* )pszNick);
+ myClient->client->send(&search );
+ }
+ }
+}
+
+int BasicSearch(WPARAM wParam,LPARAM lParam) {
+ static char buf[50];
+ if ( lParam ) {
+ if(myClient!=NULL)
+ if(myClient->client->connected)
+ {
+ lstrcpynA(buf, (const char *)lParam, 50);
+ mir_forkthread(AckBasicSearch, &buf );
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+
+
+static int SearchAddtoList(WPARAM wParam,LPARAM lParam)
+{
+ PROTOSEARCHRESULT *psr = ( PROTOSEARCHRESULT* ) lParam;
+
+ if ( psr->cbSize != sizeof( PROTOSEARCHRESULT ))
+ return 0;
+
+ if((int)wParam==0)
+ if(myClient!=NULL)
+ if(myClient->client->connected)
+ {
+ InviteBuddyPacket invite;
+ invite.addInviteName( psr->nick, Translate("Add me to your friends list."));
+ myClient->client->send(&invite );
+ }
+
+ return -1;
+}
+
+
+void CreateGroup(char*grpn,char*field) {
+ DBVARIANT dbv;
+ char* grp[255];
+
+ int val=DBGetContactSettingByte(NULL,protocolname,field,0);
+
+ if(val==0)
+ {
+ strcpy_s((char*)grp,255,grpn);//((char*)clan->name[i].c_str());
+ }
+ else
+ {
+ char temp[255];
+ DBVARIANT dbv;
+ sprintf_s(temp,255,"%d",val-1);
+ DBGetContactSettingString(NULL,"CListGroups",temp,&dbv);
+ if(dbv.pszVal!=NULL)
+ {
+ sprintf_s((char*)grp,255,"%s\\%s",&dbv.pszVal[1],(char*)grpn);
+ DBFreeVariant(&dbv);
+ }
+ else //gruppe existiert nciht mehr, auf root alles legen
+ {
+ strcpy_s((char*)grp,255,grpn);
+ DBWriteContactSettingByte(NULL,protocolname,field,0);
+ }
+ }
+
+
+ char group[255]="";
+ char temp[10];
+ int i=0;
+ for (i = 0;; i++)
+ {
+ sprintf(temp,"%d",i);
+ if (DBGetContactSettingString(NULL, "CListGroups", temp, &dbv))
+ {
+ i--;
+ break;
+ }
+ if (dbv.pszVal[0] != '\0' && !lstrcmp(dbv.pszVal + 1, (char*)grp)) {
+ DBFreeVariant(&dbv);
+ return;
+ }
+ DBFreeVariant(&dbv);
+ }
+ strcpy_s(group,255,"D");
+ strcat_s(group,255,(char*)grp);
+ group[0]= 1 | GROUPF_EXPANDED;
+ sprintf(temp,"%d",i+1);
+ DBWriteContactSettingString(NULL, "CListGroups", temp, group);
+ CallServiceSync(MS_CLUI_GROUPADDED, i + 1, 0);
+}
+
+
+int SetAwayMsg(WPARAM wParam, LPARAM lParam) {
+ EnterCriticalSection(&modeMsgsMutex);
+ if(( char* )lParam==NULL)
+ {
+ if(wParam==ID_STATUS_ONLINE)
+ {
+ strcpy(statusmessage[0],"");
+ }
+ else if((wParam!=ID_STATUS_ONLINE&&wParam!=ID_STATUS_OFFLINE)&&DBGetContactSettingByte(NULL,protocolname,"nocustomaway",0)==0)
+ {
+ strcpy(statusmessage[1],"(AFK) Away from Keyboard");
+ }
+ }
+ else
+ {
+ if(wParam==ID_STATUS_ONLINE)
+ {
+ strcpy(statusmessage[0],( char* )lParam);
+ }
+ else if((wParam!=ID_STATUS_ONLINE&&wParam!=ID_STATUS_OFFLINE)&&DBGetContactSettingByte(NULL,protocolname,"nocustomaway",0)==0&&strlen(( char* )lParam)>0)
+ {
+ strcpy(statusmessage[1],( char* )lParam);
+ }
+ else if(wParam!=ID_STATUS_ONLINE&&wParam!=ID_STATUS_OFFLINE)
+ {
+ strcpy(statusmessage[1],"(AFK) Away from Keyboard");
+ }
+ }
+
+ if(myClient!=NULL)
+ {
+ if(myClient->client->connected)
+ {
+ if(bpStatus==ID_STATUS_ONLINE)
+ myClient->Status(statusmessage[0]);
+ else if(wParam!=ID_STATUS_ONLINE&&wParam!=ID_STATUS_OFFLINE)
+ myClient->Status(statusmessage[1]);
+ }
+ }
+ LeaveCriticalSection(&modeMsgsMutex);
+ return 0;
+}
+
+static void SendAMAck( LPVOID param )
+{
+ DBVARIANT dbv;
+
+ if(!DBGetContactSettingTString((HANDLE)param, protocolname, "XStatusMsg",&dbv))
+ {
+ ProtoBroadcastAck(protocolname, (HANDLE)param, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE) 1, LPARAM(dbv.pszVal));
+ }
+ else
+ ProtoBroadcastAck(protocolname, (HANDLE)param, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE) 1, LPARAM(""));
+}
+
+int SetNickName(WPARAM wparam, LPARAM newnick)
+{
+ if(newnick==NULL)
+ {
+ return FALSE;
+ }
+
+ if(myClient!=NULL)
+ if(myClient->client->connected)
+ {
+ myClient->setNick((char*)newnick);
+ DBWriteContactSettingString(NULL,protocolname,"Nick",(char*)newnick);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+//sendet neue preferencen zu xfire
+int SendPrefs(WPARAM wparam, LPARAM lparam)
+{
+ if(myClient!=NULL)
+ if(myClient->client->connected)
+ {
+ PrefsPacket prefs;
+ for(int i=0;i<XFIRE_RECVPREFSPACKET_MAXCONFIGS;i++)
+ {
+ prefs.config[i]=xfireconfig[i];
+ }
+ myClient->client->send( &prefs );
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+int GetAwayMsg(WPARAM /*wParam*/, LPARAM lParam)
+{
+ CCSDATA* ccs = (CCSDATA*)lParam;
+
+ mir_forkthread(SendAMAck,ccs->hContact);
+ return 1;
+}
+
+int ContactDeleted(WPARAM wParam,LPARAM lParam) {
+ if(!DBGetContactSettingByte((HANDLE)wParam, protocolname, "DontSendDenyPacket", 0))
+ if(DBGetContactSettingByte((HANDLE)wParam,"CList","NotOnList",0))
+ {
+ if(myClient!=NULL)
+ if(myClient->client->connected)
+ {
+ DBVARIANT dbv2;
+ if(!DBGetContactSetting((HANDLE)wParam,protocolname,"Username",&dbv2)) {
+ SendDenyInvitationPacket deny;
+ deny.name = dbv2.pszVal;
+ myClient->client->send( &deny );
+ }
+ }
+ }
+ return 0;
+}
+
+int StartGame(WPARAM wParam,LPARAM lParam,LPARAM fParam) {
+ //gamelist blocken
+ xgamelist.Block(TRUE);
+
+ Xfire_game*game=xgamelist.getGamebyGameid(fParam);
+
+ //starte das spiel
+ if(game)
+ game->start_game();
+
+ //gamelist blocken
+ xgamelist.Block(FALSE);
+
+
+ return 0;
+}
+
+int RemoveFriend(WPARAM wParam,LPARAM lParam) {
+ char temp[256];
+ DBVARIANT dbv;
+
+ if(!DBGetContactSettingTString((HANDLE)wParam, protocolname, "Username",&dbv))
+ {
+ sprintf(temp,Translate("Do you really want delete your friend %s?"),dbv.pszVal);
+ if(MessageBoxA(NULL,temp,Translate("Confirm Delete"),MB_YESNO|MB_ICONQUESTION)==IDYES)
+ {
+ if(myClient!=NULL)
+ {
+ if(myClient->client->connected)
+ {
+ SendRemoveBuddyPacket removeBuddy;
+
+ removeBuddy.userid=DBGetContactSettingDword((HANDLE)wParam,protocolname,"UserId",0);
+
+ if(removeBuddy.userid!=0)
+ {
+ myClient->client->send(&removeBuddy);
+ }
+ }
+ }
+ }
+ DBFreeVariant(&dbv);
+ }
+ return 0;
+}
+
+int BlockFriend(WPARAM wParam,LPARAM lParam) {
+ DBVARIANT dbv;
+
+ if(!DBGetContactSettingTString((HANDLE)wParam, protocolname, "Username",&dbv))
+ {
+ if(MessageBoxA(NULL,Translate("Block this user from ever contacting you again?"),Translate("Block Confirmation"),MB_YESNO|MB_ICONQUESTION)==IDYES)
+ {
+ if(myClient!=NULL)
+ {
+ if(myClient->client->connected)
+ {
+ DBWriteContactSettingByte(NULL,"XFireBlock",dbv.pszVal,1);
+
+ SendDenyInvitationPacket deny;
+ deny.name = dbv.pszVal;
+ myClient->client->send( &deny );
+ }
+ }
+ }
+ CallService( MS_DB_CONTACT_DELETE, (WPARAM) wParam, 1 );
+ DBFreeVariant(&dbv);
+ }
+ return 0;
+}
+
+int StartThisGame(WPARAM wParam,LPARAM lParam) {
+ //gamelist blocken
+ xgamelist.Block(TRUE);
+
+ //hole die gameid des spiels
+ int id=DBGetContactSettingWord((HANDLE)wParam, protocolname, "GameId",0);
+
+ //hole passendes spielobjekt
+ Xfire_game*game=xgamelist.getGamebyGameid(id);
+
+ //starte das spiel
+ if(game)
+ game->start_game();
+
+ //gamelist blocken
+ xgamelist.Block(FALSE);
+
+ return 0;
+}
+
+int JoinGame(WPARAM wParam,LPARAM lParam) {
+ //gamelist blocken
+ xgamelist.Block(TRUE);
+
+ //hole die gameid des spiels
+ int id=DBGetContactSettingWord((HANDLE)wParam, protocolname, "GameId",0);
+
+ //hole passendes spielobjekt
+ Xfire_game*game=xgamelist.getGamebyGameid(id);
+
+ //starte das spiel
+ if(game)
+ {
+ DBVARIANT dbv; //dbv.pszVal
+ int port=DBGetContactSettingWord((HANDLE)wParam, protocolname, "Port",0);
+ if(!DBGetContactSettingTString((HANDLE)wParam, protocolname, "ServerIP",&dbv))
+ {
+ //starte spiel mit netzwerk parametern
+ game->start_game(dbv.pszVal,port);
+ DBFreeVariant(&dbv);
+ }
+ }
+
+ //gamelist unblocken
+ xgamelist.Block(FALSE);
+
+
+ return 0;
+}
+
+
+int doneQuery( WPARAM wParam, LPARAM lParam ) {
+ char temp[256];
+ BuddyListEntry* bud=(BuddyListEntry*)wParam;
+ gServerstats* gameinfo = (gServerstats*)lParam;
+ DBWriteContactSettingTString(bud->hcontact, protocolname, "ServerName", gameinfo->name);
+ DBWriteContactSettingTString(bud->hcontact, protocolname, "GameType", gameinfo->gametype);
+ DBWriteContactSettingTString(bud->hcontact, protocolname, "Map", gameinfo->map);
+ sprintf(temp,"(%d/%d)",gameinfo->players,gameinfo->maxplayers);
+ DBWriteContactSettingTString(bud->hcontact, protocolname, "Players", temp);
+ DBWriteContactSettingByte(bud->hcontact, protocolname, "Passworded", gameinfo->password);
+
+ if(myClient!=NULL)
+ handlingBuddys(bud,0,NULL,TRUE);
+
+ return 0;
+}
+
+static int SetNickDlg(WPARAM wParam,LPARAM lParam) {
+ return ShowSetNick();
+}
+
+
+int IconLibChanged(WPARAM wParam, LPARAM lParam) {
+ /*int x=0;
+ char temp[255];
+ for(int i=0;i<1024;i++)
+ {
+ if(icocache[i].hicon>0)
+ {
+ //ImageList_ReplaceIcon(hAdvancedStatusIcon,(int)icocache[i].handle,icocache[i].hicon);
+ HANDLE before=icocache[i].handle;
+ icocache[i].handle=(HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)icocache[i].hicon, 0);
+ sprintf(temp,"before: %d after: %d",before,icocache[i].handle);
+ MessageBoxA(NULL,temp,temp,0);
+ DrawIcon(GetDC(NULL),x,0,(HICON)CallService(MS_SKIN2_GETICONBYHANDLE,0,(LPARAM)icocache[i].handle));
+ x+=32;
+ }
+ }*/
+ return 0;
+}
+
+
+int GetAvatarInfo(WPARAM wParam, LPARAM lParam) {
+ PROTO_AVATAR_INFORMATION* pai = (PROTO_AVATAR_INFORMATION*)lParam;
+
+ if(DBGetContactSettingByte(NULL,protocolname,"noavatars",-1)!=0)
+ return GAIR_NOAVATAR;
+
+ pai->format=DBGetContactSettingWord(pai->hContact,"ContactPhoto","Format",0);
+ if(pai->format==0)
+ return GAIR_NOAVATAR;
+
+ DBVARIANT dbv;
+ if(!DBGetContactSetting(pai->hContact,"ContactPhoto","File",&dbv))
+ {
+ strcpy(pai->filename,dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+ else
+ return GAIR_NOAVATAR;
+
+ return GAIR_SUCCESS;
+} \ No newline at end of file
diff --git a/protocols/Xfire/src/messageackpacket.cpp b/protocols/Xfire/src/messageackpacket.cpp
new file mode 100644
index 0000000000..178e2c9717
--- /dev/null
+++ b/protocols/Xfire/src/messageackpacket.cpp
@@ -0,0 +1,75 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "messageackpacket.h"
+#include "xdebug.h"
+#include "string.h"
+#include "variablevalue.h"
+#include <iostream>
+
+namespace xfirelib {
+
+ MessageACKPacket::MessageACKPacket() {
+ memset( sid, 0, 16 );
+ imindex = -1;
+ }
+ MessageACKPacket::~MessageACKPacket() {
+ }
+
+ int MessageACKPacket::getPacketContent(char *buf) {
+ int index = 0;
+ VariableValue val;
+ val.setName("sid");
+ val.setValue(sid,16);
+
+ index += val.writeName(buf,index);
+ buf[index++] = 3;
+ index += val.writeValue(buf,index);
+
+ val.setName("peermsg");
+ index += val.writeName(buf,index);
+ buf[index++] = 5;
+ buf[index++] = 2;
+
+ val.setName("msgtype");
+ val.setValueFromLong(1,4);
+ index += val.writeName(buf,index);
+ buf[index++] = 2;
+ index += val.writeValue(buf,index);
+
+ val.setName("imindex");
+ val.setValueFromLong(imindex,4);
+ index += val.writeName(buf,index);
+ buf[index++] = 02;
+ index += val.writeValue(buf,index);
+
+ return index;
+ }
+
+ void MessageACKPacket::parseContent(char *buf, int length, int numberOfAtts) {
+ }
+
+
+};
+
diff --git a/protocols/Xfire/src/messageackpacket.h b/protocols/Xfire/src/messageackpacket.h
new file mode 100644
index 0000000000..35d0848fbd
--- /dev/null
+++ b/protocols/Xfire/src/messageackpacket.h
@@ -0,0 +1,61 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __MESSAGEACKPACKET_H
+#define __MESSAGEACKPACKET_H
+
+#include "xfiresendpacketcontent.h"
+
+#define XFIRE_MESSAGE_ACK_ID 2
+
+namespace xfirelib {
+
+ /**
+ * (Internal) Packet used to acknowledge a received message.
+ * It is of no use to users of the library because it is already
+ * sent by the Client.
+ */
+ class MessageACKPacket : public XFireSendPacketContent {
+ public:
+ MessageACKPacket();
+ ~MessageACKPacket();
+
+ XFirePacketContent* newPacket() { return new MessageACKPacket(); }
+
+
+ int getPacketId() { return XFIRE_MESSAGE_ACK_ID; }
+ int getPacketContent(char *buf);
+ int getPacketAttributeCount() { return 2; }
+ int getPacketSize() { return 1024; };
+ void parseContent(char *buf, int length, int numberOfAtts);
+
+ char sid[16];
+ long imindex;
+
+ private:
+ };
+
+};
+
+
+#endif
+
diff --git a/protocols/Xfire/src/messagepacket.cpp b/protocols/Xfire/src/messagepacket.cpp
new file mode 100644
index 0000000000..61617bc541
--- /dev/null
+++ b/protocols/Xfire/src/messagepacket.cpp
@@ -0,0 +1,92 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "messagepacket.h"
+#include "xfireparse.h"
+#include "variablevalue.h"
+#include <iostream>
+#include <string>
+#include "xdebug.h"
+
+
+namespace xfirelib {
+ using namespace std;
+
+ MessagePacket::MessagePacket(){
+ packetID = 133;
+ }
+
+int MessagePacket::getPacketContent(char *packet){
+ memcpy(packet,buf,bufLength);
+ packetID = 2;
+ return 150;
+}
+ void MessagePacket::parseContent(char *buf, int length, int numberOfAtts) {
+
+ bufLength = length;
+ XINFO(( "Got IM\n" ));
+
+ int index = 0;
+ sid = new VariableValue();
+ peermsg = new VariableValue();
+ msgtype = new VariableValue();
+
+ index += sid->readName(buf,index);
+ index++; //ignore 03
+ index += sid->readValue(buf,index,16);
+
+ index += peermsg->readName(buf,index);
+ index++;
+ index++;
+ index += msgtype->readName(buf,index);
+ index++;
+ index += msgtype->readValue(buf,index,4);
+
+ if(msgtype->getValue()[0] == 0){
+ imindex = new VariableValue();
+ index += imindex->readName(buf,index);
+
+ VariableValue messageTemp;
+ index++;//ignore 02
+ index += imindex->readValue(buf,index,4);
+ index += messageTemp.readName(buf,index);
+ index++;
+ index += messageTemp.readValue(buf,index,2);
+ int messageLength = messageTemp.getValueAsLong();
+ index = messageTemp.readValue(buf,index,messageLength);
+
+ for(int i = 0; i < messageTemp.getValueLength();i++){
+ message += messageTemp.getValue()[i];
+ }
+ /*TODO: implement this and answer the package*/
+ }else if(msgtype->getValue()[0] == 1){
+ cout << "got ack for a message we have sent" << endl;
+ }else if(msgtype->getValue()[0] == 2){
+ memcpy(this->buf,buf,150);
+ /*answer the packet*/
+ cout << "some auth magic stuff" << length << endl;
+ }
+ }
+
+};
diff --git a/protocols/Xfire/src/messagepacket.h b/protocols/Xfire/src/messagepacket.h
new file mode 100644
index 0000000000..fe867ef96b
--- /dev/null
+++ b/protocols/Xfire/src/messagepacket.h
@@ -0,0 +1,63 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __MESSAGEPACKET_H
+#define __MESSAGEPACKET_H
+
+#include "xfirerecvpacketcontent.h"
+#include "variablevalue.h"
+#include <string>
+
+#define XFIRE_MESSAGE_ID 133
+
+namespace xfirelib {
+
+ class MessagePacket : public XFireRecvPacketContent {
+ public:
+
+ MessagePacket();
+ XFirePacketContent* newPacket() { return new MessagePacket(); }
+
+ int getPacketContent(char *packet);
+ int getPacketId() { return packetID; }
+ int getPacketSize() { return 1024; };
+ void parseContent(char *buf, int length, int numberOfAtts);
+ std::string getMessage() {return message; }
+ int getMessageType(){return msgtype->getValue()[0];}
+ int getImIndex(){ return imindex->getValue()[0];}//TODO: fix this if we have more than 255 messages
+ int getPacketAttributeCount(){ return 2; }
+ char * getSid(){ return sid->getValue(); }
+
+ private:
+ VariableValue *sid;
+ VariableValue *peermsg;
+ VariableValue *msgtype;
+ VariableValue *imindex;
+ std::string message;
+ char buf[150];
+ int bufLength;
+ int packetID;//Special case because we have to answer this packet with id 2
+ };
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/monitoredobj.cpp b/protocols/Xfire/src/monitoredobj.cpp
new file mode 100644
index 0000000000..42b00120ae
--- /dev/null
+++ b/protocols/Xfire/src/monitoredobj.cpp
@@ -0,0 +1,41 @@
+/*
+ * xfiregateway - Jabber Gateway for XFire.
+ * Copyright (C) 2006 by
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net/
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "stdafx.h"
+
+#include "monitoredobj.h"
+
+//alle string klassen entfernt, da die stringklasse instabil ist - dufte
+
+namespace xfirelib {
+ int MonitoredObj::id = 0;
+ MonitoredObj::MonitoredObj() {
+ this->myid = id++;
+ }
+
+ MonitoredObj::~MonitoredObj() {
+ }
+
+ int MonitoredObj::getTotalObjectCount() {
+ int total = 0;
+ return total;
+ }
+
+};
diff --git a/protocols/Xfire/src/monitoredobj.h b/protocols/Xfire/src/monitoredobj.h
new file mode 100644
index 0000000000..4e4b2d66f6
--- /dev/null
+++ b/protocols/Xfire/src/monitoredobj.h
@@ -0,0 +1,49 @@
+/*
+ * xfiregateway - Jabber Gateway for XFire.
+ * Copyright (C) 2006 by
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net/
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#ifndef __MONITOREDOBJ_H
+#define __MONITOREDOBJ_H
+
+#include <typeinfo>
+#include <string>
+#include "xdebug.h"
+#include <map>
+
+namespace xfirelib {
+ class MonitoredObj {
+ public:
+ MonitoredObj();
+ ~MonitoredObj();
+ int getTotalObjectCount();
+
+ std::string classname;
+ int myid;
+ static std::map<std::string,int> instances;
+ static int id;
+ };
+
+
+};
+
+
+
+#endif
diff --git a/protocols/Xfire/src/options.cpp b/protocols/Xfire/src/options.cpp
new file mode 100644
index 0000000000..2cb78c3318
--- /dev/null
+++ b/protocols/Xfire/src/options.cpp
@@ -0,0 +1,1270 @@
+/*
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ *
+ * Copyright (C) 2010 by
+ * dufte <dufte@justmail.de>
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Based on J. Lawler - BaseProtocol
+ * Herbert Poul/Beat Wolf - xfirelib
+ *
+ * Miranda ICQ: the free icq client for MS Windows
+ * Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
+ *
+ */
+
+#include "stdafx.h"
+
+#include "baseProtocol.h"
+#include "m_variables.h"
+#include "recvprefspacket.h"
+#include "Xfire_gamelist.h"
+#include "addgamedialog.h"
+
+extern HANDLE XFireWorkingFolder;
+extern HANDLE XFireIconFolder;
+extern xfire_prefitem xfireconfig[XFIRE_RECVPREFSPACKET_MAXCONFIGS];
+extern Xfire_gamelist xgamelist;
+
+struct mytreeitem {
+ char name[256];
+ char dbentry[256];
+ int parent;
+ int icon;
+ HTREEITEM hitem;
+};
+
+extern int bpStatus;
+BOOL alreadyInit=FALSE;
+HWND ghwndDlg2;
+HWND addgameDialog=NULL;
+
+xfireconfigitem xfireconfigitems[XFIRE_RECVPREFSPACKET_SUPPORTEDONFIGS] = {
+ {IDC_KONFIG_1,1,"sendgamestatus"},
+ {IDC_KONFIG_2,3,"hideprofile"},
+ {IDC_KONFIG_3,2,"ipportdetec"},
+ {IDC_KONFIG_4,0xa,"shownicks"},
+ {IDC_KONFIG_5,0xb,"ts2detection"},
+ {IDC_KONFIG_6,0xc,"sendtyping"},
+ {IDC_KONFIG_7,8,"friendsoffriends"},
+};
+
+#define NUM_ICONS 4
+
+static mytreeitem mytree[] = {
+ {"Avatars","",1,0},
+ {"Disable avatars","noavatars",0,0},
+ {"Dont download avatars of clan members","noclanavatars",0,0},
+ {"Use alternate way for Avatar download","specialavatarload",0,0},
+ {"General","",1,0},
+ {"Use UTF8 for messaging and nick's (beta)","useutf8",0,0},
+ {"Automatically reconnect on protocol version changes","recprotoverchg",0,0},
+ {"No Ip/Port in StatusMsg","noipportinstatus",0,0},
+ {"Use Online status for unsupported global statuses","oninsteadafk",0,0},
+ {"Dont move friends to clan groups","skipfriendsgroups",0,0},
+ {"GameServerQuery support","gsqsupport",0,0},
+ {"No custom away message","nocustomaway",0,0},
+ {"Remove friend of friend buddies from database","fofdbremove",0,0},
+ /*{"Show usernames only","onlyusername",0},*/
+ {"Hide yourself in buddylist","skipmyself",0,0},
+ {"Dont display game search results","dontdisresults",0,0},
+ {"Dont display game search status window","dontdissstatus",0,0},
+ {"Display popup, if someone start a game","gamepopup",0,0},
+ {"Dont automatically create clan groups","noclangroups",0,0},
+ {"Enable MBot support","mbotsupport",0,0},
+ {"Gamedetection","",1,0},
+ /*{"Scan for games on every Miranda start","scanalways",0},*/
+ {"Disable game detection","nogamedetect",0,0},
+ /*{"Enable server IP/Port detection","ipportdetec",0},*/
+ /*{"Enable TeamSpeak2/Ventrilo detection","",0},*/
+ {"Use TSRemote.dll to get teamspeak server info","ts2useremote",0,0},
+ {"Disable popups when ingame","nopopups",0,0},
+ {"Disable sound events when ingame","nosoundev",0,0},
+ {"Files","",1,0},
+ {"Automatically update xfire_games.ini (pro-laming.de)","autoiniupdate",0,0},
+ {"Automatically update icons.dll (pro-laming.de)","autoicodllupdate",0,0},
+ {"Download missing game icons from Xfire website","xfiresitegameico",0,0},
+ {"No backup on update","nobackupini",0,0},
+ {"Background updating","dontaskforupdate",0,0},
+};
+
+//funktion zum auslesen aller einträge unter XFireBlock
+static int enumSettingsProc(const char *szSetting,LPARAM lParam)
+{
+ if(strlen(szSetting)>0)
+ {
+ SendDlgItemMessage( (HWND)lParam, IDC_BLOCKUSER, LB_ADDSTRING, 0, (LPARAM)szSetting);
+ }
+ EnableDlgItem((HWND)lParam, IDC_REMUSER, TRUE);
+ return 0;
+}
+
+//damit die änderungen sofort sichtbar sind
+static BOOL CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ char inipath[XFIRE_MAX_STATIC_STRING_LEN]="";
+ static BOOL inifound = FALSE;
+ static BOOL dllfound = FALSE;
+ static int nomsgboxsel[] = {1,0,2};
+ static HWND hwndTree = NULL;
+ static char login[128];
+
+ switch (msg)
+ {
+ case PSM_CHANGED:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case WM_INITDIALOG:
+ {
+ DBVARIANT dbv;
+ TranslateDialogDefault(hwndDlg);
+
+ ghwndDlg2=hwndDlg;
+
+ hwndTree = GetDlgItem(hwndDlg, IDC_TREE);
+ SetWindowLong(hwndTree,GWL_STYLE,GetWindowLong(hwndTree,GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES);
+ SendMessage(hwndDlg, DM_REBUILD_TREE, 0, 0);
+
+ FoldersGetCustomPath( XFireWorkingFolder, inipath, 1024, "" );
+ strcat(inipath,"\\");
+ strcat(inipath,"xfire_games.ini");
+
+ FILE * f = fopen(inipath,"r");
+ if(f!=NULL)
+ {
+ fclose(f);
+ CheckDlgButton(hwndDlg,IDC_CHKG,1);
+ inifound = TRUE;
+ }
+ else
+ {
+ EnableDlgItem(hwndDlg, IDC_SETUPGAMES, FALSE);
+ inifound = FALSE;
+ }
+
+ FoldersGetCustomPath( XFireIconFolder, inipath, 1024, "" );
+ strcat(inipath,"\\");
+ strcat(inipath,"icons.dll");
+
+ f = fopen(inipath,"r");
+ if(f!=NULL)
+ {
+ fclose(f);
+ CheckDlgButton(hwndDlg,IDC_CHKI,1);
+ dllfound = TRUE;
+ }
+ else
+ dllfound = FALSE;
+
+ if(!DBGetContactSetting(NULL,protocolname,"login",&dbv)) {
+ SetDlgItemText(hwndDlg,IDC_LOGIN,dbv.pszVal);
+
+ DBFreeVariant(&dbv);
+ }
+ if(!DBGetContactSetting(NULL,protocolname,"Nick",&dbv)) {
+ SetDlgItemText(hwndDlg,IDC_NICK,dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+ if(!DBGetContactSetting(NULL,protocolname,"password",&dbv)) {
+ //bit of a security hole here, since it's easy to extract a password from an edit box
+ CallService(MS_DB_CRYPT_DECODESTRING,strlen(dbv.pszVal)+1,(LPARAM)dbv.pszVal);
+ SetDlgItemText(hwndDlg,IDC_PASSWORD,dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+
+ char temp[255]="";
+ sprintf(temp,"%d",DBGetContactSettingByte(NULL,protocolname,"protover",0x5b));
+ SetDlgItemText(hwndDlg,IDC_PVER,temp);
+
+ EnableWindow(GetDlgItem(hwndDlg,IDC_LASTGAME),FALSE);
+ if(!DBGetContactSetting(NULL,protocolname,"LastGame",&dbv)) {
+ SetDlgItemText(hwndDlg,IDC_LASTGAME,dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+
+ if(bpStatus==ID_STATUS_OFFLINE&&bpStatus!=ID_STATUS_CONNECTING) {
+ EnableDlgItem(hwndDlg, IDC_NICK, FALSE);
+ }
+ else
+ {
+ int size=sizeof(xfireconfigitems)/sizeof(xfireconfigitem);
+ for(int i=0;i<size;i++)
+ {
+ EnableDlgItem(hwndDlg, xfireconfigitems[i].id, TRUE);
+ if(xfireconfig[xfireconfigitems[i].xfireconfigid].wasset==0)
+ {
+ CheckDlgButton(hwndDlg,xfireconfigitems[i].id,1);
+ }
+ else
+ {
+ CheckDlgButton(hwndDlg,xfireconfigitems[i].id,0);
+ }
+ }
+ //wenn die erste option aktiv ist, untere aktivieren, sonst deaktivieren
+ if(!(BYTE)IsDlgButtonChecked(hwndDlg, IDC_KONFIG_1 ))
+ {
+ CheckDlgButton(hwndDlg,IDC_KONFIG_2,0);
+ CheckDlgButton(hwndDlg,IDC_KONFIG_3,0);
+ EnableDlgItem(hwndDlg, IDC_KONFIG_2, FALSE);
+ EnableDlgItem(hwndDlg, IDC_KONFIG_3, FALSE);
+ }
+ }
+
+ return TRUE;
+ }
+
+
+
+ case WM_COMMAND:
+ if(!(BYTE)IsDlgButtonChecked(hwndDlg, IDC_KONFIG_1 ))
+ {
+ CheckDlgButton(hwndDlg,IDC_KONFIG_2,0);
+ CheckDlgButton(hwndDlg,IDC_KONFIG_3,0);
+ EnableDlgItem(hwndDlg, IDC_KONFIG_2, FALSE);
+ EnableDlgItem(hwndDlg, IDC_KONFIG_3, FALSE);
+ }
+ else
+ {
+ EnableDlgItem(hwndDlg, IDC_KONFIG_2, TRUE);
+ EnableDlgItem(hwndDlg, IDC_KONFIG_3, TRUE);
+ }
+ if ( LOWORD( wParam ) == IDC_URLNEWACC ) {
+ CallService( MS_UTILS_OPENURL, 1, ( LPARAM )"http://www.xfire.com/register/" );
+ return TRUE;
+ }
+ if ( LOWORD( wParam ) == IDC_LOSTPW ) {
+ CallService( MS_UTILS_OPENURL, 1, ( LPARAM )"https://secure.xfire.com/lost_password/" );
+ return TRUE;
+ }
+
+ if ((LOWORD(wParam) == 19901 || LOWORD(wParam) == 25466 || LOWORD(wParam) == IDC_LOGIN || LOWORD(wParam) == IDC_PIP || LOWORD(wParam) == IDC_PPORT || LOWORD(wParam) == IDC_NICK || LOWORD(wParam) == IDC_PASSWORD) && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) )
+ return 0;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case WM_NOTIFY:
+ {
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case PSN_APPLY:
+ {
+ int reconnectRequired=0;
+ char str[128];
+ DBVARIANT dbv;
+
+ GetDlgItemText(hwndDlg,IDC_LOGIN,login,sizeof(login));
+ dbv.pszVal=NULL;
+ if(DBGetContactSetting(NULL,protocolname,"login",&dbv) || strcmp(login,dbv.pszVal))
+ reconnectRequired=1;
+ if(dbv.pszVal!=NULL) DBFreeVariant(&dbv);
+
+ //den login lowercasen
+ int size=strlen(login);
+ BOOL mustlowercase=FALSE;
+ for(int i=0;i<size;i++)
+ {
+ if(login[i]>='A'&&login[i]<='Z')
+ mustlowercase=TRUE;
+ login[i]=tolower(login[i]);
+ }
+ if(mustlowercase) {
+ MessageBoxA(NULL,Translate("The username must be lowercase, so it will be lowercased saved."),Translate("XFire Options"),MB_OK|MB_ICONINFORMATION);
+ SetDlgItemText(hwndDlg,IDC_LOGIN,login);
+ }
+
+ DBWriteContactSettingString(NULL,protocolname,"login",login);
+ DBWriteContactSettingString(NULL,protocolname,"Username",login);
+
+ //nur wenn der nick erfolgreich übertragen wurde
+ GetDlgItemText(hwndDlg,IDC_NICK,login,sizeof(login));
+ dbv.pszVal=NULL;
+ if(DBGetContactSetting(NULL,protocolname,"Nick",&dbv) || strcmp(login,dbv.pszVal))
+ {
+ if(CallService(XFIRE_SET_NICK,0,(WPARAM)login))
+ DBWriteContactSettingString(NULL,protocolname,"Nick",login);
+ }
+ if(dbv.pszVal!=NULL) DBFreeVariant(&dbv);
+
+ GetDlgItemText(hwndDlg,IDC_PASSWORD,str,sizeof(str));
+ CallService(MS_DB_CRYPT_ENCODESTRING,sizeof(str),(LPARAM)str);
+ dbv.pszVal=NULL;
+ if(DBGetContactSetting(NULL,protocolname,"password",&dbv) || strcmp(str,dbv.pszVal))
+ reconnectRequired=1;
+ if(dbv.pszVal!=NULL) DBFreeVariant(&dbv);
+ DBWriteContactSettingString(NULL,protocolname,"password",str);
+ GetDlgItemText(hwndDlg,IDC_SERVER,str,sizeof(str));
+
+ //neue preferencen sichern
+ if(bpStatus!=ID_STATUS_OFFLINE&&bpStatus!=ID_STATUS_CONNECTING)
+ {
+ int size=sizeof(xfireconfigitems)/sizeof(xfireconfigitem);
+ for(int i=0;i<size;i++)
+ {
+ if(!(BYTE)IsDlgButtonChecked(hwndDlg, xfireconfigitems[i].id))
+ {
+ DBWriteContactSettingByte(NULL,protocolname,xfireconfigitems[i].dbentry,0);
+ xfireconfig[xfireconfigitems[i].xfireconfigid].wasset=1;
+ xfireconfig[xfireconfigitems[i].xfireconfigid].data[0]=1;
+ xfireconfig[xfireconfigitems[i].xfireconfigid].data[1]=1;
+ xfireconfig[xfireconfigitems[i].xfireconfigid].data[2]=0;
+ xfireconfig[xfireconfigitems[i].xfireconfigid].data[3]=0x30;
+ }
+ else
+ {
+ xfireconfig[xfireconfigitems[i].xfireconfigid].wasset=0;
+ DBWriteContactSettingByte(NULL,protocolname,xfireconfigitems[i].dbentry,1);
+ }
+ }
+ CallService(XFIRE_SEND_PREFS,0,0);
+ }
+
+ //protocolversion wird autoamtisch vergeben
+ //GetDlgItemText(hwndDlg,IDC_PVER,str,sizeof(str));
+ //DBWriteContactSettingByte(NULL,protocolname,"protover",(char)atoi(str));
+
+ if(reconnectRequired) MessageBox(hwndDlg,Translate("The changes you have made require you to reconnect to the XFire network before they take effect"),Translate("XFire Options"),MB_OK|MB_ICONINFORMATION);
+ return TRUE;
+ }
+
+ }
+ break;
+ }
+ }
+ return FALSE;
+}
+
+static BOOL CALLBACK DlgProcOpts3(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ char inipath[XFIRE_MAX_STATIC_STRING_LEN]="";
+ static BOOL inifound = FALSE;
+ static BOOL dllfound = FALSE;
+ static int nomsgboxsel[] = {1,0,2};
+ static HWND hwndTree = NULL;
+
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+
+ hwndTree = GetDlgItem(hwndDlg, IDC_TREE);
+
+ SetWindowLong(hwndTree,GWL_STYLE,GetWindowLong(hwndTree,GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES);
+
+ SendMessage(hwndDlg, DM_REBUILD_TREE, 0, 0);
+
+ SendDlgItemMessage( hwndDlg, IDC_NOMSG, CB_ADDSTRING, 0, (LPARAM)TranslateT("Hidden" ));
+ SendDlgItemMessage( hwndDlg, IDC_NOMSG, CB_ADDSTRING, 0, (LPARAM)TranslateT("Messagebox" ));
+ SendDlgItemMessage( hwndDlg, IDC_NOMSG, CB_ADDSTRING, 0, (LPARAM)TranslateT("Popup" ));
+
+ //iconslots auswahl einfügen
+ SendDlgItemMessage( hwndDlg, IDC_CBGICO, CB_ADDSTRING, 0, (LPARAM)TranslateT("Advanced #1 (ICQ X-Status)" ));
+ SendDlgItemMessage( hwndDlg, IDC_CBGICO, CB_ADDSTRING, 0, (LPARAM)TranslateT("Advanced #2" ));
+ SendDlgItemMessage( hwndDlg, IDC_CBGICO, CB_ADDSTRING, 0, (LPARAM)TranslateT("Advanced #3" ));
+ SendDlgItemMessage( hwndDlg, IDC_CBGICO, CB_ADDSTRING, 0, (LPARAM)TranslateT("Advanced #4" ));
+ SendDlgItemMessage( hwndDlg, IDC_CBVICO, CB_ADDSTRING, 0, (LPARAM)TranslateT("Advanced #1 (ICQ X-Status)" ));
+ SendDlgItemMessage( hwndDlg, IDC_CBVICO, CB_ADDSTRING, 0, (LPARAM)TranslateT("Advanced #2" ));
+ SendDlgItemMessage( hwndDlg, IDC_CBVICO, CB_ADDSTRING, 0, (LPARAM)TranslateT("Advanced #3" ));
+ SendDlgItemMessage( hwndDlg, IDC_CBVICO, CB_ADDSTRING, 0, (LPARAM)TranslateT("Advanced #4" ));
+
+ //scanalways
+ SendDlgItemMessage( hwndDlg, IDC_SCANUPDATECB, CB_ADDSTRING, 0, (LPARAM)TranslateT("No" ));
+ SendDlgItemMessage( hwndDlg, IDC_SCANUPDATECB, CB_ADDSTRING, 0, (LPARAM)TranslateT("On every start" ));
+ SendDlgItemMessage( hwndDlg, IDC_SCANUPDATECB, CB_ADDSTRING, 0, (LPARAM)TranslateT("Daily" ));
+
+ SendDlgItemMessage( hwndDlg, IDC_CBVICO, CB_SETCURSEL, DBGetContactSettingByte(NULL,protocolname,"voiceico",-1), 0);
+ SendDlgItemMessage( hwndDlg, IDC_CBGICO, CB_SETCURSEL, DBGetContactSettingByte(NULL,protocolname,"gameico",-1), 0);
+ SendDlgItemMessage( hwndDlg, IDC_SCANUPDATECB, CB_SETCURSEL, DBGetContactSettingByte(NULL,protocolname,"scanalways",0), 0);
+
+ SendDlgItemMessage( hwndDlg, IDC_NOMSG, CB_SETCURSEL, nomsgboxsel[DBGetContactSettingByte(NULL,protocolname,"nomsgbox",0)], 0);
+
+ /* Gruppen raussuchen */
+ {
+ int gruppen_id=0;
+ char temp[8];
+ DBVARIANT dbv;
+
+ SendDlgItemMessage( hwndDlg, IDC_CLANGROUP, CB_ADDSTRING, 0, (LPARAM)TranslateT("<Root Group>" ));
+ SendDlgItemMessage( hwndDlg, IDC_FOFGROUP, CB_ADDSTRING, 0, (LPARAM)TranslateT("<Root Group>" ));
+
+ sprintf_s(temp,8,"%d",gruppen_id);
+ while(!DBGetContactSettingString(NULL,"CListGroups",temp,&dbv))
+ {
+ gruppen_id++;
+ sprintf_s(temp,8,"%d",gruppen_id);
+
+ if(dbv.pszVal!=NULL) {
+ SendDlgItemMessage( hwndDlg, IDC_CLANGROUP, CB_ADDSTRING, 0, (LPARAM)&dbv.pszVal[1]);
+ SendDlgItemMessage( hwndDlg, IDC_FOFGROUP, CB_ADDSTRING, 0, (LPARAM)&dbv.pszVal[1]);
+ DBFreeVariant(&dbv);
+ }
+ }
+ SendDlgItemMessage( hwndDlg, IDC_CLANGROUP, CB_SETCURSEL, DBGetContactSettingByte(NULL,protocolname,"mainclangroup",0), 0);
+ SendDlgItemMessage( hwndDlg, IDC_FOFGROUP, CB_SETCURSEL, DBGetContactSettingByte(NULL,protocolname,"fofgroup",0), 0);
+ }
+
+
+
+ return TRUE;
+ }
+
+ case DM_REBUILD_TREE:
+ //baue optionsmenü auf
+ TreeView_SelectItem(hwndTree, NULL);
+ ShowWindow(hwndTree, SW_HIDE);
+ TreeView_DeleteAllItems(hwndTree);
+ {
+ TVINSERTSTRUCT tvis;
+ HTREEITEM lastSec = NULL;
+
+ tvis.hParent = NULL;
+ tvis.hInsertAfter = TVI_SORT;
+ tvis.item.state = tvis.item.stateMask = TVIS_EXPANDED;
+
+ int size=sizeof(mytree)/sizeof(mytreeitem);
+
+
+ for(int i=0;i<size;i++)
+ {
+ tvis.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM;
+ tvis.item.iImage = -1;
+ tvis.item.stateMask = TVIS_EXPANDED;
+ tvis.item.state = TVIS_EXPANDED;
+ tvis.hParent = lastSec;
+ if ( mytree[i].parent ) {
+ tvis.hParent = NULL;
+ tvis.item.lParam = -1;
+ tvis.item.pszText = Translate(mytree[i].name);
+ tvis.hParent = tvis.item.hItem = TreeView_InsertItem( hwndTree, &tvis );
+ lastSec=tvis.hParent;
+ tvis.item.stateMask = TVIS_STATEIMAGEMASK;
+ tvis.item.state = INDEXTOSTATEIMAGEMASK(0);
+ TreeView_SetItem( hwndTree, &tvis.item );
+ }
+ else
+ {
+ tvis.item.stateMask = TVIS_STATEIMAGEMASK;
+ tvis.item.state = INDEXTOSTATEIMAGEMASK(DBGetContactSettingByte(NULL,protocolname,mytree[i].dbentry,0)==1?2:1);
+ tvis.item.lParam = 0;
+ tvis.item.pszText = Translate(mytree[i].name);
+ mytree[i].hitem=TreeView_InsertItem( hwndTree, &tvis );
+ }
+ }
+ }
+ {
+ TVITEM tvi;
+ tvi.hItem = TreeView_GetRoot(hwndTree);
+ while ( tvi.hItem != NULL ) {
+ tvi.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE;
+ TreeView_GetItem(hwndTree, &tvi);
+ if ( tvi.lParam == -1 )
+ TreeView_SetItemState(hwndTree, tvi.hItem, INDEXTOSTATEIMAGEMASK(0), TVIS_STATEIMAGEMASK);
+
+ tvi.hItem=TreeView_GetNextSibling(hwndTree,tvi.hItem);
+ }
+ }
+
+
+ ShowWindow(hwndTree, SW_SHOW);
+
+ break;
+
+ case PSM_CHANGED:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case WM_COMMAND:
+ CheckDlgButton(hwndDlg,IDC_CHKI,dllfound);
+ CheckDlgButton(hwndDlg,IDC_CHKG,inifound);
+
+ if(HIWORD(wParam) == CBN_SELCHANGE)
+ {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ return 0;
+ }
+
+ if ((LOWORD(wParam) == IDC_LOGIN || LOWORD(wParam) == 1013 || LOWORD(wParam) == 1015 || LOWORD(wParam) == 3 || LOWORD(wParam) == IDC_NICK || LOWORD(wParam) == IDC_PASSWORD) && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) )
+ return 0;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case WM_NOTIFY:
+ {
+ switch (((LPNMHDR)lParam)->idFrom)
+ {
+ case IDC_TREE:
+ {
+ switch(((NMHDR*)lParam)->code) { //wenn was geändert wurde, apply aktivieren
+ case TVN_SELCHANGEDA:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ case TVN_KEYDOWN: //tastatursteuerung
+ {
+ NMTVKEYDOWN* ptkd = (NMTVKEYDOWN*)lParam;
+ if (ptkd&&ptkd->wVKey==VK_SPACE&&TreeView_GetSelection(ptkd->hdr.hwndFrom))
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ }
+ case NM_CLICK: //wenn was geklickt wurde, apply aktivieren
+ {
+ TVHITTESTINFO hti;
+ hti.pt.x=(short)LOWORD(GetMessagePos());
+ hti.pt.y=(short)HIWORD(GetMessagePos());
+ ScreenToClient(((LPNMHDR)lParam)->hwndFrom,&hti.pt);
+ if(TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti))
+ if (hti.flags&TVHT_ONITEM)
+ if(hti.flags&TVHT_ONITEMSTATEICON)
+ if (TreeView_GetParent(hwndTree, hti.hItem)!=NULL)
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ }
+ }
+ }
+ }
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case PSN_APPLY:
+ {
+ int reconnectRequired=0;
+ int ccc;
+
+ hwndTree = GetDlgItem(hwndDlg, IDC_TREE);
+
+ //optionen speichern
+ for(int i=0;i<sizeof(mytree)/sizeof(mytreeitem);i++)
+ {
+ TVITEM tvic;
+ if(mytree[i].parent==0)
+ {
+ tvic.hItem=mytree[i].hitem;
+ tvic.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE;
+
+ TreeView_GetItem(hwndTree, &tvic);
+ if ((( tvic.state & TVIS_STATEIMAGEMASK ) >> 12 == 2 ))
+ DBWriteContactSettingByte(NULL,protocolname,mytree[i].dbentry,1);
+ else
+ DBWriteContactSettingByte(NULL,protocolname,mytree[i].dbentry,0);
+ }
+ }
+
+ DBWriteContactSettingByte(NULL,protocolname,"nomsgbox",(BYTE)nomsgboxsel[SendDlgItemMessage(hwndDlg, IDC_NOMSG, CB_GETCURSEL, 0, 0)]);
+
+ ccc=SendDlgItemMessage(hwndDlg, IDC_CBVICO, CB_GETCURSEL, 0, 0);
+ DBWriteContactSettingByte(NULL,protocolname,"voiceico",(BYTE)ccc);
+ ccc=SendDlgItemMessage(hwndDlg, IDC_CBGICO, CB_GETCURSEL, 0, 0);
+ DBWriteContactSettingByte(NULL,protocolname,"gameico",(BYTE)ccc);
+ ccc=SendDlgItemMessage(hwndDlg, IDC_CLANGROUP, CB_GETCURSEL, 0, 0);
+ DBWriteContactSettingByte(NULL,protocolname,"mainclangroup",(BYTE)ccc);
+ ccc=SendDlgItemMessage(hwndDlg, IDC_FOFGROUP, CB_GETCURSEL, 0, 0);
+ DBWriteContactSettingByte(NULL,protocolname,"fofgroup",(BYTE)ccc);
+ ccc=SendDlgItemMessage(hwndDlg, IDC_SCANUPDATECB, CB_GETCURSEL, 0, 0);
+ DBWriteContactSettingByte(NULL,protocolname,"scanalways",(BYTE)ccc);
+
+ //protocolversion wird autoamtisch vergeben
+ //GetDlgItemText(hwndDlg,IDC_PVER,str,sizeof(str));
+ //DBWriteContactSettingByte(NULL,protocolname,"protover",(char)atoi(str));
+
+ if(reconnectRequired) MessageBox(hwndDlg,Translate("The changes you have made require you to reconnect to the XFire network before they take effect"),Translate("XFire Options"),MB_OK|MB_ICONINFORMATION);
+ return TRUE;
+ }
+
+ }
+ break;
+ }
+ }
+ return FALSE;
+}
+
+static BOOL CALLBACK DlgProcOpts4(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ char inipath[XFIRE_MAX_STATIC_STRING_LEN]="";
+ static BOOL inifound = FALSE;
+ static BOOL dllfound = FALSE;
+ static int nomsgboxsel[] = {1,0,2};
+ static HWND hwndTree = NULL;
+
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ //addgamedia auf 0 setzen
+ TranslateDialogDefault(hwndDlg);
+
+ FoldersGetCustomPath( XFireWorkingFolder, inipath, 1024, "" );
+ strcat(inipath,"\\");
+ strcat(inipath,"xfire_games.ini");
+
+ FILE * f = fopen(inipath,"r");
+ if(f!=NULL)
+ {
+ fclose(f);
+ CheckDlgButton(hwndDlg,IDC_CHKG,1);
+ inifound = TRUE;
+ }
+ else
+ {
+ EnableDlgItem(hwndDlg, IDC_SETUPGAMES, FALSE);
+ inifound = FALSE;
+ }
+
+ FoldersGetCustomPath( XFireIconFolder, inipath, 1024, "" );
+ strcat(inipath,"\\");
+ strcat(inipath,"icons.dll");
+
+ f = fopen(inipath,"r");
+ if(f!=NULL)
+ {
+ fclose(f);
+ CheckDlgButton(hwndDlg,IDC_CHKI,1);
+ dllfound = TRUE;
+ }
+ else
+ dllfound = FALSE;
+
+ //alle blockierten nutzer in die liste einfügen
+ DBCONTACTENUMSETTINGS dbces;
+
+ // enum all setting the contact has for the module
+ dbces.pfnEnumProc = enumSettingsProc;
+ dbces.szModule = "XFireBlock";
+ dbces.lParam = (LPARAM)hwndDlg;
+ CallService(MS_DB_CONTACT_ENUMSETTINGS, 0,(LPARAM)&dbces);
+
+ SendMessage(GetDlgItem(hwndDlg,IDC_REMUSER),BM_SETIMAGE,IMAGE_ICON,(WPARAM)LoadSkinnedIcon(SKINICON_OTHER_DELETE));
+
+ FoldersGetCustomPath( XFireWorkingFolder, inipath, 1024, "" );
+ SetDlgItemText(hwndDlg,IDC_FILESSHOULDBE,inipath);
+
+ EnableDlgItem(hwndDlg, IDC_REMUSER, FALSE);
+
+ return TRUE;
+ }
+
+ case PSM_CHANGED:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case WM_COMMAND:
+ CheckDlgButton(hwndDlg,IDC_CHKI,dllfound);
+ CheckDlgButton(hwndDlg,IDC_CHKG,inifound);
+
+ if(LOWORD(wParam) == IDC_REMUSER) //nutzer soll aus der blockierliste raus
+ {
+ char temp[255];
+ int sel=SendDlgItemMessage(hwndDlg, IDC_BLOCKUSER, LB_GETCURSEL, 0, 0);
+ if(sel!=LB_ERR) //nur wenn was ausgewählt wurde
+ {
+ SendDlgItemMessage(hwndDlg, IDC_BLOCKUSER, LB_GETTEXT, sel, (LPARAM)temp);
+ SendDlgItemMessage(hwndDlg, IDC_BLOCKUSER, LB_DELETESTRING, sel, 0);
+ DBDeleteContactSetting(NULL,"XFireBlock",temp);
+ if(SendDlgItemMessage(hwndDlg, IDC_BLOCKUSER, LB_GETCOUNT, 0, 0)==0)
+ EnableDlgItem(hwndDlg, IDC_REMUSER, FALSE);
+ }
+ }
+
+
+ if ((LOWORD(wParam) == 9508 || LOWORD(wParam) == IDC_LOGIN || LOWORD(wParam) == IDC_SETUPGAMES || LOWORD(wParam) == IDC_PASSWORD) && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) )
+ return 0;
+
+ break;
+
+ case WM_NOTIFY:
+ {
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case PSN_APPLY:
+ {
+ return TRUE;
+ }
+
+ }
+ break;
+ }
+ }
+ return FALSE;
+}
+
+static BOOL CALLBACK DlgProcOpts5(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ DBVARIANT dbv;
+
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+
+ CheckDlgButton(hwndDlg,IDC_ENABLESTSMSG,DBGetContactSettingByte(NULL,protocolname,"autosetstatusmsg",0));
+ CheckDlgButton(hwndDlg,IDC_CHGSTATUS,DBGetContactSettingByte(NULL,protocolname,"statuschgtype",0));
+ CheckDlgButton(hwndDlg,IDC_DNDFIRST,DBGetContactSettingByte(NULL,protocolname,"dndfirst",0));
+ if(!DBGetContactSetting(NULL,protocolname,"setstatusmsg",&dbv)) {
+ SetDlgItemText(hwndDlg,IDC_STATUSMSG,dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+ if(!IsDlgButtonChecked(hwndDlg, IDC_ENABLESTSMSG))
+ {
+ EnableDlgItem(hwndDlg, IDC_STATUSMSG, FALSE);
+ }
+ /* if(!ServiceExists(MS_VARS_FORMATSTRING))
+ {
+ EnableDlgItem(hwndDlg, IDC_STATUSMSG, FALSE);
+ EnableDlgItem(hwndDlg, IDC_ENABLESTSMSG, FALSE);
+ EnableDlgItem(hwndDlg, IDC_CHGSTATUS, FALSE);
+ EnableDlgItem(hwndDlg, IDC_DNDFIRST, FALSE);
+ }*/
+
+ return TRUE;
+ }
+
+ case PSM_CHANGED:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case WM_COMMAND:
+ if ( IsDlgButtonChecked(hwndDlg, IDC_ENABLESTSMSG) ) {
+ EnableDlgItem(hwndDlg, IDC_STATUSMSG, TRUE);
+ }
+ else
+ {
+ EnableDlgItem(hwndDlg, IDC_STATUSMSG, FALSE);
+ }
+
+ if ((LOWORD(wParam) == IDC_LOGIN || LOWORD(wParam) == IDC_STATUSMSG || LOWORD(wParam) == IDC_PASSWORD) && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) )
+ return 0;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+
+ break;
+
+ case WM_NOTIFY:
+ {
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case PSN_APPLY:
+ {
+ int reconnectRequired=0;
+ char str[512];
+
+ GetDlgItemText(hwndDlg,IDC_STATUSMSG,str,sizeof(str));
+ DBWriteContactSettingString(NULL,protocolname,"setstatusmsg",str);
+
+ DBWriteContactSettingByte(NULL,protocolname, "autosetstatusmsg", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ENABLESTSMSG));
+ DBWriteContactSettingByte(NULL,protocolname, "statuschgtype", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CHGSTATUS));
+ DBWriteContactSettingByte(NULL,protocolname, "dndfirst", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DNDFIRST));
+
+ return TRUE;
+ }
+
+ }
+ break;
+ }
+ }
+ return FALSE;
+}
+
+static BOOL CALLBACK DlgProcOpts6(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ addgameDialog=NULL;
+
+ TranslateDialogDefault(hwndDlg);
+
+ //elemente erstmal abstellen
+ EnableDlgItem(hwndDlg, IDC_DONTDETECT, FALSE);
+ EnableDlgItem(hwndDlg, IDC_NOSTATUSMSG, FALSE);
+ EnableDlgItem(hwndDlg, IDC_NOTINSTARTMENU, FALSE);
+ EnableDlgItem(hwndDlg, IDC_APPLY, FALSE);
+ EnableDlgItem(hwndDlg, IDC_EXTRAPARAMS, FALSE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_EDITGAME), SW_HIDE);
+
+ //gamelist füllen
+ SendMessage(hwndDlg,WM_FILLGAMELIST,0,0);
+
+ //SendMessage(GetDlgItem(hwndDlg,IDC_CREATETXTLIST),BM_SETIMAGE,IMAGE_ICON,(WPARAM)LoadSkinnedIcon(SKINICON_OTHER_USERDETAILS));
+
+ return TRUE;
+ }
+ case WM_FILLGAMELIST:
+ {
+ //spielliste leeren
+ SendDlgItemMessage( (HWND)hwndDlg, IDC_LGAMELIST, LB_RESETCONTENT, 0, 0);
+ //spiele auslesen und in die liste einfügen
+ int found=DBGetContactSettingWord(NULL,protocolname,"foundgames",0);
+ char temp[XFIRE_MAXSIZEOFGAMENAME];
+ for(int i=0;i<found;i++)
+ {
+ //id auslesen
+ sprintf_s(temp,XFIRE_MAXSIZEOFGAMENAME,"gameid_%d",i);
+ int gameid=DBGetContactSettingWord(NULL,protocolname,temp,0);
+ //spielnamen auslesen
+ xgamelist.getGamename(gameid,temp,XFIRE_MAXSIZEOFGAMENAME);
+ //eintrag einfügen
+ int idx=SendDlgItemMessage( (HWND)hwndDlg, IDC_LGAMELIST, LB_ADDSTRING, 0, (LPARAM)temp);
+ //id an das element übergeben
+ SendDlgItemMessage( (HWND)hwndDlg, IDC_LGAMELIST, LB_SETITEMDATA, idx, gameid);
+ }
+ return TRUE;
+ }
+ case WM_COMMAND:
+ {
+ if(LOWORD(wParam)==IDC_REMOVE)
+ {
+ int idx=SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETCURSEL, 0, 0);
+
+ //was ausgewählt in der liste?
+ if(idx!=LB_ERR) {
+ //user fragen ob er das game wirklich löschen will
+ if(MessageBox(hwndDlg,Translate("Are you sure you want to remove this game?"),Translate("XFire Options"),MB_YESNO|MB_ICONQUESTION)==IDYES) {
+ //gameliste blocken
+ xgamelist.Block(TRUE);
+ //spielid auslesen
+ int gameid=SendDlgItemMessage( (HWND)hwndDlg, IDC_LGAMELIST, LB_GETITEMDATA, idx, 0);
+ //spiel per gameid entfernen
+ xgamelist.Removegame(gameid);
+ //db säubern
+ xgamelist.clearDatabase(TRUE);
+ //derzeitige gameliste in die datenbank eintragen
+ xgamelist.writeDatabase();
+ //startmenu leeren
+ xgamelist.clearStartmenu();
+ //startmenu neuerzeugen
+ xgamelist.createStartmenu();
+ //gameliste unblocken
+ xgamelist.Block(FALSE);
+ //gamelist neu füllen
+ SendMessage(hwndDlg,WM_FILLGAMELIST,0,0);
+ //erstes vorauswählen
+ SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_SETCURSEL, 0, 0);
+ //liste refresh
+ SendMessage(hwndDlg,WM_COMMAND,MAKELONG(IDC_LGAMELIST,LBN_SELCHANGE),0);
+ }
+ }
+ else
+ MessageBox(hwndDlg,Translate("Please select a game."),Translate("XFire Options"),MB_OK|MB_ICONEXCLAMATION);
+
+ }
+ else
+ if(LOWORD(wParam)==IDC_ADDGAME)
+ {
+ //gameliste blocken
+ xgamelist.Block(TRUE);
+ //if(DialogBox(hinstance,MAKEINTRESOURCE(IDD_ADDGAME),hwndDlg,DlgAddGameProc)) {
+ AddGameDialog(hwndDlg);
+ //gameliste unblocken
+ xgamelist.Block(FALSE);
+ //gamelist neu füllen
+ SendMessage(hwndDlg,WM_FILLGAMELIST,0,0);
+ }
+ //copy gamelist to clipboard button entfernt
+ /*else if(LOWORD(wParam)==IDC_CREATETXTLIST) //gameliste als textform für debugging erstellen
+ {
+ //gameliste blocken
+ xgamelist.Block(TRUE);
+
+ //alle games durchgehen
+ Xfire_game* nextgame;
+ //output string
+ char* out=new char[10];
+ xgamelist.setString("Xfire-gamelist:\r\n",&out);
+ while(xgamelist.getnextGame(&nextgame))
+ {
+ if(nextgame->name)
+ {
+ xgamelist.appendString("\r\nName: ",&out);
+ xgamelist.appendString(nextgame->name,&out);
+ }
+ if(nextgame->path)
+ {
+ xgamelist.appendString("\r\nPath: ",&out);
+ xgamelist.appendString(nextgame->path,&out);
+ }
+ if(nextgame->launchparams)
+ {
+ xgamelist.appendString("\r\nLaunch: ",&out);
+ xgamelist.appendString(nextgame->launchparams,&out);
+ }
+
+ char temp[10];
+ _itoa(nextgame->id,temp,10);
+ xgamelist.appendString("\r\nId: ",&out);
+ xgamelist.appendString(temp,&out);
+
+ _itoa(nextgame->send_gameid,temp,10);
+ xgamelist.appendString("\r\nSend-Id: ",&out);
+ xgamelist.appendString(temp,&out);
+
+ if(nextgame->skip)
+ {
+ xgamelist.appendString("\r\nThis game will be skipped in game detection!",&out);
+ }
+
+ xgamelist.appendString("\r\n",&out);
+ }
+
+ if(OpenClipboard(NULL))
+ {
+ HGLOBAL clipbuffer;
+ char* buffer;
+
+ EmptyClipboard();
+ clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(out)+1);
+ buffer = (char*)GlobalLock(clipbuffer);
+ strcpy(buffer, LPCSTR(out));
+ GlobalUnlock(clipbuffer);
+
+ SetClipboardData(CF_TEXT, clipbuffer);
+ CloseClipboard();
+ }
+
+ if(out!=NULL) delete[] out;
+
+ //gameliste unblocken
+ xgamelist.Block(FALSE);
+ }*/
+ else if(LOWORD(wParam)==IDC_EDITGAME) {
+ int idx=SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETCURSEL, 0, 0);
+
+ //was ausgewählt in der liste?
+ if(idx!=LB_ERR) {
+ //gameliste blocken
+ xgamelist.Block(TRUE);
+ //gameid der aktuellen auswahl auslesen
+ int gameid=SendDlgItemMessage( (HWND)hwndDlg, IDC_LGAMELIST, LB_GETITEMDATA, idx, 0);
+ //spielobject holen
+ Xfire_game* tempgame=xgamelist.getGamebyGameid(gameid);
+ //gültiger verweis?
+ if(tempgame) {
+ //editmodus des addgamedialog
+ AddGameDialog(hwndDlg,tempgame);
+ //elemente wieder unsichtbar machen
+ EnableDlgItem(hwndDlg, IDC_DONTDETECT, FALSE);
+ EnableDlgItem(hwndDlg, IDC_NOSTATUSMSG, FALSE);
+ EnableDlgItem(hwndDlg, IDC_NOTINSTARTMENU, FALSE);
+ EnableDlgItem(hwndDlg, IDC_APPLY, FALSE);
+ EnableDlgItem(hwndDlg, IDC_EXTRAPARAMS, FALSE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_EDITGAME), SW_HIDE);
+ }
+ else
+ MessageBox(hwndDlg,Translate("Error unknown game id."),Translate("XFire Options"),MB_OK|MB_ICONEXCLAMATION);
+ //gameliste unblocken
+ xgamelist.Block(FALSE);
+ //gamelist neu füllen
+ SendMessage(hwndDlg,WM_FILLGAMELIST,0,0);
+ }
+ else
+ MessageBox(hwndDlg,Translate("Please select a game."),Translate("XFire Options"),MB_OK|MB_ICONEXCLAMATION);
+ }else //wurde ein spiel aus der liste gewählt?
+ if(HIWORD(wParam)==LBN_SELCHANGE && LOWORD(wParam)==IDC_LGAMELIST)
+ {
+ int idx=SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETCURSEL, 0, 0);
+ //es wurde was ausgewählt?
+ if(idx!=LB_ERR)
+ {
+ //textlänge auslesen
+ int size=SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETTEXTLEN, idx, 0);
+ //textbuffer anlegen
+ char* text=new char[size+1];
+ SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETTEXT, idx, (LPARAM)text);
+ SetDlgItemText(hwndDlg,IDC_GAMENAME,text);
+ //textbuffer löschen
+ if(text!=NULL)
+ {
+ delete text;
+ text=NULL;
+ }
+ //id des spielsbekommen
+ int gameid=SendDlgItemMessage( (HWND)hwndDlg, IDC_LGAMELIST, LB_GETITEMDATA, idx, 0);
+
+ HICON hicon=xgamelist.iconmngr.getGameIcon(gameid);
+ //iconhandle holen und setzen
+ if(hicon)
+ SendMessage(GetDlgItem(hwndDlg,IDC_GAMEICO),STM_SETICON,(WPARAM)hicon,0);
+ else
+ SendMessage(GetDlgItem(hwndDlg,IDC_GAMEICO),STM_SETICON,0,0);
+
+ //elemente aktivieren
+ EnableDlgItem(hwndDlg, IDC_DONTDETECT, TRUE);
+ EnableDlgItem(hwndDlg, IDC_NOSTATUSMSG, TRUE);
+ EnableDlgItem(hwndDlg, IDC_APPLY, TRUE);
+ EnableDlgItem(hwndDlg, IDC_NOTINSTARTMENU, TRUE);
+ EnableDlgItem(hwndDlg, IDC_EXTRAPARAMS, TRUE);
+
+ Xfire_game* xgtemp = xgamelist.getGamebyGameid(gameid);
+ if(xgtemp && xgtemp->custom)
+ {
+ ShowWindow(GetDlgItem(hwndDlg,IDC_MANADDED),SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_EDITGAME), SW_SHOW);
+ }
+ else
+ {
+ ShowWindow(GetDlgItem(hwndDlg,IDC_MANADDED),SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_EDITGAME), SW_HIDE);
+ }
+
+ //gameskip wert setzen
+ char temp[64]="";
+ sprintf_s(temp,64,"gameskip_%d",gameid);
+ CheckDlgButton(hwndDlg,IDC_DONTDETECT,DBGetContactSettingByte(NULL,protocolname,temp,0));
+ sprintf_s(temp,64,"gamenostatus_%d",gameid);
+ CheckDlgButton(hwndDlg,IDC_NOSTATUSMSG,DBGetContactSettingByte(NULL,protocolname,temp,0));
+ sprintf_s(temp,64,"notinstartmenu_%d",gameid);
+ CheckDlgButton(hwndDlg,IDC_NOTINSTARTMENU,DBGetContactSettingByte(NULL,protocolname,temp,0));
+
+ //extra parameter auslesen, aber nur, wenn das spiel auch sowas unterstützt
+ if(xgtemp && xgtemp->haveExtraGameArgs())
+ {
+ EnableDlgItem(hwndDlg, IDC_EXTRAPARAMS, TRUE);
+ sprintf_s(temp,64,"gameextraparams_%d",gameid);
+ DBVARIANT dbv;
+ if(!DBGetContactSetting(NULL,protocolname,temp,&dbv))
+ {
+ SetDlgItemText(hwndDlg,IDC_EXTRAPARAMS,dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+ else
+ SetDlgItemText(hwndDlg,IDC_EXTRAPARAMS,"");
+ }
+ else
+ {
+ EnableDlgItem(hwndDlg, IDC_EXTRAPARAMS, FALSE);
+ SetDlgItemText(hwndDlg,IDC_EXTRAPARAMS,Translate("Not supported"));
+ }
+ }
+ }
+ else if(LOWORD(wParam)==IDC_APPLY)
+ {
+ //auswahl speichern
+ int idx=SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETCURSEL, 0, 0);
+ //es wurde was ausgewählt?
+ if(idx!=LB_ERR)
+ {
+ int gameid=SendDlgItemMessage( (HWND)hwndDlg, IDC_LGAMELIST, LB_GETITEMDATA, idx, 0);
+ int dbid;
+
+ //gamelist blocken
+ xgamelist.Block(TRUE);
+
+ if(xgamelist.Gameinlist(gameid,&dbid))
+ {
+ Xfire_game* game=xgamelist.getGame(dbid);
+ if(game)
+ {
+ game->skip=(BYTE)IsDlgButtonChecked(hwndDlg, IDC_DONTDETECT);
+ game->noicqstatus=(BYTE)IsDlgButtonChecked(hwndDlg, IDC_NOSTATUSMSG);
+ game->notinstartmenu=(BYTE)IsDlgButtonChecked(hwndDlg, IDC_NOTINSTARTMENU);
+
+ //extra parameter auslesen und das gameobj schreiben
+ char str[128]="";
+ GetDlgItemText(hwndDlg,IDC_EXTRAPARAMS,str,sizeof(str));
+ if(str[0]!=0)
+ {
+ //extra parameter sind gesetzt, zuweisen
+ game->setString(str,&game->extraparams);
+ }
+ else
+ {
+ //extra parameter leer, wenn gesetzt entfernen/freigeben
+ if(game->extraparams)
+ {
+ delete[] game->extraparams;
+ game->extraparams=NULL;
+ }
+ }
+
+
+ game->refreshMenuitem();
+ game->writeToDB(dbid);
+
+ SetDlgItemText(hwndDlg,IDC_TEXTSTATUS,Translate("Configuration saved!"));
+ }
+ else
+ {
+ SetDlgItemText(hwndDlg,IDC_TEXTSTATUS,Translate("Game not found?!"));
+ }
+ }
+ else
+ {
+ SetDlgItemText(hwndDlg,IDC_TEXTSTATUS,Translate("Game not found?!"));
+ }
+
+ //gamelist unblocken
+ xgamelist.Block(FALSE);
+ }
+ }
+ break;
+ }
+
+ case WM_NOTIFY:
+ {
+ break;
+ }
+ }
+ return FALSE;
+}
+
+static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case PSM_CHANGED:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ case WM_INITDIALOG:
+ {
+ HWND hwndTab,hPage;
+ TCITEMA tci = {0};
+ int iTotal;
+ RECT rcClient;
+
+ hwndTab = GetDlgItem(hwndDlg, IDC_OPTIONSTAB);
+ TabCtrl_DeleteAllItems(hwndTab);
+ GetClientRect(GetParent(hwndTab), &rcClient);
+
+ hPage=CreateDialog(hinstance, MAKEINTRESOURCE(IDD_OPTLOGIN), hwndDlg, DlgProcOpts2);
+ iTotal = TabCtrl_GetItemCount(hwndTab);
+ tci.mask = TCIF_PARAM|TCIF_TEXT;
+ tci.lParam = (LPARAM)hPage;
+ tci.pszText = Translate("Account");
+ SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tci);
+ MoveWindow(hPage, 3, 24, rcClient.right - 6, rcClient.bottom - 28, 1);
+ iTotal++;
+
+
+ hPage=CreateDialog(hinstance, MAKEINTRESOURCE(IDD_OPTFEAT), hwndDlg, DlgProcOpts3);
+ ShowWindow(hPage,FALSE);
+ iTotal = TabCtrl_GetItemCount(hwndTab);
+ tci.mask = TCIF_PARAM|TCIF_TEXT;
+ tci.lParam = (LPARAM)hPage;
+ tci.pszText = Translate("Features");
+ SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tci);
+ MoveWindow(hPage, 3, 24, rcClient.right - 6, rcClient.bottom - 28, 1);
+ iTotal++;
+
+ hPage=CreateDialog(hinstance, MAKEINTRESOURCE(IDD_OPTFEAT2), hwndDlg, DlgProcOpts4);
+ ShowWindow(hPage,FALSE);
+ iTotal = TabCtrl_GetItemCount(hwndTab);
+ tci.mask = TCIF_PARAM|TCIF_TEXT;
+ tci.lParam = (LPARAM)hPage;
+ tci.pszText = Translate("Blocklist / Games");
+ SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tci);
+ MoveWindow(hPage, 3, 24, rcClient.right - 6, rcClient.bottom - 28, 1);
+ iTotal++;
+
+ hPage=CreateDialog(hinstance, MAKEINTRESOURCE(IDD_OPTFEAT3), hwndDlg, DlgProcOpts5);
+ ShowWindow(hPage,FALSE);
+ iTotal = TabCtrl_GetItemCount(hwndTab);
+ tci.mask = TCIF_PARAM|TCIF_TEXT;
+ tci.lParam = (LPARAM)hPage;
+ tci.pszText = Translate("StatusMsg");
+ SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tci);
+ MoveWindow(hPage, 3, 24, rcClient.right - 6, rcClient.bottom - 28, 1);
+ iTotal++;
+
+ hPage=CreateDialog(hinstance, MAKEINTRESOURCE(IDD_OPTFEAT4), hwndDlg, DlgProcOpts6);
+ ShowWindow(hPage,FALSE);
+ iTotal = TabCtrl_GetItemCount(hwndTab);
+ tci.mask = TCIF_PARAM|TCIF_TEXT;
+ tci.lParam = (LPARAM)hPage;
+ tci.pszText = Translate("Games");
+ SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tci);
+ MoveWindow(hPage, 3, 24, rcClient.right - 6, rcClient.bottom - 28, 1);
+ iTotal++;
+
+ TabCtrl_SetCurSel(hwndTab, 0);
+
+ return TRUE;
+ }
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->idFrom)
+ {
+ case 0:
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case PSN_APPLY:
+ {
+ TCITEM tci;
+ int i,count;
+
+ tci.mask = TCIF_PARAM;
+ count = TabCtrl_GetItemCount(GetDlgItem(hwndDlg,IDC_OPTIONSTAB));
+ for (i=0; i<count; i++)
+ {
+ TabCtrl_GetItem(GetDlgItem(hwndDlg,IDC_OPTIONSTAB),i,&tci);
+ SendMessage((HWND)tci.lParam,WM_NOTIFY,0,lParam);
+ }
+ break;
+ }
+ }
+ break;
+
+ case IDC_OPTIONSTAB:
+ {
+ HWND hTabCtrl = GetDlgItem(hwndDlg, IDC_OPTIONSTAB);
+
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case TCN_SELCHANGING:
+ {
+ TCITEM tci;
+
+ tci.mask = TCIF_PARAM;
+ TabCtrl_GetItem(hTabCtrl, TabCtrl_GetCurSel(hTabCtrl), &tci);
+ ShowWindow((HWND)tci.lParam, SW_HIDE);
+ }
+ break;
+
+ case TCN_SELCHANGE:
+ {
+ TCITEM tci;
+
+ tci.mask = TCIF_PARAM;
+ TabCtrl_GetItem(hTabCtrl, TabCtrl_GetCurSel(hTabCtrl), &tci);
+ ShowWindow((HWND)tci.lParam,SW_SHOW);
+ }
+ break;
+ }
+ break;
+ }
+ }
+ break;
+ }
+
+ return FALSE;
+}
+
+int OptInit(WPARAM wParam,LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp;
+
+ ghwndDlg2=NULL;
+
+ ZeroMemory(&odp,sizeof(odp));
+ odp.cbSize=sizeof(odp);
+ //odp.position=-790000000;
+ odp.hInstance=hinstance;
+ odp.pszTemplate=MAKEINTRESOURCE(IDD_OPT);
+ odp.pszTitle=Translate("XFire");
+ odp.pszGroup = Translate("Network");
+ odp.flags=ODPF_BOLDGROUPS;
+ //odp.nIDBottomSimpleControl=IDC_GROUPMAIN;
+ odp.pfnDlgProc=DlgProcOpts;
+ Options_AddPage(wParam, &odp);
+
+ return 0;
+} \ No newline at end of file
diff --git a/protocols/Xfire/src/otherloginpacket.cpp b/protocols/Xfire/src/otherloginpacket.cpp
new file mode 100644
index 0000000000..d0d16fb41e
--- /dev/null
+++ b/protocols/Xfire/src/otherloginpacket.cpp
@@ -0,0 +1,37 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "otherloginpacket.h"
+#include "xfireparse.h"
+#include "variablevalue.h"
+#include "xdebug.h"
+
+namespace xfirelib {
+ using namespace std;
+
+ void OtherLoginPacket::parseContent(char *buf, int length, int numberOfAtts) {
+ XINFO(("Someone login in with the same account that we have\n"));
+ }
+
+};
diff --git a/protocols/Xfire/src/otherloginpacket.h b/protocols/Xfire/src/otherloginpacket.h
new file mode 100644
index 0000000000..4f1168e427
--- /dev/null
+++ b/protocols/Xfire/src/otherloginpacket.h
@@ -0,0 +1,46 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __OTHERLOGINPACKET_H
+#define __OTHERLOGINPACKET_H
+
+#include "xfirerecvpacketcontent.h"
+#include "variablevalue.h"
+
+#define XFIRE_OTHER_LOGIN 145
+
+namespace xfirelib {
+
+ class OtherLoginPacket : public XFireRecvPacketContent {
+ public:
+ XFirePacketContent* newPacket() { return new OtherLoginPacket(); }
+
+ int getPacketId() { return XFIRE_OTHER_LOGIN; }
+ int getPacketContent(char *buf) { return 0; }
+ int getPacketAttributeCount() { return 0; };
+ int getPacketSize() { return 1024; };
+ void parseContent(char *buf, int length, int numberOfAtts);
+ };
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/packetlistener.h b/protocols/Xfire/src/packetlistener.h
new file mode 100644
index 0000000000..5702affcff
--- /dev/null
+++ b/protocols/Xfire/src/packetlistener.h
@@ -0,0 +1,41 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __PACKETLISTENER_H
+#define __PACKETLISTENER_H
+
+#include "xfirepacket.h"
+
+
+namespace xfirelib {
+ struct XFirePacket;
+
+ class PacketListener {
+ public:
+ virtual ~PacketListener() { }
+ virtual void receivedPacket(XFirePacket *packet) = 0;
+ };
+
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/packetreader.cpp b/protocols/Xfire/src/packetreader.cpp
new file mode 100644
index 0000000000..d06c480a6e
--- /dev/null
+++ b/protocols/Xfire/src/packetreader.cpp
@@ -0,0 +1,163 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "packetreader.h"
+
+#include <iostream>
+#include "xfirepacket.h"
+
+#include "clientinformationpacket.h"
+#include "authpacket.h"
+#include "loginfailedpacket.h"
+#include "loginsuccesspacket.h"
+#include "buddylistonlinepacket.h"
+#include "buddylistnamespacket.h"
+#include "clanbuddylistnamespacket.h"
+#include "xfireclanpacket.h"
+#include "buddylistgamespacket.h"
+#include "buddylistgames2packet.h"
+#include "messagepacket.h"
+#include "otherloginpacket.h"
+#include "invitebuddypacket.h"
+#include "inviterequestpacket.h"
+#include "recvremovebuddypacket.h"
+#include "recvstatusmessagepacket.h"
+#include "recvoldversionpacket.h"
+#include "recvdidpacket.h"
+#include "recvprefspacket.h"
+#include "gameinfopacket.h"
+#include "claninvitationpacket.h"
+#include "xfirefoundbuddys.h"
+#include "buddyinfo.h"
+#include "friendsoffriendlist.h"
+#include "recvbuddychangednick.h"
+
+#include "xdebug.h"
+//#include "packetlistener.h"
+
+namespace xfirelib {
+ using namespace std;
+
+ PacketReader::PacketReader(Socket *socket) {
+ this->socket = socket;
+ this->packetListeners = new vector<PacketListener *>();
+
+ initPackets();
+ }
+ void PacketReader::setSocket(Socket *socket) {
+ this->socket = socket;
+ }
+ PacketReader::~PacketReader() {
+ // TODO: delete each packetListener ..
+ delete packetListeners;
+
+ while(!packets->empty()) { delete packets->at(packets->size()-1); packets->pop_back(); }
+ delete packets;
+ }
+
+ void PacketReader::initPackets() {
+ packets = new vector <XFirePacketContent *>();
+ packets->push_back( new ClientInformationPacket() );
+ packets->push_back( new AuthPacket() );
+ packets->push_back( new LoginFailedPacket() );
+ packets->push_back( new LoginSuccessPacket() );
+ packets->push_back( new MessagePacket() );
+ packets->push_back( new BuddyListOnlinePacket() );
+ packets->push_back( new BuddyListNamesPacket() );
+ packets->push_back( new BuddyListGamesPacket() );
+ packets->push_back( new BuddyListGames2Packet() );
+ packets->push_back( new OtherLoginPacket() );
+ packets->push_back( new InviteBuddyPacket() );
+ packets->push_back( new InviteRequestPacket() );
+ packets->push_back( new RecvRemoveBuddyPacket() );
+ packets->push_back( new RecvDidPacket() );
+ packets->push_back( new RecvStatusMessagePacket() );
+ packets->push_back( new RecvOldVersionPacket() );
+ packets->push_back( new RecvPrefsPacket() );
+ //neue packetklassen hinzugefügt - dufte
+ packets->push_back( new FriendsBuddyListNamesPacket() );
+ packets->push_back( new ClanBuddyListNamesPacket() );
+ packets->push_back( new XFireClanPacket() );
+ packets->push_back( new GameInfoPacket() );
+ packets->push_back( new ClanInvitationPacket() );
+ packets->push_back( new XFireFoundBuddys() );
+ packets->push_back( new BuddyInfoPacket() );
+ packets->push_back( new RecvBuddyChangedNick() );
+ }
+
+
+ void *muh(void *ptr);
+
+ /* I moved thread starting to Client
+
+ void PacketReader::startListening() {
+ PacketReader *myself = this;
+ void* (*func)(void*) = &xfirelib::PacketReader::thread_start;
+ XINFO(("About to start thread\n"));
+ int ret = pthread_create( &readthread, NULL, func, (void*)myself );
+ XDEBUG(("ret: %d\n",ret));
+ }
+ */
+
+ void PacketReader::run() {
+ // start receiving on socket...
+ XDEBUG(("Starting run() method .... \n"));
+ while(socket != NULL) {
+ string str;
+ //int b = socket->recv(str);
+ XFirePacket *packet = new XFirePacket(this);
+ XDEBUG(("Waiting for next packet ... \n"));
+ if(packet==NULL) continue;
+ packet->recvPacket( socket );
+ XINFO(("Received packet\n"));
+ if(packet->getContent() != NULL) {
+ fireListeners( packet );
+ } else {
+ XDEBUG(("Packet Content was NULL ... Unknown Packet Id ??\n"));
+ }
+ XDEBUG(("Notified Listeners\n"));// << b << "bytes: " << str << endl;
+ delete packet->getContent();
+ delete packet;
+ }
+ }
+
+ void PacketReader::fireListeners( XFirePacket *packet ) {
+ for(vector<PacketListener *>::iterator it = packetListeners->begin() ;
+ it != packetListeners->end() ; ++it) {
+ (*it)->receivedPacket( packet );
+ }
+ }
+
+ XFirePacketContent *PacketReader::getPacketContentClass(int packetId) {
+ XDEBUG(("Searching for a content class...\n"));
+ for(uint i = 0 ; i < packets->size() ; i++)
+ if(packets->at(i)->getPacketId() == packetId) return packets->at(i);
+ XDEBUG(("None Found\n"));
+ return NULL;
+ }
+
+ void PacketReader::addPacketListener( PacketListener *listener ) {
+ packetListeners->push_back( listener );
+ }
+};
diff --git a/protocols/Xfire/src/packetreader.h b/protocols/Xfire/src/packetreader.h
new file mode 100644
index 0000000000..6108500565
--- /dev/null
+++ b/protocols/Xfire/src/packetreader.h
@@ -0,0 +1,57 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "socket.h"
+
+#ifndef __PACKETREADER_H
+#define __PACKETREADER_H
+
+#include <vector>
+#include "xfirepacketcontent.h"
+#include "packetlistener.h"
+
+namespace xfirelib {
+ struct PacketListener;
+ struct XFirePacket;
+
+class PacketReader {
+ public:
+ PacketReader(Socket *socket);
+ ~PacketReader();
+
+ void setSocket(Socket *socket);
+ void startListening();
+ XFirePacketContent *getPacketContentClass(int packetId);
+ void addPacketListener( PacketListener *listener );
+ void run();
+ private:
+ void initPackets();
+ void fireListeners( XFirePacket *packet );
+
+ Socket *socket;
+ std::vector <XFirePacketContent *> *packets;
+ std::vector <PacketListener *> *packetListeners;
+};
+
+};
+
+#endif
diff --git a/protocols/Xfire/src/passworddialog.cpp b/protocols/Xfire/src/passworddialog.cpp
new file mode 100644
index 0000000000..7b2202c24f
--- /dev/null
+++ b/protocols/Xfire/src/passworddialog.cpp
@@ -0,0 +1,59 @@
+//fürs passwort dialog - dufte
+
+#include "stdafx.h"
+#include "passworddialog.h"
+
+static char nick[255];
+BOOL usenick=FALSE;
+
+BOOL CALLBACK DlgPWProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ static char* pw[255];
+ switch (msg)
+ {
+ case WM_CLOSE:
+ {
+ GetDlgItemTextA(hwndDlg,IDC_PWSTRING,(LPSTR)pw,254);
+ if(usenick)
+ GetDlgItemTextA(hwndDlg,IDC_PWNICK,(LPSTR)nick,254);
+ EndDialog(hwndDlg,(INT_PTR)pw);
+ break;
+ }
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+ //passwort und nick leeren
+ pw[0]=0;
+ nick[0]=0;
+ SendMessage(hwndDlg,WM_SETICON, (WPARAM)false, (LPARAM)LoadIcon(hinstance, MAKEINTRESOURCE(IDI_TM)));
+ if(!usenick)
+ EnableWindow(GetDlgItem(hwndDlg,IDC_PWNICK),FALSE);
+
+ return TRUE;
+ }
+ case WM_COMMAND:
+ {
+ if(LOWORD(wParam) == IDC_BTN4) {
+ SendMessage(hwndDlg,WM_CLOSE,0,0);
+ }
+ break;
+ }
+ }
+ return FALSE;
+}
+
+void ShowPasswordDialog(char*pw,char*mynick) {
+ if(mynick!=NULL)
+ {
+ usenick=TRUE;
+ }
+ else
+ usenick=FALSE;
+
+ char* npw = (char*)DialogBox(hinstance,MAKEINTRESOURCE(IDD_PWDLG),NULL,DlgPWProc);
+ strcpy(pw,npw);
+ if(mynick)
+ {
+ strcpy(mynick,(char*)nick);
+ }
+} \ No newline at end of file
diff --git a/protocols/Xfire/src/passworddialog.h b/protocols/Xfire/src/passworddialog.h
new file mode 100644
index 0000000000..4078c766df
--- /dev/null
+++ b/protocols/Xfire/src/passworddialog.h
@@ -0,0 +1,4 @@
+#include "baseProtocol.h"
+#include "resource.h"
+
+void ShowPasswordDialog(char*pw,char*mynick=NULL); \ No newline at end of file
diff --git a/protocols/Xfire/src/processbuddyinfo.cpp b/protocols/Xfire/src/processbuddyinfo.cpp
new file mode 100644
index 0000000000..e5e6fb6af7
--- /dev/null
+++ b/protocols/Xfire/src/processbuddyinfo.cpp
@@ -0,0 +1,111 @@
+#include "stdafx.h"
+#include "processbuddyinfo.h"
+
+#include <sys\stat.h>
+
+
+/*
+DBWriteContactSettingTString(xsa->hContact, "ContactPhoto", "Backup", av.backup);
+DBWriteContactSettingTString(xsa->hContact, "ContactPhoto", "File", av.file);
+DBWriteContactSettingTString(xsa->hContact, "ContactPhoto", "RFile", av.rfile);
+DBWriteContactSettingWord(xsa->hContact, "ContactPhoto", "Format", av.type);
+*/
+
+extern HANDLE XFireAvatarFolder;
+
+//vom Yahoo plugin
+/*int avt_hash(const char *key, DWORD ksize)
+{
+ const char *p = key;
+ int h = *p;
+ long l = 1;
+
+ if (h)
+ for (p += 1; l < ksize; p++, l++)
+ h = (h << 5) - h + *p;
+
+ return h;
+}*/
+
+void ProcessBuddyInfo(xfirelib::BuddyInfoPacket *buddyinfo,HANDLE hcontact,char* username) {
+ char temp[512]="";
+ char filename[512];
+ BOOL dl=FALSE;
+ int type;
+
+ //versuche doppeltes laden zuvermeiden
+ if(hcontact) //avatar von freunden
+ {
+ if(DBGetContactSettingDword(hcontact, "ContactPhoto", "XFireAvatarId", 0)==buddyinfo->avatarid &&
+ DBGetContactSettingByte(hcontact, "ContactPhoto", "XFireAvatarMode", 0)==buddyinfo->avatarmode)
+ return;
+ }
+ else //eigeneder avatar
+ {
+ if(DBGetContactSettingDword(hcontact, protocolname, "XFireAvatarId", 0)==buddyinfo->avatarid &&
+ DBGetContactSettingByte(hcontact, protocolname, "XFireAvatarMode", 0)==buddyinfo->avatarmode)
+ return;
+
+ //alten dateipfad des avatars löschen, wenn sichw as geändert hat
+ DBDeleteContactSetting(NULL,protocolname, "MyAvatarFile");
+ }
+
+ FoldersGetCustomPath( XFireAvatarFolder, filename, 1024, "" );
+ strcat(filename,"\\");
+
+ switch(buddyinfo->avatarmode) {
+ case 1:
+ strcat(filename,username);
+ strcat(filename,".gif");
+ type=PA_FORMAT_GIF;
+
+ sprintf(temp,"/xfire/xf/images/avatars/gallery/default/%03d.gif",buddyinfo->avatarid);
+
+ dl=GetWWWContent("media.xfire.com",temp,filename,FALSE);
+ break;
+ case 2:
+ strcat(filename,username);
+ strcat(filename,".jpg");
+ type=PA_FORMAT_JPEG;
+
+ sprintf(temp,"/avatar/100/%s.jpg?%d",username,buddyinfo->avatarid);
+
+ dl=GetWWWContent("screenshot.xfire.com",temp,filename,FALSE);
+ break;
+ case 3:
+ type=PA_FORMAT_GIF;
+ strcat(filename,"xfire.gif");
+
+ sprintf(temp,"/xfire/xf/images/avatars/gallery/default/xfire.gif",buddyinfo->avatarid);
+
+ dl=GetWWWContent("media.xfire.com",temp,filename,TRUE);
+ break;
+ default:
+ return;
+ }
+
+
+ if(dl!=FALSE)
+ {
+ if(hcontact) //buddyavatar setzen
+ {
+ DBWriteContactSettingDword(hcontact, "ContactPhoto", "XFireAvatarId", buddyinfo->avatarid);
+ DBWriteContactSettingByte(hcontact, "ContactPhoto", "XFireAvatarMode", buddyinfo->avatarmode);
+ PROTO_AVATAR_INFORMATION AI;
+ AI.cbSize = sizeof(AI);
+ AI.format = type;
+ AI.hContact = hcontact;
+ lstrcpy(AI.filename,filename);
+ ProtoBroadcastAck(protocolname, hcontact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS,(HANDLE) &AI, 0);
+ }
+ else //eigenen avatar setzen
+ {
+ DBWriteContactSettingDword(NULL, protocolname, "XFireAvatarId", buddyinfo->avatarid);
+ DBWriteContactSettingByte(NULL, protocolname, "XFireAvatarMode", buddyinfo->avatarmode);
+ //neuen avatarfilepath eintragen
+ DBWriteContactSettingTString(NULL,protocolname, "MyAvatarFile",filename);
+ //beshceid geben, avatar hat sich geändert
+ CallService(MS_AV_REPORTMYAVATARCHANGED,(WPARAM)protocolname,0);
+ }
+ }
+} \ No newline at end of file
diff --git a/protocols/Xfire/src/processbuddyinfo.h b/protocols/Xfire/src/processbuddyinfo.h
new file mode 100644
index 0000000000..0964ef983b
--- /dev/null
+++ b/protocols/Xfire/src/processbuddyinfo.h
@@ -0,0 +1,7 @@
+//funktion soll avatar runterladen und dem buddy zuordnen
+#include "baseProtocol.h"
+#include "resource.h"
+#include "getbuddyinfo.h"
+#include "buddyinfo.h"
+
+void ProcessBuddyInfo(xfirelib::BuddyInfoPacket *buddyinfo,HANDLE hcontact,char* username); \ No newline at end of file
diff --git a/protocols/Xfire/src/pwd_dlg.cpp b/protocols/Xfire/src/pwd_dlg.cpp
new file mode 100644
index 0000000000..e2668b96d7
--- /dev/null
+++ b/protocols/Xfire/src/pwd_dlg.cpp
@@ -0,0 +1,53 @@
+//fürs nick - dialog
+
+#include "stdafx.h"
+#include "pwd_dlg.h"
+
+char password[256]="";
+
+BOOL CALLBACK DlgPwProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ SetWindowText(hwndDlg, "Please enter server password ...");
+ TranslateDialogDefault(hwndDlg);
+ SendMessage(hwndDlg,WM_SETICON, (WPARAM)false, (LPARAM)LoadIcon(hinstance, MAKEINTRESOURCE(IDI_TM)));
+ return TRUE;
+ }
+ case WM_COMMAND:
+ {
+ if(LOWORD(wParam) == IDOK)
+ {
+ GetDlgItemText(hwndDlg,IDC_NICKNAME,password,sizeof(password));
+ EndDialog(hwndDlg,TRUE);
+ return TRUE;
+ }
+ else if(LOWORD(wParam) == IDCANCEL)
+ {
+ EndDialog(hwndDlg,FALSE);
+ return FALSE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+BOOL ShowPwdDlg(char* pw) {
+ //kein gültiges ziel für das eingegebene passwort
+ if(&pw==NULL)
+ return FALSE;
+
+ if(DialogBox(hinstance,MAKEINTRESOURCE(IDD_SETNICKNAME),NULL,DlgPwProc))
+ {
+ //passwort kopieren
+ if(*password == 0)
+ return FALSE;
+
+ strcpy_s(pw,255,password);
+ return TRUE;
+ }
+
+ return FALSE;
+} \ No newline at end of file
diff --git a/protocols/Xfire/src/pwd_dlg.h b/protocols/Xfire/src/pwd_dlg.h
new file mode 100644
index 0000000000..022c63de9f
--- /dev/null
+++ b/protocols/Xfire/src/pwd_dlg.h
@@ -0,0 +1,4 @@
+#include "baseProtocol.h"
+#include "resource.h"
+
+BOOL ShowPwdDlg(char* pw); \ No newline at end of file
diff --git a/protocols/Xfire/src/recvbuddychangednick.cpp b/protocols/Xfire/src/recvbuddychangednick.cpp
new file mode 100644
index 0000000000..f48b8da043
--- /dev/null
+++ b/protocols/Xfire/src/recvbuddychangednick.cpp
@@ -0,0 +1,48 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "recvbuddychangednick.h"
+#include "variablevalue.h"
+
+//packet liest neue nicks ein
+
+namespace xfirelib {
+ using namespace std;
+
+ void RecvBuddyChangedNick::parseContent(char *buf, int length, int numberOfAtts) {
+ VariableValue val;
+ int index = 0;
+ index +=2; // Ignore 02 01 02 ??
+ index += val.readValue(buf,index,4);
+ userid = val.getValueAsLong();
+ index +=2; // Ignore 0d 01
+ int l = (unsigned char)buf[index++];
+ index++;
+ index += val.readValue(buf,index,l);
+ string stringvalue = string(val.getValue(),l);
+ this->newnick=stringvalue;
+ }
+
+};
diff --git a/protocols/Xfire/src/recvbuddychangednick.h b/protocols/Xfire/src/recvbuddychangednick.h
new file mode 100644
index 0000000000..6c3ae08e05
--- /dev/null
+++ b/protocols/Xfire/src/recvbuddychangednick.h
@@ -0,0 +1,52 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __RECVBUDDYCHANGEDNICK_H
+#define __RECVBUDDYCHANGEDNICK_H
+
+//packet liest neue nicks ein
+
+#include "xfirerecvpacketcontent.h"
+#include <string>
+
+#define XFIRE_RECVBUDDYCHANGEDNICK 161
+
+namespace xfirelib {
+ class RecvBuddyChangedNick : public XFireRecvPacketContent {
+ public:
+ virtual ~RecvBuddyChangedNick() { }
+ int getPacketId() { return XFIRE_RECVBUDDYCHANGEDNICK; }
+
+ XFirePacketContent *newPacket() { return new RecvBuddyChangedNick(); }
+ void parseContent(char *buf, int length, int numberOfAtts);
+
+ long userid;
+
+ std::string newnick;
+ void* entry; // handle eingefügt, damit ich schnell den buddy killen kann - dufte
+ };
+
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/recvdidpacket.cpp b/protocols/Xfire/src/recvdidpacket.cpp
new file mode 100644
index 0000000000..ee0925c724
--- /dev/null
+++ b/protocols/Xfire/src/recvdidpacket.cpp
@@ -0,0 +1,35 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "recvdidpacket.h"
+#include "variablevalue.h"
+#include "xdebug.h"
+
+namespace xfirelib {
+
+ void RecvDidPacket::parseContent(char *buf, int length, int numberOfAtts) {
+ XDEBUG(("This is the useles DID packet, its realy useless\n"));
+ }
+
+};
diff --git a/protocols/Xfire/src/recvdidpacket.h b/protocols/Xfire/src/recvdidpacket.h
new file mode 100644
index 0000000000..92e09ff2f3
--- /dev/null
+++ b/protocols/Xfire/src/recvdidpacket.h
@@ -0,0 +1,43 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __RECVDIDPACKET_H
+#define __RECVDIDPACKET_H
+
+#include "xfirerecvpacketcontent.h"
+
+#define XFIRE_RECVDIDPACKET 144
+
+namespace xfirelib {
+ class RecvDidPacket : public XFireRecvPacketContent {
+ public:
+ virtual ~RecvDidPacket() { }
+ int getPacketId() { return XFIRE_RECVDIDPACKET; }
+
+ XFirePacketContent *newPacket() { return new RecvDidPacket(); }
+ void parseContent(char *buf, int length, int numberOfAtts);
+ };
+
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/recvoldversionpacket.cpp b/protocols/Xfire/src/recvoldversionpacket.cpp
new file mode 100644
index 0000000000..635d69352a
--- /dev/null
+++ b/protocols/Xfire/src/recvoldversionpacket.cpp
@@ -0,0 +1,42 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "recvoldversionpacket.h"
+
+#include "variablevalue.h"
+#include "xdebug.h"
+#include <vector>
+#include <string>
+
+namespace xfirelib {
+ class RecvOldVersionPacket;
+
+ RecvOldVersionPacket::RecvOldVersionPacket() : XFireRecvPacketContent() {
+ }
+
+ void RecvOldVersionPacket::parseContent(char *buf, int length, int numberOfAtts) {
+ //aktuelle version
+ this->newversion=buf[12];
+ }
+};
diff --git a/protocols/Xfire/src/recvoldversionpacket.h b/protocols/Xfire/src/recvoldversionpacket.h
new file mode 100644
index 0000000000..46bc1d6ccc
--- /dev/null
+++ b/protocols/Xfire/src/recvoldversionpacket.h
@@ -0,0 +1,48 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __RECVOLDVERSIONPACKET_H
+#define __RECVOLDVERSIONPACKET_H
+
+#define XFIRE_RECV_OLDVERSION_PACKET_ID 134
+
+#include "xfirerecvpacketcontent.h"
+
+namespace xfirelib {
+
+ class RecvOldVersionPacket : public XFireRecvPacketContent {
+ public:
+ RecvOldVersionPacket();
+ virtual ~RecvOldVersionPacket() { }
+ XFirePacketContent *newPacket() { return new RecvOldVersionPacket; }
+ int getPacketId() { return XFIRE_RECV_OLDVERSION_PACKET_ID; }
+
+ void parseContent(char *buf, int length, int numberOfAtts);
+
+ char newversion;
+
+ };
+
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/recvprefspacket.cpp b/protocols/Xfire/src/recvprefspacket.cpp
new file mode 100644
index 0000000000..faad9ce964
--- /dev/null
+++ b/protocols/Xfire/src/recvprefspacket.cpp
@@ -0,0 +1,107 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "recvprefspacket.h"
+#include "variablevalue.h"
+#include "xdebug.h"
+
+namespace xfirelib {
+
+ void RecvPrefsPacket::parseContent(char *buf, int length, int numberOfAtts) {
+ int index = 0;
+
+ memset(&this->config,0,sizeof(xfire_prefitem)*XFIRE_RECVPREFSPACKET_MAXCONFIGS);
+
+ XDEBUG("This packet gives us the preferences that you can set with the official client.\n");
+
+ //skip 4c,09
+ index+=2;
+
+ //anzahl an konfigurationen welche abgestellt wurden
+ int anz=buf[index];
+ XDEBUG2("%d disabled Configs\n",anz);
+
+ index++;
+
+ for(int i=0;i<anz;i++)
+ {
+ int kid=buf[index];
+ XDEBUG2("Konfigid: %d\n",kid);
+
+ if(kid<XFIRE_RECVPREFSPACKET_MAXCONFIGS&&kid>0)
+ {
+ config[kid].wasset=1;
+ for(int j=0;j<4;j++)
+ {
+ index++;
+ config[kid].data[j]=buf[index];
+ }
+ }
+
+ XDEBUG2("Konfigval: %d\n",buf[index]);
+ index++;
+ }
+
+
+ }
+
+ //prefences packet vorbereiten
+ int PrefsPacket::getPacketContent(char *buf) {
+ int index = 0;
+
+ buf[index++]=5;
+ buf[index++]='p';
+ buf[index++]='r';
+ buf[index++]='e';
+ buf[index++]='f';
+ buf[index++]='s';
+
+ buf[index++]=9;
+
+ //anzahlindex zwischenspeichern
+ int anzindex=index;
+ index++;
+
+ int anz=0;
+ for(int j=0;j<XFIRE_RECVPREFSPACKET_MAXCONFIGS;j++)
+ {
+ if(this->config[j].wasset==1)
+ {
+ buf[index++]=j;
+ buf[index++]=this->config[j].data[0];
+ buf[index++]=this->config[j].data[1];
+ buf[index++]=this->config[j].data[2];
+ buf[index++]=this->config[j].data[3];
+ anz++;
+ }
+ }
+
+ buf[anzindex]=anz;
+
+ return index;
+ }
+
+
+};
diff --git a/protocols/Xfire/src/recvprefspacket.h b/protocols/Xfire/src/recvprefspacket.h
new file mode 100644
index 0000000000..24683f870b
--- /dev/null
+++ b/protocols/Xfire/src/recvprefspacket.h
@@ -0,0 +1,81 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __RECVPREFSPACKET_H
+#define __RECVPREFSPACKET_H
+
+#include "xfirerecvpacketcontent.h"
+#include "xfiresendpacketcontent.h"
+
+#define XFIRE_RECVPREFSPACKET 141
+#define XFIRE_SENDPREFSPACKET 0xa
+
+#define XFIRE_RECVPREFSPACKET_MAXCONFIGS 32
+#define XFIRE_RECVPREFSPACKET_SUPPORTEDONFIGS 7
+
+//zum zwischenspeichern, wird später benötigt zum versenden
+struct xfire_prefitem {
+ unsigned char data[4];
+ unsigned char wasset;
+};
+
+//für die optionen
+struct xfireconfigitem {
+ unsigned long id;
+ char xfireconfigid;
+ char dbentry[256];
+};
+
+namespace xfirelib {
+
+ //packet mit den preferences
+ class RecvPrefsPacket : public XFireRecvPacketContent {
+ public:
+ virtual ~RecvPrefsPacket() { }
+ int getPacketId() { return XFIRE_RECVPREFSPACKET; }
+
+ XFirePacketContent *newPacket() { return new RecvPrefsPacket(); }
+ void parseContent(char *buf, int length, int numberOfAtts);
+
+ //array vorbereiten, eventuell auf 32 bytes aufstocken, man weis ja nie was kommt
+ xfire_prefitem config[XFIRE_RECVPREFSPACKET_MAXCONFIGS];
+ };
+
+ //packet zum setzen neuer preferences
+ class PrefsPacket : public XFireSendPacketContent {
+ public:
+ virtual ~PrefsPacket() { }
+
+ XFirePacketContent *newPacket() { return new PrefsPacket; }
+ int getPacketId() { return XFIRE_SENDPREFSPACKET; }
+
+ int getPacketContent(char *buf);
+ int getPacketAttributeCount() { return 1; }
+ int getPacketSize() { return 1024; }
+
+ xfire_prefitem config[XFIRE_RECVPREFSPACKET_MAXCONFIGS];
+ };
+
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/recvremovebuddypacket.cpp b/protocols/Xfire/src/recvremovebuddypacket.cpp
new file mode 100644
index 0000000000..1e9b14d939
--- /dev/null
+++ b/protocols/Xfire/src/recvremovebuddypacket.cpp
@@ -0,0 +1,39 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "recvremovebuddypacket.h"
+#include "variablevalue.h"
+
+namespace xfirelib {
+
+ void RecvRemoveBuddyPacket::parseContent(char *buf, int length, int numberOfAtts) {
+ VariableValue val;
+ int index = 0;
+ index += val.readName(buf,index);
+ index ++; // Ignore 02 ??
+ index += val.readValue(buf,index,4);
+ userid = val.getValueAsLong();
+ }
+
+};
diff --git a/protocols/Xfire/src/recvremovebuddypacket.h b/protocols/Xfire/src/recvremovebuddypacket.h
new file mode 100644
index 0000000000..87c75c0012
--- /dev/null
+++ b/protocols/Xfire/src/recvremovebuddypacket.h
@@ -0,0 +1,56 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __RECVREMOVEBUDDYPACKET_H
+#define __RECVREMOVEBUDDYPACKET_H
+
+#include "xfirerecvpacketcontent.h"
+#include <string>
+
+#define XFIRE_RECVREMOVEBUDDYPACKET 139
+
+namespace xfirelib {
+ class RecvRemoveBuddyPacket : public XFireRecvPacketContent {
+ public:
+ virtual ~RecvRemoveBuddyPacket() { }
+ int getPacketId() { return XFIRE_RECVREMOVEBUDDYPACKET; }
+
+ XFirePacketContent *newPacket() { return new RecvRemoveBuddyPacket(); }
+ void parseContent(char *buf, int length, int numberOfAtts);
+
+ long userid;
+
+ /**
+ * I've added this attribute altough it is not part of the actual packet
+ * because by the time the packet content reaches the client
+ * application the user will no longer be in the BuddyList .. so no
+ * way for the client application to know which buddy was just removed.
+ * (it will be set by the BuddyList, not when parsing the packet)
+ */
+ std::string username;
+ void* handle; // handle eingefügt, damit ich schnell den buddy killen kann - dufte
+ };
+
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/recvstatusmessagepacket.cpp b/protocols/Xfire/src/recvstatusmessagepacket.cpp
new file mode 100644
index 0000000000..38387f424d
--- /dev/null
+++ b/protocols/Xfire/src/recvstatusmessagepacket.cpp
@@ -0,0 +1,80 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "recvstatusmessagepacket.h"
+
+#include "variablevalue.h"
+#include "xdebug.h"
+#include <vector>
+#include <string>
+
+namespace xfirelib {
+ RecvStatusMessagePacket::RecvStatusMessagePacket() {
+ centries=0;
+ }
+
+ void RecvStatusMessagePacket::parseContent(char *buf, int length, int numberOfAtts) {
+ int index = 0;
+ int numberOfIds = 0;
+ VariableValue val;
+ index += val.readName(buf,index);
+ index ++; // ignore 03 ??
+ index ++; // jump to counter
+ numberOfIds = (unsigned char) buf[index];
+ index ++; // Ignore 00 ??
+ index ++;
+ sids = new std::vector<char *>;
+ for(int i = 0 ; i < numberOfIds ; i++) {
+ index += val.readValue(buf,index,16);
+ char *sid = new char[16];
+ memcpy(sid,val.getValue(),16);
+ sids->push_back(sid);
+ }
+
+ index += val.readName(buf,index);
+ XDEBUG(( "valname %s\n", val.getName().c_str() ));
+ index ++; // Ignore 04 ??
+ msgs = new std::vector<std::string>;
+ index = readStrings(msgs,buf,index);
+
+ }
+
+
+int RecvStatusMessagePacket::readStrings(std::vector<std::string> *strings, char *buf, int index) {
+ VariableValue friends;
+ index += friends.readValue(buf,index);
+ index ++; // Ignore 00
+ int numberOfStrings = friends.getValueAsLong();
+ XDEBUG3( "name: %s numberOfStrings: %d\n", friends.getName().c_str(), numberOfStrings );
+ for(int i = 0 ; i < numberOfStrings ; i++) {
+ int length = (unsigned char)buf[index++];
+ index++;
+ index += friends.readValue(buf,index,length);
+ std::string stringvalue = std::string(friends.getValue(),length);
+ strings->push_back(stringvalue);
+ XDEBUG3( "String length: %2d : %s\n", length, stringvalue.c_str() );
+ }
+ return index;
+ }
+};
diff --git a/protocols/Xfire/src/recvstatusmessagepacket.h b/protocols/Xfire/src/recvstatusmessagepacket.h
new file mode 100644
index 0000000000..95e61fab12
--- /dev/null
+++ b/protocols/Xfire/src/recvstatusmessagepacket.h
@@ -0,0 +1,57 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __RECVMESSAGEPACKET_H
+#define __RECVMESSAGEPACKET_H
+
+#define XFIRE_RECV_STATUSMESSAGE_PACKET_ID 154
+
+#include "xfirerecvpacketcontent.h"
+#include "buddylist.h"
+#include <string>
+#include <vector>
+
+namespace xfirelib {
+
+ class RecvStatusMessagePacket : public XFireRecvPacketContent {
+ public:
+ RecvStatusMessagePacket();
+ virtual ~RecvStatusMessagePacket() { }
+ XFirePacketContent *newPacket() { return new RecvStatusMessagePacket; }
+ int getPacketId() { return XFIRE_RECV_STATUSMESSAGE_PACKET_ID; }
+
+ void parseContent(char *buf, int length, int numberOfAtts);
+ char * getSid(int i){ return sids->at(i); }
+
+ std::vector<char *> *sids;
+ std::vector<std::string> *msgs;
+ BuddyListEntry** entries;
+ int centries;
+
+ private:
+ int readStrings(std::vector<std::string> *strings, char *buf, int index);
+ };
+
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/resource.h b/protocols/Xfire/src/resource.h
new file mode 100644
index 0000000000..5d2cbd8a4e
--- /dev/null
+++ b/protocols/Xfire/src/resource.h
@@ -0,0 +1,173 @@
+#define IDC_APPLY 1331
+#define ID_OP 13
+#define IDI_TM 14
+#define IDC_STC1 1
+#define IDC_NICK 2
+#define IDC_GRP1 11
+#define IDC_NOAV 12
+#define IDC_NOMSG 3
+#define IDC_GRP2 3
+#define IDC_GRP3 4
+#define IDC_GRP4 17
+#define IDC_SETUPGAMES 10551
+#define IDC_STC2 1
+#define IDC_STC3 2
+#define IDC_STC4 5
+#define IDC_GAME 6
+#define IDC_GRP5 88
+#define IDC_STC6 77
+#define IDC_STC8 55
+#define IDC_STC5 7
+#define IDC_GIP 8
+#define IDC_STC7 9
+#define IDC_GPORT 10
+#define IDC_VNAME 11
+#define IDC_STC10 12
+#define IDC_STC11 13
+#define IDC_VIP 14
+#define IDC_STC13 15
+#define IDC_VPORT 16
+#define IDC_DNICK 18
+#define IDC_DUSERNAME 19
+#define IDC_GAMEICO 100
+#define IDC_VOICEICO 200
+#define IDC_COPYGAME 1001
+#define IDC_COPYVOICE 1002
+#define IDC_STATIC -1
+#define IDI_ONLINE 104
+#define IDI_OFFLINE 105
+#define IDI_AWAY 128
+#define IDC_NOIPPORT 1007
+#define IDC_ONINAFK 1008
+#define IDI_TEST 10
+#define IDC_CHKI 1072
+#define IDD_OPT 102
+#define IDD_UD 1000
+#define IDD_UD2 1001
+#define IDC_CBGICO 1013
+#define IDC_CBVICO 1015
+#define IDC_GROUPCONFIG 1000
+#define IDC_GROUPMAIN 1002
+#define IDC_KEEPALIVE 1011
+#define IDC_PASSWORD 1020
+#define IDC_LOGIN 1022
+#define IDC_SERVER 1171
+#define IDC_SERVERPORT 1174
+#define IDC_STATIC -1
+#define IDC_STATIC -1
+#define IDC_STC9 1001
+#define IDC_NOCLANGROUP 5001
+#define IDC_BTN1 5002
+#define IDC_GRP6 1202
+#define IDC_PROFILIMG 1601
+#define IDC_SCANALWAYS 1621
+#define IDC_STC12 1702
+#define IDC_STC14 1804
+#define IDC_CHKG 1071
+#define IDC_GAMEINFOLIST 1992
+#define IDC_GRP7 19901
+#define IDC_FINDFILES 1234
+#define IDD_GAMELIST 1009
+#define IDC_LST1 1001
+#define IDC_NEVERD 1004
+#define IDC_RBN2 1005
+#define IDC_MANUAL 1006
+#define IDC_GAMEPATH 1007
+#define IDC_BTN2 1009
+#define IDC_GSQP 1991
+#define IDC_BTN3 1044
+#define IDC_LAUNCH 3002
+#define IDC_STC15 3003
+#define IDC_NOCUSTOMAWAY 91231
+#define IDC_TREE 1921
+#define DM_REBUILD_TREE 87714
+#define IDC_GRP8 10241
+#define IDC_BLOCKUSER 61002
+#define IDC_REMUSER 61003
+#define IDC_INSTALLTYPE 871002
+#define IDC_INSTALLTYPES 1707
+#define IDC_STC16 31001
+#define IDC_PVER 91002
+#define IDD_PWDLG 991000
+#define IDC_STC17 41901
+#define IDC_PWSTRING 1902
+#define IDC_BTN4 12903
+#define IDC_LASTGAME 19901
+#define IDI_JOIN 8888
+#define IDI_COPYGAME 8889
+#define IDI_JOINV 8890
+#define IDI_COPYVOICE 8891
+#define IDC_STC18 1001
+#define IDC_PWNICK 9502
+#define IDC_OPTIONSTAB 9503
+#define IDD_OPTLOGIN 9504
+#define IDD_OPTFEAT 9505
+#define IDD_OPTFEAT2 9506
+#define IDC_URLNEWACC 9507
+#define IDC_FILESSHOULDBE 9508
+#define IDC_PIP 9509
+#define IDC_PPORT 9510
+#define IDC_USEPROXY 9511
+#define IDD_OPTFEAT3 9512
+#define IDC_ENABLESTSMSG 9511
+#define IDC_STATUSMSG 9512
+#define IDD_SETNICKNAME 9513
+#define IDC_NICKNAME 9514
+#define IDC_CHGSTATUS 9515
+#define IDD_SEARCHING 9516
+#define IDC_SEARCHINGLABL 9517
+#define IDC_CURRENTGAME 9518
+#define IDC_LOSTPW 9519
+#define IDC_CLANGROUP 9520
+#define IDC_SCANUPDATECB 9521
+#define IDC_LGAMELIST 9522
+#define IDD_OPTFEAT4 9523
+#define IDC_DONTDETECT 9524
+#define IDC_GAMENAME 9525
+#define IDC_NOSTATUSMSG 9526
+#define IDC_TEXTSTATUS 9527
+#define IDC_KONFIG_1 9528
+#define IDC_KONFIG_2 9529
+#define IDC_KONFIG_3 9530
+#define IDC_KONFIG_4 9531
+#define IDC_KONFIG_5 9532
+#define IDC_KONFIG_6 9533
+#define IDC_KONFIG_7 9534
+#define IDC_FOFGROUP 9535
+#define IDC_WEBC 9536
+#define IDD_UPDATE 9537
+#define IDC_UPDATEGAMES 9538
+#define IDD_ADDGAME 9539
+#define IDC_ADDGAME 9540
+#define IDC_GAMELIST 9541
+#define IDC_PROGRESS 9542
+#define IDC_SEARCH 9543
+#define IDC_REMOVE 9544
+#define IDC_NOTINSTARTMENU 9545
+#define IDC_MANADDED 9546
+#define IDC_DNDFIRST 9547
+#define IDC_EXTRAPARAMS 9548
+#define IDD_ADDGAMEMAIN 9549
+#define IDD_ADDGAME2 9550
+#define IDC_ADD_NAME 9551
+#define IDC_ADD_DETECTEXE 9552
+#define IDC_ADD_BROWSEDETECT 9553
+#define IDC_ADD_LAUNCHEREXE 9554
+#define IDC_ADD_BROWSELAUNCHER 9555
+#define IDC_GAMEIDHELP 9556
+#define IDC_ADD_ID 9557
+#define IDC_ADD_SENDID 9558
+#define IDC_SENDIDHELP 9559
+#define IDC_ADD_STATUSMSG 9560
+#define IDC_EDITGAME 9561
+#define IDC_CREATETXTLIST 9562
+#define IDC_TESTBUTTON 9563
+#define IDC_CUSTOM 9564
+#define IDC_ADD_CUSTOMPARAMS 9565
+#define WM_SETPROFIMAGE WM_USER+10
+#define WM_FILLGAMELIST WM_USER+20
+#define WM_EDITGAMEDLG WM_USER+30
+
+/*
+ end of resource.h
+*/ \ No newline at end of file
diff --git a/protocols/Xfire/src/searchbuddy.cpp b/protocols/Xfire/src/searchbuddy.cpp
new file mode 100644
index 0000000000..716d88438c
--- /dev/null
+++ b/protocols/Xfire/src/searchbuddy.cpp
@@ -0,0 +1,77 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+#include "searchbuddy.h"
+#include <string.h>
+#include <iostream>
+
+namespace xfirelib {
+ using namespace std;
+
+ int SearchBuddy::getPacketContent(char *packet) {
+ int index = 0;
+
+ // name
+ VariableValue val;
+ val.setName( "name" );
+ index += val.writeName( packet, index );
+
+ packet[index++] = 0x01;
+
+ val.setValue((char*)searchstring.c_str(),searchstring.size());
+ packet[index++] = searchstring.size()%256;
+ packet[index++] = (int)searchstring.size()/256;
+ index += val.writeValue(packet,index);
+
+ val.setName( "fname" );
+ index += val.writeName( packet, index );
+
+ packet[index++] = 0x01;
+ packet[index++] = 0x00;
+ packet[index++] = 0x00;
+
+ val.setName( "lname" );
+ index += val.writeName( packet, index );
+
+ packet[index++] = 0x01;
+ packet[index++] = 0x00;
+ packet[index++] = 0x00;
+
+ val.setName( "email" );
+ index += val.writeName( packet, index );
+
+ packet[index++] = 0x01;
+ packet[index++] = 0x00;
+ packet[index++] = 0x00;
+
+ length = index;
+ return index;
+ }
+
+ int SearchBuddy::getPacketAttributeCount() {
+ return 4;
+ }
+
+}
diff --git a/protocols/Xfire/src/searchbuddy.h b/protocols/Xfire/src/searchbuddy.h
new file mode 100644
index 0000000000..79c474d06c
--- /dev/null
+++ b/protocols/Xfire/src/searchbuddy.h
@@ -0,0 +1,55 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+//packet, welches bei der buddysuche versendet wird, um neue freund zu finden
+
+#ifndef __SEARCHBUDDY_H
+#define __SEARCHBUDDY_H
+
+#include "xfiresendpacketcontent.h"
+#include "variablevalue.h"
+
+#include <string>
+
+namespace xfirelib {
+
+ class SearchBuddy : public XFireSendPacketContent {
+ public:
+ XFirePacketContent* newPacket() { return new SearchBuddy(); }
+
+ int getPacketId() { return 0xC; }
+ int getPacketContent(char *buf);
+ int getPacketAttributeCount();
+ int getPacketSize() { return 1000; };
+ void parseContent(char *buf, int length, int numberOfAtts) { };
+ void searchfor(std::string s) { searchstring=s; }
+
+ private:
+ int length;
+ std::string searchstring;
+ };
+
+};
+
+#endif
diff --git a/protocols/Xfire/src/searching4games.cpp b/protocols/Xfire/src/searching4games.cpp
new file mode 100644
index 0000000000..abdb9c7b8e
--- /dev/null
+++ b/protocols/Xfire/src/searching4games.cpp
@@ -0,0 +1,741 @@
+/*
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ *
+ * Copyright (C) 2010 by
+ * dufte <dufte@justmail.de>
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ *
+ * Miranda ICQ: the free icq client for MS Windows
+ * Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
+ *
+ */
+
+#include "stdafx.h"
+#include "baseProtocol.h"
+#include "Xfire_gamelist.h"
+
+#include <string>
+using std::string;
+
+extern int foundgames;
+extern HANDLE XFireAvatarFolder;
+extern HANDLE XFireWorkingFolder;
+extern int StartGame(WPARAM wParam,LPARAM lParam,LPARAM fParam);
+extern Xfire_gamelist xgamelist;
+
+//versucht die * in den pfaden der ini mit dem korrekten eintrag zu ersetzen
+BOOL CheckPath(char*ppath,char*pathwildcard=NULL)
+{
+ char* pos=0;
+ char* pos2=0;
+
+ pos = strchr(ppath,'*');
+ if(pos)
+ {
+ HANDLE fHandle;
+ WIN32_FIND_DATA wfd;
+ BOOL weiter=TRUE;
+
+ if(pathwildcard)
+ {
+ strcpy_s(pathwildcard,XFIRE_MAX_STATIC_STRING_LEN,ppath);
+ }
+
+ pos++;
+ *pos=0;
+ pos++;
+
+ //versuch die exe zu finden
+ fHandle=FindFirstFile(ppath,&wfd); // . skippen
+ FindNextFile(fHandle,&wfd); // .. auch skippen
+
+ while ((FindNextFile(fHandle,&wfd)&&weiter==TRUE)) // erstes file
+ {
+ if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) // nur verzeichnisse sind interessant
+ {
+ char temp[XFIRE_MAX_STATIC_STRING_LEN];
+
+ strcpy(temp,ppath);
+ *(temp+strlen(temp)-1)=0;
+ strcat(temp,wfd.cFileName);
+ strcat(temp,"\\");
+ strcat(temp,pos);
+
+ if(GetFileAttributes(temp)!=0xFFFFFFFF) { //exe vorhanden???? unt hint?
+ //gefundenes in path kopieren
+ FindClose(fHandle);
+ strcpy(ppath,temp);
+ return TRUE;
+ }
+ }
+ }
+ FindClose(fHandle);
+ }
+ else
+ {
+ if(GetFileAttributes(ppath)!=0xFFFFFFFF) { //exe vorhanden???? unt hint?
+ //gefundenes in path kopieren
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+BOOL CALLBACK DlgSearchDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+void ShowSearchDialog(LPVOID lparam)
+{
+ HWND* hwnd=(HWND*)lparam;
+ HWND myhwnd=CreateDialog(hinstance,MAKEINTRESOURCE(IDD_SEARCHING),NULL,DlgSearchDialogProc);
+
+ if(myhwnd==NULL)
+ return;
+
+ *hwnd=myhwnd;
+
+ ShowWindow(myhwnd,SW_SHOW);
+
+ //nachrichten schleife
+ MSG msg;
+ while (GetMessage(&msg,myhwnd,0,0))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+}
+
+void Scan4Games( LPVOID lparam )
+{
+ int i=2;
+ unsigned int i2=1;
+ BOOL split=FALSE;
+ int notfound=0;
+ char* pos=0;
+ char* pos2=0;
+ char *cutforlaunch = 0;
+ char temp[10]="";
+ char inipath[XFIRE_MAX_STATIC_STRING_LEN]="";
+ char ret[XFIRE_MAX_STATIC_STRING_LEN]="";
+ char gamename[XFIRE_MAX_STATIC_STRING_LEN]="";
+ char ret2[XFIRE_MAX_STATIC_STRING_LEN]="";
+ char gamelist[XFIRE_MAX_STATIC_STRING_LEN]="";
+ BOOL multiexe=FALSE;
+ BOOL somethingfound=TRUE;
+ int i3=0;
+ CLISTMENUITEM mi = { 0 };
+ DWORD gpps=1;
+ DWORD last_gpps=0;
+ static BOOL searching=FALSE;
+
+ //ich suche schon,also raushier
+ if(searching)
+ {
+ MSGBOX("Game searching is already running!");
+ return;
+ }
+ if(xgamelist.Ingame())
+ {
+ MSGBOX("A game is currently running, please close the game.");
+ return;
+ }
+
+ //gamelist blocken, damit nur 1 thread es ausführt/nutzt
+ xgamelist.Block(TRUE);
+
+ searching=TRUE;
+
+ //säubert die gameliste für eine neuauslesung
+ xgamelist.clearGamelist();
+
+ //prüfe ob schon gescannt wurde, dann das aus der db nehmen, beschleunigt den start
+ foundgames=DBGetContactSettingWord(NULL, protocolname, "foundgames",-1);
+
+ //um bei einer neuen version einen rescan zuforcen, bei bestimmten wert found auf 0 resetten
+ if(DBGetContactSettingWord(NULL, protocolname, "scanver",0)!=XFIRE_SCAN_VAL)
+ foundgames=-1;
+
+ BOOL loadgamesfromdb=FALSE;
+ if(DBGetContactSettingByte(NULL,protocolname,"scanalways",0)==0)
+ loadgamesfromdb=TRUE;
+ else
+ {
+ if(DBGetContactSettingByte(NULL,protocolname,"scanalways",0)==2)
+ {
+ time_t zeit;
+ struct tm *t;
+ time(&zeit);
+ t = localtime(&zeit);
+
+ if(t!=NULL)
+ {
+ if(t->tm_yday!=DBGetContactSettingWord(NULL,protocolname,"scanalways_t",0))
+ {
+ DBWriteContactSettingWord(NULL,protocolname,"scanalways_t",t->tm_yday);
+ }
+ else
+ loadgamesfromdb=TRUE;
+ }
+ }
+ }
+
+ //spiele von db laden
+ if(loadgamesfromdb)
+ if(foundgames>0)
+ {
+ //spieliste einlesen
+ xgamelist.readGamelist(foundgames);
+ //menüpunkte anlegen
+ xgamelist.createStartmenu();
+
+ //gamelist unblocken
+ xgamelist.Block(FALSE);
+
+ searching=FALSE;
+ return;
+ }
+ else if(foundgames==0)
+ {
+ searching=FALSE;
+ //dummymenü punkt entfernen
+ //CallService( MS_CLIST_REMOVEMAINMENUITEM, ( WPARAM )dummymenu, 0 );
+
+ //gamelist unblocken
+ xgamelist.Block(FALSE);
+
+ return;
+ }
+ else
+ foundgames=0;
+ else
+ foundgames=0;
+
+ HWND hwnd=NULL;
+
+ //suche dialog anzeigen
+ if(!DBGetContactSettingByte(NULL,protocolname,"dontdissstatus",0))
+ {
+ mir_forkthread(ShowSearchDialog,&hwnd);
+ }
+
+ FoldersGetCustomPath( XFireWorkingFolder, inipath, 1024, "" );
+ strcat(inipath,"\\");
+ strcat(inipath,"xfire_games.ini");
+
+ //erstmal db säubern
+ xgamelist.clearDatabase();
+
+ //maximal 200 notfounds, um die nicht belegten id's zu überspringen
+ while(notfound<200)
+ {
+ //2 gameids?
+ if(split)
+ sprintf(temp,"%i_%i",i,i2);
+ else
+ sprintf(temp,"%i",i);
+
+ //MessageBoxA(0,temp,temp,0);
+
+ //letztes ergeniss sichern
+ last_gpps=gpps;
+
+ //las ma mal suchen ....
+ gpps=xfire_GetPrivateProfileString(temp, "LongName", "", gamename, 255, inipath);
+
+ char entrytype[100]="";
+ if(gpps!=NULL) xfire_GetPrivateProfileString(temp, "SoftwareType", "", entrytype, 100, inipath);
+
+ //kein eintrag? voicechat? musiapplicationen? schon in der gameliste?
+ if(gpps!=NULL && strcmp(entrytype,"Music")!=0 && strcmp(entrytype,"VoiceChat")!=0 && !xgamelist.Gameinlist(i)) //was gefunden und noch nicht eintragen?
+ {
+ BOOL MatchExe=FALSE;
+ //MatchExe Games in der automatischen Suche skippen
+ if(xfire_GetPrivateProfileString(temp, "MatchExe", "", ret, 255, inipath))
+ MatchExe=TRUE;
+
+ //Registryschlüssel auslesen und pfad auf exe prüfen
+ xfire_GetPrivateProfileString(temp, "LauncherDirKey", "", ret, 255, inipath);
+ strcpy(ret2,ret);
+
+ //ersten part des registry schlüssel raustrennen
+ pos=strchr(ret2,'\\');
+ if(!MatchExe && pos!=0)
+ {
+ HKEY hkey,hsubk;
+
+ *pos=0; //string trennen
+ pos++;
+
+ pos2=strrchr(pos,'\\'); //key trennen
+ if(pos!=0)
+ {
+ *pos2=0;
+ pos2++;
+
+ //HKEY festlegen
+ switch(*(ret2+6))
+ {
+ case 'L':
+ hkey = HKEY_CLASSES_ROOT;
+ break;
+ case 'U':
+ hkey = HKEY_CURRENT_USER;
+ break;
+ case 'O':
+ hkey = HKEY_LOCAL_MACHINE;
+ break;
+ default:
+ hkey = NULL;
+ }
+ }
+ else
+ hkey = NULL;
+
+ if(hkey) //nur wenn der key erkannt wurde
+ {
+ if(RegOpenKeyA(hkey,pos,&hsubk) == ERROR_SUCCESS) //key versuchen zu "öffnen"
+ {
+ char path[XFIRE_MAX_STATIC_STRING_LEN]="";
+ char path_r[XFIRE_MAX_STATIC_STRING_LEN]="";
+ DWORD size=sizeof(path);
+
+ //key lesen
+ if(RegQueryValueEx(hsubk,pos2,NULL,NULL,(LPBYTE)path,&size)== ERROR_SUCCESS)
+ {
+ //zusätzlichen pfad anhängen
+ if(xfire_GetPrivateProfileString(temp, "LauncherDirAppend", "", ret2, 255, inipath))
+ {
+ if(*(path+strlen(path)-1)=='\\'&&*(ret2)=='\\')
+ strcat(path,(ret2+1));
+ else
+ strcat(path,ret2);
+ }
+
+ if(xfire_GetPrivateProfileString(temp, "LauncherDirTruncAt", "", ret2, 255, inipath))
+ {
+ //mögliches erstes anführungszeichen entfernen
+ if(*(path)=='"')
+ {
+ pos2=path;
+ pos2++;
+
+ strcpy(path,pos2);
+ }
+
+ //mögliche weitere anführungszeichen entfernen
+ pos=strchr(path,'"');
+ if(pos!=0)
+ *pos=0;
+
+ if(*(path+strlen(path)-1)!='\\')
+ *(path+strlen(path)-strlen(ret2))=0;
+ }
+
+ if(*(path+strlen(path)-1)!='\\')
+ strcat(path,"\\");
+
+
+ //dateiname auslesen
+ if(xfire_GetPrivateProfileString(temp, "InstallHint", "", ret2, 255, inipath))
+ {
+ char pathtemp[XFIRE_MAX_STATIC_STRING_LEN];
+ strcpy(pathtemp,path);
+ strcat(pathtemp,ret2);
+
+ if(CheckPath(pathtemp))
+ {
+ if(xfire_GetPrivateProfileString(temp, "DetectExe", "", ret, 255, inipath))
+ {
+ cutforlaunch=path+strlen(path);
+ strcpy(pathtemp,path);
+
+ //wenn backslash bei detectexe, dann diesen skippen (eveonline bug)
+ if(ret[0]=='\\')
+ {
+ strcat(pathtemp,(char*)&ret[1]);
+ }
+ else
+ {
+ strcat(pathtemp,ret);
+ }
+
+ if(CheckPath(pathtemp))
+ {
+ strcpy(path, pathtemp);
+ }
+ else
+ {
+ *(path)=0;
+ }
+ }
+ else if(xfire_GetPrivateProfileString(temp, "LauncherExe", "", ret2, 255, inipath))
+ {
+ cutforlaunch=path+strlen(path);
+ strcat(path,ret2);
+ }
+ }
+ else
+ {
+ *(path)=0;
+ }
+ }
+ else if(xfire_GetPrivateProfileString(temp, "DetectExe[0]", "", ret2, 255, inipath))
+ {
+ cutforlaunch=path+strlen(path);
+ strcat(path,ret2);
+ multiexe=TRUE;
+ if(!CheckPath(path,path_r))
+ {
+ *(path)=0;
+ }
+ }
+ else if(xfire_GetPrivateProfileString(temp, "DetectExe", "", ret2, 255, inipath))
+ {
+ cutforlaunch=path+strlen(path);
+
+ //wenn backslash bei detectexe, dann diesen skippen (eveonline bug)
+ if(ret2[0]=='\\')
+ {
+ strcat(path,(char*)&ret2[1]);
+ }
+ else
+ {
+ strcat(path,ret2);
+ }
+
+ if(!CheckPath(path,path_r))
+ {
+ *(path)=0;
+ }
+ }
+ else if(xfire_GetPrivateProfileString(temp, "LauncherExe", "", ret2, 255, inipath))
+ {
+ cutforlaunch=path+strlen(path);
+ strcat(path,ret2);
+ }
+
+
+ //prüfe ob existent, dann ist das spiel installiert
+ if(path[0]!=0 && GetFileAttributes(path)!=0xFFFFFFFF)
+ {
+ Xfire_game* newgame=new Xfire_game();
+ newgame->id=i;
+
+ //8.3 pfade umwandeln
+ //GetLongPathNameA(path,path,sizeof(path));
+
+ //lowercase pfad
+ for(unsigned int ii=0;ii<strlen(path);ii++)
+ path[ii]=tolower(path[ii]);
+
+ if(path_r[0]==0)
+ newgame->setString(path,&newgame->path);
+ else
+ {
+ //lowercase wildcard pfad
+ for(unsigned int ii=0;ii<strlen(path_r);ii++)
+ path_r[ii]=tolower(path_r[ii]);
+ newgame->setString(path_r,&newgame->path);
+ }
+
+ //spiel mit mehreren exefiles
+ if(multiexe)
+ {
+ multiexe=FALSE;
+ for(int i=1;i<9;i++)
+ {
+ sprintf(ret,"DetectExe[%d]",i);
+ if(xfire_GetPrivateProfileString(temp, ret, "", ret2, 512, inipath))
+ {
+ char* pos=strrchr(path,'\\');
+ if(pos!=0)
+ {
+ pos++;
+ *pos=0;
+ }
+ strcat(path,ret2);
+ if(!CheckPath(path))
+ {
+ *(path)=0;
+ }
+ else
+ {
+ for(unsigned int i2=0;i2<strlen(path);i2++)
+ path[i2]=tolower(path[i2]);
+
+ char* mpathtemp=new char[strlen(path)+1];
+ strcpy(mpathtemp,path);
+ newgame->mpath.push_back(mpathtemp);
+ }
+ }
+ }
+ }
+
+ //für launcherstring anpassen
+ char* pos=strrchr(path,'\\');
+ if(pos!=0)
+ {
+ pos++;
+ *pos=0;
+ }
+ xfire_GetPrivateProfileString(temp, "LauncherExe", "", ret2, 255, inipath); // anfügen
+ if(cutforlaunch!=0) *cutforlaunch=0;
+
+ //pfad aufbereiten
+ char launchpath[XFIRE_MAX_STATIC_STRING_LEN]="";
+ strcpy(launchpath,path);
+ //letzten backslash entfernen
+ if(launchpath[strlen(launchpath)-1]=='\\') launchpath[strlen(launchpath)-1]=0;
+
+ strcat(path,ret2);
+
+ newgame->setString(path,&newgame->launchparams);
+ newgame->appendString(" ",&newgame->launchparams);
+
+ xfire_GetPrivateProfileString(temp, "Launch", "", ret2, 512, inipath);
+ str_replace(ret2,"%UA_LAUNCHER_EXE_DIR%",launchpath);
+ str_replace(ret2,"%UA_LAUNCHER_EXE_PATH%",""); //erstmal unwichtige sachen entfernen
+ //str_replace(ret2,"%UA_LAUNCHER_EXTRA_ARGS%",""); // - auch entfernen
+ str_replace(ret2,"%UA_LAUNCHER_LOGIN_ARGS%",""); // - auch entfernen
+
+ newgame->appendString(ret2,&newgame->launchparams);
+
+ /*if(xfire_GetPrivateProfileString(temp, "LauncherLoginArgs", "", ret2, 512, inipath))
+ {
+ str_replace(xf[foundgames].launchparams,"%UA_LAUNCHER_LOGIN_ARGS%",ret2); // - auch entfernen
+ }
+ else*/
+ // str_replace(xf[foundgames].launchparams,"%UA_LAUNCHER_LOGIN_ARGS%",""); // - auch entfernen
+
+ if(xfire_GetPrivateProfileString(temp, "LauncherPasswordArgs", "", ret2, 512, inipath))
+ newgame->setString(ret2,&newgame->pwparams);
+
+ if(xfire_GetPrivateProfileString(temp, "LauncherNetworkArgs", "", ret2, 512, inipath))
+ newgame->setString(ret2,&newgame->networkparams);
+
+ if(xfire_GetPrivateProfileString(temp, "CommandLineMustContain[0]", "", ret2, 512, inipath))
+ newgame->setString(ret2,&newgame->mustcontain);
+
+ if(xfire_GetPrivateProfileString(temp, "XUSERSendId", "", ret2, 512, inipath))
+ newgame->send_gameid=atoi(ret2);
+
+ if(xfire_GetPrivateProfileString(temp, "XUSERSetStatusMsg", "", ret2, 512, inipath))
+ newgame->setstatusmsg=atoi(ret2);
+
+ //launcherurl?
+ if(xfire_GetPrivateProfileString(temp, "LauncherUrl", "", ret2, 512, inipath))
+ newgame->setString(ret2,&newgame->launchparams);
+
+ //soll alle string, welche nicht in der commandline eines spiels sein soll in einen string pakcen semikolon getrennt
+ sprintf(ret,"CommandLineMustNotContain[0]");
+ int i=0;
+
+ while(xfire_GetPrivateProfileString(temp, ret, "", ret2, 512, inipath))
+ {
+ if(!newgame->notcontain) newgame->setString("",&newgame->notcontain);
+ if(i>0)
+ newgame->appendString(";",&newgame->notcontain);
+ newgame->appendString(ret2,&newgame->notcontain);
+
+ i++;
+ sprintf(ret,"CommandLineMustNotContain[%d]",i);
+ }
+
+ newgame->setNameandIcon();
+
+ strcat(gamelist,gamename);
+ strcat(gamelist,", ");
+ if(foundgames%2==1)
+ strcat(gamelist,"\r\n");
+
+ xgamelist.Addgame(newgame);
+
+ foundgames++;
+
+ split=FALSE;
+ }
+
+ }
+
+ RegCloseKey(hsubk);
+ }
+ }
+
+ }
+ else if(!MatchExe && xfire_GetPrivateProfileString(temp, "LauncherDirDefault", "", ret2, 255, inipath))
+ {
+ if(xfire_GetPrivateProfileString(temp, "LauncherExe", "", ret, 255, inipath))
+ {
+ strcat(ret2,"\\");
+ strcat(ret2,ret);
+ }
+
+ str_replace(ret2,"%WINDIR%",getenv("WINDIR"));
+ str_replace(ret2,"%ProgramFiles%",getenv("ProgramFiles"));
+
+ //prüfe ob existent, dann ist das spiel installiert
+ if(GetFileAttributes(ret2)!=0xFFFFFFFF)
+ {
+
+ Xfire_game* newgame=new Xfire_game();
+
+ newgame->id=i;
+
+ //8.3 pfade umwandeln
+ //GetLongPathNameA(ret2,ret2,sizeof(ret2));
+
+ //lowercase pfad
+ for(unsigned int i=0;i<strlen(ret2);i++)
+ ret2[i]=tolower(ret2[i]);
+
+ newgame->setString(ret2,&newgame->path);
+
+ //launch parameterstring
+
+ //pfad aufbereiten
+ char launchpath[XFIRE_MAX_STATIC_STRING_LEN]="";
+ strcpy(launchpath,ret2);
+ if(strrchr(launchpath,'\\')!=0)
+ {
+ *(strrchr(launchpath,'\\'))=0;
+ }
+
+ newgame->setString(ret2,&newgame->launchparams);
+ newgame->appendString(" ",&newgame->launchparams);
+
+ xfire_GetPrivateProfileString(temp, "Launch", "", ret2, 512, inipath);
+
+ str_replace(ret2,"%UA_LAUNCHER_EXE_DIR%",launchpath);
+
+ str_replace(ret2,"%UA_LAUNCHER_EXE_PATH%",""); //unwichtige sachen entfernen
+ //str_replace(ret2,"%UA_LAUNCHER_EXTRA_ARGS%",""); // - auch entfernen
+ str_replace(ret2,"%UA_LAUNCHER_LOGIN_ARGS%",""); // - auch entfernen
+
+ newgame->appendString(ret2,&newgame->launchparams);
+
+ if(xfire_GetPrivateProfileString(temp, "LauncherPasswordArgs", "", ret2, 512, inipath))
+ newgame->setString(ret2,&newgame->pwparams);
+
+ if(xfire_GetPrivateProfileString(temp, "LauncherNetworkArgs", "", ret2, 512, inipath))
+ newgame->setString(ret2,&newgame->networkparams);
+
+ if(xfire_GetPrivateProfileString(temp, "CommandLineMustContain[0]", "", ret2, 512, inipath))
+ newgame->setString(ret2,&newgame->mustcontain);
+
+ if(xfire_GetPrivateProfileString(temp, "XUSERSendId", "", ret2, 512, inipath))
+ newgame->send_gameid=atoi(ret2);
+
+ if(xfire_GetPrivateProfileString(temp, "XUSERSetStatusMsg", "", ret2, 512, inipath))
+ newgame->setstatusmsg=atoi(ret2);
+
+ //soll alle string, welche nicht in der commandline eines spiels sein soll in einen string pakcen semikolon getrennt
+ sprintf(ret,"CommandLineMustNotContain[0]");
+ int i=0;
+
+ while(xfire_GetPrivateProfileString(temp, ret, "", ret2, 512, inipath))
+ {
+ if(!newgame->notcontain) newgame->setString("",&newgame->notcontain);
+ if(i>0)
+ newgame->appendString(";",&newgame->notcontain);
+ newgame->appendString(ret2,&newgame->notcontain);
+
+ i++;
+ sprintf(ret,"CommandLineMustNotContain[%d]",i);
+ }
+
+ newgame->setNameandIcon();
+
+ strcat(gamelist,gamename);
+ strcat(gamelist,", ");
+ if(foundgames%2==1)
+ strcat(gamelist,"\r\n");
+
+ xgamelist.Addgame(newgame);
+
+ foundgames++;
+
+ split=FALSE;
+ }
+
+ }
+
+ if(split)
+ i2++;
+ else
+ i++;
+ notfound=0;
+ }
+ else if(split==FALSE) // nichts gefunden, dann die 2. gameid probieren (games die zb über steam und normal installiert werden können, haben eine 2. id)
+ {
+ i2=1;
+ split=TRUE;
+ }
+ else if(split==TRUE&&last_gpps!=NULL) // keine weiteren einträge mit der 2. id gefunden, also wieder mit der normalen weitersuchen
+ {
+ split=FALSE;
+ i++;
+ i2=0;
+ }
+ else if(split==TRUE&&last_gpps==NULL) // überhaupt nix gefunden, vllt nicht belegete id's, überspringen und "notfound" hochsetzen
+ {
+ split=FALSE;
+ i2=0;
+ if(i==35) //großer sprung unbenutzer id's
+ i+=4000;
+ i++;
+ notfound++;
+ }
+ }
+
+ if(hwnd)SetDlgItemText(hwnd,IDC_CURRENTGAME,Translate("Write to database ..."));
+
+ //gefundene games in db eintragen
+ xgamelist.writeDatabase();
+
+ //scanversion setzen, um ungewollten rescan zu vermeiden
+ DBWriteContactSettingWord(NULL, protocolname, "scanver", XFIRE_SCAN_VAL);
+
+ EndDialog(hwnd,0);
+
+ if(!DBGetContactSettingByte(NULL,protocolname,"dontdisresults",0))
+ {
+ int p=strlen(gamelist)-2;
+ if(p>-1)
+ gamelist[p]=0; //letztes koma killen
+ sprintf(ret,Translate("Games found:%s%s"),"\r\n\r\n",gamelist);
+ MSGBOX(ret);
+ }
+
+ searching=FALSE;
+
+ xgamelist.createStartmenu();
+
+ //gamelist unblocken
+ xgamelist.Block(FALSE);
+} \ No newline at end of file
diff --git a/protocols/Xfire/src/sendacceptinvitationpacket.cpp b/protocols/Xfire/src/sendacceptinvitationpacket.cpp
new file mode 100644
index 0000000000..ece6c0bc3a
--- /dev/null
+++ b/protocols/Xfire/src/sendacceptinvitationpacket.cpp
@@ -0,0 +1,47 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "sendacceptinvitationpacket.h"
+
+#include "variablevalue.h"
+#include "xdebug.h"
+
+namespace xfirelib {
+
+ int SendAcceptInvitationPacket::getPacketContent(char *buf) {
+ VariableValue val;
+ val.setName( "name" );
+ val.setValue( name.c_str() );
+ int index = 0;
+ index += val.writeName(buf, index);
+ buf[index++] = 01;
+ buf[index++] = name.length();
+ buf[index++] = 00;
+ index += val.writeValue(buf, index);
+
+ return index;
+ }
+
+
+};
diff --git a/protocols/Xfire/src/sendacceptinvitationpacket.h b/protocols/Xfire/src/sendacceptinvitationpacket.h
new file mode 100644
index 0000000000..9bc2c4769b
--- /dev/null
+++ b/protocols/Xfire/src/sendacceptinvitationpacket.h
@@ -0,0 +1,51 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SENDACCEPTINVITATION_H
+#define __SENDACCEPTINVITATION_H
+
+#include "xfiresendpacketcontent.h"
+#include <string>
+
+
+#define XFIRE_ACCEPT_INVITATION_PACKET 07
+
+namespace xfirelib {
+ class SendAcceptInvitationPacket : public XFireSendPacketContent {
+ public:
+ virtual ~SendAcceptInvitationPacket() { }
+ int getPacketId() { return XFIRE_ACCEPT_INVITATION_PACKET; }
+
+ int getPacketContent(char *buf);
+ int getPacketAttributeCount() { return 3; }
+ int getPacketSize() { return 1024; }
+
+ std::string name;
+ private:
+
+ };
+
+};
+
+
+#endif
+
diff --git a/protocols/Xfire/src/senddenyinvitationpacket.cpp b/protocols/Xfire/src/senddenyinvitationpacket.cpp
new file mode 100644
index 0000000000..f122c91ce4
--- /dev/null
+++ b/protocols/Xfire/src/senddenyinvitationpacket.cpp
@@ -0,0 +1,27 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "senddenyinvitationpacket.h"
+
+
diff --git a/protocols/Xfire/src/senddenyinvitationpacket.h b/protocols/Xfire/src/senddenyinvitationpacket.h
new file mode 100644
index 0000000000..10cf6a3a80
--- /dev/null
+++ b/protocols/Xfire/src/senddenyinvitationpacket.h
@@ -0,0 +1,43 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SENDDENYINVITATIONPACKET_H
+#define __SENDDENYINVITATIONPACKET_H
+
+#include "sendacceptinvitationpacket.h"
+
+#define XFIRE_DENY_INVITATION_PACKET 8
+
+namespace xfirelib {
+
+ class SendDenyInvitationPacket : public SendAcceptInvitationPacket {
+ public:
+ virtual ~SendDenyInvitationPacket() { }
+ int getPacketId() { return XFIRE_DENY_INVITATION_PACKET; }
+
+ private:
+ };
+
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/sendgameserverpacket.cpp b/protocols/Xfire/src/sendgameserverpacket.cpp
new file mode 100644
index 0000000000..2f65e1578b
--- /dev/null
+++ b/protocols/Xfire/src/sendgameserverpacket.cpp
@@ -0,0 +1,50 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "sendgameserverpacket.h"
+#include "variablevalue.h"
+#include <iostream>
+
+namespace xfirelib {
+
+ int SendGameServerPacket::getPacketContent(char *buf) {
+ VariableValue val;
+ val.setName( "gip" );
+ val.setValue(ip);
+ val.setValueLength(4);
+
+ int index = 0;
+ index += val.writeName(buf, index);
+ buf[index++] = 02;
+ index += val.writeValue(buf, index);
+ val.setName("gport");
+ val.setValueFromLong(port,4);
+ index += val.writeName(buf, index);
+ buf[index++] = 02;
+ index += val.writeValue(buf, index);
+ return index;
+ }
+
+
+};
diff --git a/protocols/Xfire/src/sendgameserverpacket.h b/protocols/Xfire/src/sendgameserverpacket.h
new file mode 100644
index 0000000000..d9f8dfc8b4
--- /dev/null
+++ b/protocols/Xfire/src/sendgameserverpacket.h
@@ -0,0 +1,49 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#ifndef _SENDGAMESERVERPACKET_H_
+#define _SENDGAMESERVERPACKET_H_
+
+#include "xfiresendpacketcontent.h"
+
+#define XFIRE_GAME_SERVER_PACKET 04
+
+namespace xfirelib {
+ class SendGameServerPacket : public XFireSendPacketContent {
+ public:
+ virtual ~SendGameServerPacket() { }
+ int getPacketId() { return XFIRE_GAME_SERVER_PACKET; }
+
+ int getPacketContent(char *buf);
+ int getPacketAttributeCount() { return 3; }
+ int getPacketSize() { return 1024; }
+
+ long port;
+ char ip[4];
+ private:
+
+ };
+
+};
+
+#endif //_SENDGAMESERVERPACKET_H_
diff --git a/protocols/Xfire/src/sendgamestatus2packet.cpp b/protocols/Xfire/src/sendgamestatus2packet.cpp
new file mode 100644
index 0000000000..8859e004cb
--- /dev/null
+++ b/protocols/Xfire/src/sendgamestatus2packet.cpp
@@ -0,0 +1,74 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "stdafx.h"
+
+#include "sendgamestatus2packet.h"
+#include "variablevalue.h"
+#include "xdebug.h"
+
+#include <windows.h>
+
+//packet vervollständigt
+
+namespace xfirelib {
+
+ SendGameStatus2Packet::SendGameStatus2Packet() {
+ ip[0] = ip[1] = ip[2] = ip[3] = 0;
+ port = 0;
+ }
+
+ int SendGameStatus2Packet::getPacketContent(char *buf) {
+
+ VariableValue val;
+
+ val.setName( getGameAttributeName() );
+
+ val.setValueFromLong(gameid,4);
+
+ int index = 0;
+ index += val.writeName(buf, index);
+ buf[index++] = 02;
+ index += val.writeValue(buf, index);
+
+ val.setName( getIPAttributeName() );
+
+ //BUG: hab ,4 hinzugefügt, führte und vista zum crash - dufte
+ val.setValue(ip,4);
+ val.setValueLength(4);
+
+ index += val.writeName(buf, index);
+ buf[index++] = 02;
+ index += val.writeValue(buf, index);
+ val.setName( getPortAttributeName() );
+ val.setValueFromLong(port,4);
+ index += val.writeName(buf, index);
+ buf[index++] = 02;
+ index += val.writeValue(buf, index);
+
+ return index;
+ }
+
+
+};
+
diff --git a/protocols/Xfire/src/sendgamestatus2packet.h b/protocols/Xfire/src/sendgamestatus2packet.h
new file mode 100644
index 0000000000..cad9d0108b
--- /dev/null
+++ b/protocols/Xfire/src/sendgamestatus2packet.h
@@ -0,0 +1,56 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#ifndef _SENDGAMESTATUS2PACKET_H_
+#define _SENDGAMESTATUS2PACKET_H_
+
+#include "sendgamestatuspacket.h"
+
+#define XFIRE_GAME_STATUS2_PACKET 15
+
+namespace xfirelib {
+
+ class SendGameStatus2Packet : public SendGameStatusPacket {
+ public:
+ virtual ~SendGameStatus2Packet() { }
+ SendGameStatus2Packet();
+ int getPacketId() { return XFIRE_GAME_STATUS2_PACKET; }
+
+ int getPacketContent(char *buf);
+ int getPacketAttributeCount() { return 3; }
+ int getPacketSize() { return 1024; }
+
+ //gamestatus2 packet ready gemacht
+ long gameid;
+ char ip[4];
+ long port;
+
+ protected:
+ virtual std::string getGameAttributeName() { return "vid"; }
+ virtual std::string getIPAttributeName() { return "vip"; }
+ virtual std::string getPortAttributeName() { return "vport"; }
+ };
+
+};
+
+#endif
diff --git a/protocols/Xfire/src/sendgamestatuspacket.cpp b/protocols/Xfire/src/sendgamestatuspacket.cpp
new file mode 100644
index 0000000000..fe3ae43e5a
--- /dev/null
+++ b/protocols/Xfire/src/sendgamestatuspacket.cpp
@@ -0,0 +1,69 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "stdafx.h"
+
+#include "sendgamestatuspacket.h"
+#include "variablevalue.h"
+#include "xdebug.h"
+
+#include <windows.h>
+
+namespace xfirelib {
+
+ SendGameStatusPacket::SendGameStatusPacket() {
+ ip[0] = ip[1] = ip[2] = ip[3] = 0;
+ port = 0;
+ }
+
+ int SendGameStatusPacket::getPacketContent(char *buf) {
+
+ VariableValue val;
+
+ val.setName( getGameAttributeName() );
+
+ val.setValueFromLong(gameid,4);
+
+ int index = 0;
+ index += val.writeName(buf, index);
+ buf[index++] = 02;
+ index += val.writeValue(buf, index);
+
+ val.setName( getIPAttributeName() );
+
+ //BUG: hab ,4 hinzugefügt, führte und vista zum crash - dufte
+ val.setValue(ip,4);
+ val.setValueLength(4);
+
+ index += val.writeName(buf, index);
+ buf[index++] = 02;
+ index += val.writeValue(buf, index);
+ val.setName( getPortAttributeName() );
+ val.setValueFromLong(port,4);
+ index += val.writeName(buf, index);
+ buf[index++] = 02;
+ index += val.writeValue(buf, index);
+
+ return index;
+ }
+
+
+};
diff --git a/protocols/Xfire/src/sendgamestatuspacket.h b/protocols/Xfire/src/sendgamestatuspacket.h
new file mode 100644
index 0000000000..57bec411ee
--- /dev/null
+++ b/protocols/Xfire/src/sendgamestatuspacket.h
@@ -0,0 +1,56 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#ifndef _SENDGAMESTATUSPACKET_H_
+#define _SENDGAMESTATUSPACKET_H_
+
+#include "xfiresendpacketcontent.h"
+#include <string>
+
+#define XFIRE_GAME_STATUS_PACKET 04
+
+namespace xfirelib {
+ class SendGameStatusPacket : public XFireSendPacketContent {
+ public:
+ SendGameStatusPacket();
+ virtual ~SendGameStatusPacket() { }
+ int getPacketId() { return XFIRE_GAME_STATUS_PACKET; }
+
+ int getPacketContent(char *buf);
+ int getPacketAttributeCount() { return 3; }
+ int getPacketSize() { return 1024; }
+
+ long gameid;
+ char ip[4];
+ long port;
+
+ protected:
+ virtual std::string getGameAttributeName() { return "gameid"; }
+ virtual std::string getIPAttributeName() { return "gip"; }
+ virtual std::string getPortAttributeName() { return "gport"; }
+ private:
+
+ };
+
+};
+#endif //_SENDGAMESTATUSPACKET_H_
diff --git a/protocols/Xfire/src/sendkeepalivepacket.cpp b/protocols/Xfire/src/sendkeepalivepacket.cpp
new file mode 100644
index 0000000000..242ba88214
--- /dev/null
+++ b/protocols/Xfire/src/sendkeepalivepacket.cpp
@@ -0,0 +1,56 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "sendkeepalivepacket.h"
+#include "variablevalue.h"
+#include <string.h>
+
+namespace xfirelib {
+
+ int SendKeepAlivePacket::getPacketContent(char *buf) {
+ int index = 0;
+
+ VariableValue val;
+ val.setName("value");
+
+ index += val.writeName(buf,index);
+ buf[index++] = 2;
+ buf[index++] = 0;
+ buf[index++] = 0;
+ buf[index++] = 0;
+ buf[index++] = 0;
+
+ val.setName("stats");
+
+ index += val.writeName(buf,index);
+ buf[index++] = 4;
+ buf[index++] = 2;
+ buf[index++] = 0;
+ buf[index++] = 0;
+
+ return index;
+ }
+
+
+};
diff --git a/protocols/Xfire/src/sendkeepalivepacket.h b/protocols/Xfire/src/sendkeepalivepacket.h
new file mode 100644
index 0000000000..5d81785998
--- /dev/null
+++ b/protocols/Xfire/src/sendkeepalivepacket.h
@@ -0,0 +1,48 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SENDKEEPALIVEPACKET_H
+#define __SENDKEEPALIVEPACKET_H
+
+#include "xfiresendpacketcontent.h"
+#include <string>
+
+#define XFIRE_SEND_KEEPALIVE_PACKET_ID 13;
+
+namespace xfirelib {
+ using namespace std;
+
+ class SendKeepAlivePacket : public XFireSendPacketContent {
+ public:
+ virtual ~SendKeepAlivePacket() { }
+ int getPacketId() { return XFIRE_SEND_KEEPALIVE_PACKET_ID; }
+
+ int getPacketContent(char *buf);
+ int getPacketAttributeCount() { return 2; }
+ int getPacketSize() { return 26; }
+
+ };
+
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/sendmessagepacket.cpp b/protocols/Xfire/src/sendmessagepacket.cpp
new file mode 100644
index 0000000000..a0f7e4e3d0
--- /dev/null
+++ b/protocols/Xfire/src/sendmessagepacket.cpp
@@ -0,0 +1,103 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "sendmessagepacket.h"
+#include "xfireutils.h"
+#include <string.h>
+#include <iostream>
+#include "xdebug.h"
+
+#include "sendmessagepacket.h"
+#include "xfireutils.h"
+#include <string.h>
+#include <iostream>
+#include "xdebug.h"
+
+namespace xfirelib {
+ using namespace std;
+
+ std::map<std::string,int> SendMessagePacket::imindexes;
+
+ void SendMessagePacket::init(Client *client, string username, string message) {
+ BuddyListEntry *entry = client->getBuddyList()->getBuddyByName(username);
+ if(entry) {
+ setSid(entry->sid);
+ }
+ this->message = message;
+ initIMIndex();
+ }
+
+ void SendMessagePacket::initIMIndex() {
+ string str_sid(sid);
+ if( imindexes.count( str_sid ) < 1 )
+ imindex = imindexes[str_sid] = 1;
+ else
+ imindex = ++imindexes[str_sid];
+ }
+
+ void SendMessagePacket::setSid(const char *sid) {
+ memcpy(this->sid,sid,16);
+ }
+
+ int SendMessagePacket::getPacketContent(char *buf) {
+ if( imindex == 0 ) initIMIndex();
+
+ int index = 0;
+ VariableValue val;
+ val.setName("sid");
+ val.setValue(sid,16);
+
+ index += val.writeName(buf,index);
+ buf[index++] = 3;
+ index += val.writeValue(buf,index);
+
+ val.setName("peermsg");
+ index += val.writeName(buf,index);
+ buf[index++] = 5;
+ //buf[index++] = 7;
+ buf[index++] = 3;
+
+ val.setName("msgtype");
+ val.setValueFromLong(0,4);
+ index += val.writeName(buf,index);
+ buf[index++] = 2;
+ index += val.writeValue(buf,index);
+
+ val.setName("imindex");
+ val.setValueFromLong(imindex,4);
+ index += val.writeName(buf,index);
+ buf[index++] = 02;
+ index += val.writeValue(buf,index);
+
+ val.setName("im");
+ val.setValue((char*)message.c_str(),message.size());
+ index += val.writeName(buf,index);
+ buf[index++] = 01;
+ buf[index++] = message.size()%256;
+ buf[index++] = (int)message.size()/256;
+ index += val.writeValue(buf,index);
+
+ return index;
+ }
+}
diff --git a/protocols/Xfire/src/sendmessagepacket.h b/protocols/Xfire/src/sendmessagepacket.h
new file mode 100644
index 0000000000..f54efd778c
--- /dev/null
+++ b/protocols/Xfire/src/sendmessagepacket.h
@@ -0,0 +1,77 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+
+#ifndef __SENDMESSAGEPACKET_H
+#define __SENDMESSAGEPACKET_H
+
+
+
+#include "xfiresendpacketcontent.h"
+#include "variablevalue.h"
+#include <string.h>
+#include "client.h"
+
+namespace xfirelib {
+
+ class SendMessagePacket : public XFireSendPacketContent {
+ public:
+ SendMessagePacket() {
+ imindex = 0;
+ }
+ virtual ~SendMessagePacket() { }
+
+ void init(Client *client, string username, string message);
+ void setSid(const char *sid);
+
+ XFirePacketContent* newPacket() { return new SendMessagePacket(); }
+
+ int getPacketId() { return 2; }
+ int getPacketContent(char *buf);
+ int getPacketAttributeCount() {return 2;};
+ int getPacketSize() { return 5024; };
+
+ /**
+ * SID of the user to who the message should be sent.
+ */
+ char sid[16];
+ /**
+ * A running counter for each buddy. (will be initialized to 0 by default.. and..
+ * shouldn't be a problem to leave it 0)
+ */
+ long imindex;
+ /**
+ * Message body to be sent.
+ */
+ std::string message;
+
+ protected:
+ void initIMIndex();
+
+ static std::map<std::string,int> imindexes;
+
+ };
+
+};
+
+#endif
diff --git a/protocols/Xfire/src/sendnickchangepacket.cpp b/protocols/Xfire/src/sendnickchangepacket.cpp
new file mode 100644
index 0000000000..57d38ac50d
--- /dev/null
+++ b/protocols/Xfire/src/sendnickchangepacket.cpp
@@ -0,0 +1,49 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "sendnickchangepacket.h"
+#include "variablevalue.h"
+#include <string.h>
+
+namespace xfirelib {
+/*TODO: this packet is outdated, sniff with official client and change it to a correct implementation*/
+ int SendNickChangePacket::getPacketContent(char *buf) {
+ int index = 0;
+
+ VariableValue val;
+ val.setName("nick");
+ val.setValue((char*)nick.c_str(),nick.size());
+
+ index += val.writeName(buf,index);
+ buf[index++] = 1;
+ buf[index++] = nick.size();
+ buf[index++] = 0;
+
+ index += val.writeValue(buf,index);
+
+ return index;
+ }
+
+
+};
diff --git a/protocols/Xfire/src/sendnickchangepacket.h b/protocols/Xfire/src/sendnickchangepacket.h
new file mode 100644
index 0000000000..940bac032d
--- /dev/null
+++ b/protocols/Xfire/src/sendnickchangepacket.h
@@ -0,0 +1,51 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SENDNICKCHANGEPACKET_H
+#define __SENDNICKCHANGEPACKET_H
+
+#include "xfiresendpacketcontent.h"
+#include <string>
+
+#define XFIRE_SEND_NICKCHANGE_PACKET_ID 14;
+
+namespace xfirelib {
+ using namespace std;
+
+ class SendNickChangePacket : public XFireSendPacketContent {
+ public:
+ virtual ~SendNickChangePacket() { }
+
+ XFirePacketContent *newPacket() { return new SendNickChangePacket; }
+ int getPacketId() { return XFIRE_SEND_NICKCHANGE_PACKET_ID; }
+
+ int getPacketContent(char *buf);
+ int getPacketAttributeCount() { return 1; }
+ int getPacketSize() { return 1024; }
+
+ string nick;
+ };
+
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/sendremovebuddypacket.cpp b/protocols/Xfire/src/sendremovebuddypacket.cpp
new file mode 100644
index 0000000000..a49b3f38ed
--- /dev/null
+++ b/protocols/Xfire/src/sendremovebuddypacket.cpp
@@ -0,0 +1,46 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "sendremovebuddypacket.h"
+
+#include "variablevalue.h"
+#include "xdebug.h"
+
+namespace xfirelib {
+
+ int SendRemoveBuddyPacket::getPacketContent(char *buf) {
+ int index = 0;
+ VariableValue val;
+ val.setName("userid");
+ XDEBUG2( "Creating packet to remove userid %ld\n", userid );
+ index += val.writeName(buf,index);
+ val.setValueFromLong(userid,4);
+ buf[index++] = 2;
+ index += val.writeValue(buf,index);
+
+ return index;
+ }
+
+};
+
diff --git a/protocols/Xfire/src/sendremovebuddypacket.h b/protocols/Xfire/src/sendremovebuddypacket.h
new file mode 100644
index 0000000000..6a27728300
--- /dev/null
+++ b/protocols/Xfire/src/sendremovebuddypacket.h
@@ -0,0 +1,46 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SENDREMOVEBUDDYPACKET_H
+#define __SENDREMOVEBUDDYPACKET_H
+
+#include "xfiresendpacketcontent.h"
+
+#define XFIRE_SENDREMOVEBUDDYPACKET 9
+
+namespace xfirelib {
+
+ class SendRemoveBuddyPacket : public XFireSendPacketContent {
+ public:
+ virtual ~SendRemoveBuddyPacket() { }
+ int getPacketId() { return XFIRE_SENDREMOVEBUDDYPACKET; }
+
+ int getPacketContent(char *buf);
+ int getPacketAttributeCount() { return 1; }
+ int getPacketSize() { return 1024; }
+
+ long userid;
+ };
+
+};
+
+#endif
diff --git a/protocols/Xfire/src/sendsidpacket.cpp b/protocols/Xfire/src/sendsidpacket.cpp
new file mode 100644
index 0000000000..34c80a7ff3
--- /dev/null
+++ b/protocols/Xfire/src/sendsidpacket.cpp
@@ -0,0 +1,71 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+#include "sendsidpacket.h"
+#include <string.h>
+#include <iostream>
+
+/*
+ whois packet von xfire, für z.b. friends of friends
+*/
+
+namespace xfirelib {
+ using namespace std;
+
+ int SendSidPacket::getPacketContent(char *packet) {
+ int index = 0;
+
+ XERROR("Send Sid Packet!\n");
+
+ packet[index++] = 0x03;
+ packet[index++] = 's';
+ packet[index++] = 'i';
+ packet[index++] = 'd';
+ packet[index++] = 4;
+ packet[index++] = 3;
+ XDEBUG2("Sids: %d\n",sids->size());
+ packet[index++] = sids->size();
+ packet[index++] = 0;
+
+ for(uint i = 0 ; i < sids->size() ; i++) {
+ XDEBUG2("Sid%d:",i);
+ char* sid=sids->at(i);
+ for(int u = 0; u <16 ; u++)
+ {
+ XDEBUG2("%x,",sid[u]);
+ packet[index++] = sid[u];
+ }
+ XDEBUG("\n");
+ }
+
+ length = index;
+ return index;
+ }
+
+ int SendSidPacket::getPacketAttributeCount() {
+ return 1;
+ }
+
+}
diff --git a/protocols/Xfire/src/sendsidpacket.h b/protocols/Xfire/src/sendsidpacket.h
new file mode 100644
index 0000000000..ffffad2071
--- /dev/null
+++ b/protocols/Xfire/src/sendsidpacket.h
@@ -0,0 +1,58 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+//mit diesem packet kann man sids welche man nicht zuordnen kann, erfragen wer sich dahinter verbirgt
+//eine art whois, wahrscheinlich
+
+#ifndef __SENDSIDPACKET_H
+#define __SENDSIDPACKET_H
+
+#include "xfiresendpacketcontent.h"
+#include "variablevalue.h"
+
+#include <vector>
+#include <string>
+
+namespace xfirelib {
+ using namespace std;
+
+ class SendSidPacket : public XFireSendPacketContent {
+ public:
+ XFirePacketContent* newPacket() { return new SendSidPacket(); }
+
+ int getPacketId() { return 0x5; }
+ int getPacketContent(char *buf);
+ int getPacketAttributeCount();
+ int getPacketSize() { return 1000; };
+ void parseContent(char *buf, int length, int numberOfAtts) { };
+
+ vector<char *> *sids;
+
+ private:
+ int length;
+ };
+
+};
+
+#endif
diff --git a/protocols/Xfire/src/sendstatusmessagepacket.cpp b/protocols/Xfire/src/sendstatusmessagepacket.cpp
new file mode 100644
index 0000000000..6495515119
--- /dev/null
+++ b/protocols/Xfire/src/sendstatusmessagepacket.cpp
@@ -0,0 +1,43 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "sendstatusmessagepacket.h"
+
+#include <string.h>
+
+namespace xfirelib {
+
+ int SendStatusMessagePacket::getPacketContent(char *buf) {
+ int index = 0;
+ buf[index++] = 0x2e;
+ buf[index++] = 0x01;
+ buf[index++] = awaymsg.length();
+ buf[index++] = 0x00;
+ memcpy(buf+index,awaymsg.c_str(),awaymsg.length());
+ index+=awaymsg.length();
+ return index;
+ }
+
+
+};
diff --git a/protocols/Xfire/src/sendstatusmessagepacket.h b/protocols/Xfire/src/sendstatusmessagepacket.h
new file mode 100644
index 0000000000..3c4106e260
--- /dev/null
+++ b/protocols/Xfire/src/sendstatusmessagepacket.h
@@ -0,0 +1,52 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SENDSTATUSMESSAGEPACKET_H
+#define __SENDSTATUSMESSAGEPACKET_H
+
+#include "xfiresendpacketcontent.h"
+#include <string>
+
+#define XFIRE_SEND_STATUSMESSAGE_PACKET_ID 32
+
+namespace xfirelib {
+ using namespace std;
+
+ class SendStatusMessagePacket : public XFireSendPacketContent {
+ public:
+ ~SendStatusMessagePacket(){};
+ XFirePacketContent *newPacket() { return new SendStatusMessagePacket; }
+
+ int getPacketId() { return XFIRE_SEND_STATUSMESSAGE_PACKET_ID; }
+
+ int getPacketContent(char *buf);
+ int getPacketAttributeCount() { return 1; }
+ int getPacketSize() { return 1024; }
+
+
+ string awaymsg;
+ };
+
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/sendtypingpacket.cpp b/protocols/Xfire/src/sendtypingpacket.cpp
new file mode 100644
index 0000000000..3cc09d80e9
--- /dev/null
+++ b/protocols/Xfire/src/sendtypingpacket.cpp
@@ -0,0 +1,103 @@
+#include "stdafx.h"
+
+/*
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ *
+ * Copyright (C) 2010 by
+ * dufte <dufte@justmail.de>
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Based on J. Lawler - BaseProtocol
+ * Herbert Poul/Beat Wolf - xfirelib
+ *
+ * Miranda ICQ: the free icq client for MS Windows
+ * Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
+ *
+ */
+
+//sendtypingklasse hinzugefügt http://xfirelib.sphene.net/board2/showThread/367 - big thx to Fl0ri4n - dufte
+
+
+#include "sendtypingpacket.h"
+#include "xfireutils.h"
+#include <string.h>
+#include <iostream>
+#include "xdebug.h"
+
+namespace xfirelib {
+using namespace std;
+
+std::map<std::string,int> SendTypingPacket::imindexes;
+
+void SendTypingPacket::init(Client *client, string username) {
+BuddyListEntry *entry = client->getBuddyList()->getBuddyByName(username);
+if(entry) {
+setSid(entry->sid);
+}
+initIMIndex();
+}
+
+void SendTypingPacket::initIMIndex() {
+string str_sid(sid);
+if( imindexes.count( str_sid ) < 1 )
+imindex = imindexes[str_sid] = 1;
+else
+imindex = ++imindexes[str_sid];
+
+}
+void SendTypingPacket::setSid(const char *sid) {
+memcpy(this->sid,sid,16);
+}
+
+int SendTypingPacket::getPacketContent(char *buf) {
+if( imindex == 0 ) initIMIndex();
+
+int index = 0;
+VariableValue val;
+val.setName("sid");
+val.setValue(sid,16);
+
+index += val.writeName(buf,index);
+buf[index++] = 3;
+index += val.writeValue(buf,index);
+
+val.setName("peermsg");
+index += val.writeName(buf,index);
+buf[index++] = 5;
+//buf[index++] = 7;
+buf[index++] = 3;
+
+val.setName("msgtype");
+val.setValueFromLong(3,4);
+index += val.writeName(buf,index);
+buf[index++] = 2;
+index += val.writeValue(buf,index);
+
+val.setName("imindex");
+val.setValueFromLong(imindex,4);
+index += val.writeName(buf,index);
+buf[index++] = 02;
+index += val.writeValue(buf,index);
+
+val.setName("typing");
+val.setValueFromLong(1,4);
+index += val.writeName(buf,index);
+buf[index++] = 02;
+index += val.writeValue(buf,index);
+
+return index;
+}
+} \ No newline at end of file
diff --git a/protocols/Xfire/src/sendtypingpacket.h b/protocols/Xfire/src/sendtypingpacket.h
new file mode 100644
index 0000000000..d3226f3a0e
--- /dev/null
+++ b/protocols/Xfire/src/sendtypingpacket.h
@@ -0,0 +1,79 @@
+/*
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ *
+ * Copyright (C) 2010 by
+ * dufte <dufte@justmail.de>
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Based on J. Lawler - BaseProtocol
+ * Herbert Poul/Beat Wolf - xfirelib
+ *
+ * Miranda ICQ: the free icq client for MS Windows
+ * Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
+ *
+ */
+
+//sendtypingklasse hinzugefügt http://xfirelib.sphene.net/board2/showThread/367 - big thx to Fl0ri4n - dufte
+
+#ifndef __SENDTYPINGPACKET_H
+#define __SENDTYPINGPACKET_H
+
+
+
+#include "xfiresendpacketcontent.h"
+#include "variablevalue.h"
+#include <string.h>
+#include "client.h"
+
+namespace xfirelib {
+
+class SendTypingPacket : public XFireSendPacketContent {
+public:
+SendTypingPacket() {
+imindex = 0;
+}
+virtual ~SendTypingPacket() { }
+
+void init(Client *client, string username);
+void setSid(const char *sid);
+
+XFirePacketContent* newPacket() { return new SendTypingPacket(); }
+
+int getPacketId() { return 2; }
+int getPacketContent(char *buf);
+int getPacketAttributeCount() {return 2;};
+int getPacketSize() { return 1024; };
+
+/**
+* SID of the user to who the message should be sent.
+*/
+char sid[16];
+/**
+* A running counter for each buddy. (will be initialized to 0 by default.. and..
+* shouldn't be a problem to leave it 0)
+*/
+long imindex;
+
+protected:
+void initIMIndex();
+
+static std::map<std::string,int> imindexes;
+
+};
+
+};
+
+#endif \ No newline at end of file
diff --git a/protocols/Xfire/src/services.cpp b/protocols/Xfire/src/services.cpp
new file mode 100644
index 0000000000..3f39200e59
--- /dev/null
+++ b/protocols/Xfire/src/services.cpp
@@ -0,0 +1,81 @@
+/*
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ *
+ * Copyright (C) 2010 by
+ * dufte <dufte@justmail.de>
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Based on J. Lawler - BaseProtocol
+ * Herbert Poul/Beat Wolf - xfirelib
+ *
+ * Miranda ICQ: the free icq client for MS Windows
+ * Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
+ *
+ */
+
+#include "stdafx.h"
+
+#include "baseProtocol.h"
+
+BOOL IsContactMySelf(std::string buddyusername) {
+ DBVARIANT dbv;
+
+ //nur wenn option aktiv, sonst immer FALSE
+ if(!DBGetContactSettingByte(NULL,protocolname,"skipmyself",0))
+ return FALSE;
+
+ if(!DBGetContactSetting(NULL,protocolname,"login",&dbv))
+ {
+ if(!lstrcmpiA( dbv.pszVal, buddyusername.c_str() ))
+ {
+ DBFreeVariant(&dbv);
+ return TRUE;
+ }
+ DBFreeVariant(&dbv);
+ }
+ else
+ return FALSE;
+
+ return FALSE;
+}
+
+//liefert vollendateipfad vom eigenen avatar zurück, wenn definiert
+int GetMyAvatar(WPARAM wparam,LPARAM lparam) {
+ DBVARIANT dbv;
+
+ if(!DBGetContactSetting(NULL,protocolname,"MyAvatarFile",&dbv))
+ {
+ strncpy((char*)wparam, dbv.pszVal, (int)lparam);
+ DBFreeVariant(&dbv);
+ return 0;
+ }
+
+ return -1;
+}
+
+//liefert vollendateipfad vom eigenen avatar zurück, wenn definiert
+int mBotNotify(WPARAM wparam,LPARAM lparam) {
+
+ if(wparam) {
+ CallService(MBOT_TRIGGER,(WPARAM)"xfireingame",1);
+ }
+ else
+ {
+ CallService(MBOT_TRIGGER,(WPARAM)"xfireingame",0);
+ }
+
+ return 0;
+} \ No newline at end of file
diff --git a/protocols/Xfire/src/services.h b/protocols/Xfire/src/services.h
new file mode 100644
index 0000000000..af0477f1c7
--- /dev/null
+++ b/protocols/Xfire/src/services.h
@@ -0,0 +1,18 @@
+#ifndef _XFIRESERVICES_H
+#define _XFIRESERVICES_H
+
+#define XFIRE_URLCALL "XFire/UrlCall"
+
+#define XFIRE_SET_NICK "XFire/SetNickname"
+
+#define XFIRE_SEND_PREFS "XFire/SendXFirePrefs"
+
+#define XFIRE_INGAMESTATUSHOOK "XFire/Gamestatus"
+
+#define MBOT_TRIGGER "MBot/Trigger"
+
+//liefert den eigenen avatar zurück
+int GetMyAvatar(WPARAM wparam,LPARAM lparam);
+int mBotNotify(WPARAM wparam,LPARAM lparam);
+
+#endif \ No newline at end of file
diff --git a/protocols/Xfire/src/setnickname.cpp b/protocols/Xfire/src/setnickname.cpp
new file mode 100644
index 0000000000..2062c2f487
--- /dev/null
+++ b/protocols/Xfire/src/setnickname.cpp
@@ -0,0 +1,46 @@
+//fürs nick - dialog
+
+#include "stdafx.h"
+#include "setnickname.h"
+
+BOOL CALLBACK DlgNickProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+ SendMessage(hwndDlg,WM_SETICON, (WPARAM)false, (LPARAM)LoadIcon(hinstance, MAKEINTRESOURCE(IDI_TM)));
+
+ DBVARIANT dbv;
+ if(!DBGetContactSetting(NULL,protocolname,"Nick",&dbv)) {
+ SetDlgItemText(hwndDlg,IDC_NICKNAME,dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+ return TRUE;
+ }
+ case WM_COMMAND:
+ {
+ if(LOWORD(wParam) == IDOK)
+ {
+ char nick[255];
+ GetDlgItemText(hwndDlg,IDC_NICKNAME,nick,sizeof(nick));
+
+ CallService(XFIRE_SET_NICK,0,(LPARAM)nick);
+
+ EndDialog(hwndDlg,TRUE);
+ return TRUE;
+ }
+ else if(LOWORD(wParam) == IDCANCEL)
+ {
+ EndDialog(hwndDlg,FALSE);
+ return FALSE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+BOOL ShowSetNick() {
+ return DialogBox(hinstance,MAKEINTRESOURCE(IDD_SETNICKNAME),NULL,DlgNickProc);
+} \ No newline at end of file
diff --git a/protocols/Xfire/src/setnickname.h b/protocols/Xfire/src/setnickname.h
new file mode 100644
index 0000000000..f3d9eb552e
--- /dev/null
+++ b/protocols/Xfire/src/setnickname.h
@@ -0,0 +1,4 @@
+#include "baseProtocol.h"
+#include "resource.h"
+
+BOOL ShowSetNick(); \ No newline at end of file
diff --git a/protocols/Xfire/src/socket.cpp b/protocols/Xfire/src/socket.cpp
new file mode 100644
index 0000000000..f5f48e5588
--- /dev/null
+++ b/protocols/Xfire/src/socket.cpp
@@ -0,0 +1,272 @@
+// Copied from http://linuxgazette.net/issue74/tougher.html
+// (only slightly modified)
+// heavy modified (für windows umgeschrieben) - dufte
+
+// Implementation of the Socket class.
+
+
+#include "stdafx.h"
+
+#include "xdebug.h"
+#include "socket.h"
+#include "string.h"
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <iostream>
+
+/*NETLIB*****************/
+#include <newpluginapi.h>
+#include <m_netlib.h>
+extern HANDLE hNetlib;
+/*NETLIB*****************/
+
+
+using namespace std;
+
+Socket::Socket( std::string host, int port, int useproxy, std::string proxyhost , int proxyport ) :
+ m_sock ( -1 )
+{
+
+ memset ( &m_addr,
+ 0,
+ sizeof ( m_addr ) );
+
+ if(!create()) {
+ throw SocketException( "Could not create socket." );
+ }
+ if(!connect(host,port,useproxy,proxyhost,proxyport)) {
+ throw SocketException( "Could not bind port." );
+ }
+}
+
+Socket::~Socket()
+{
+ Netlib_CloseHandle(this->netlibcon);
+}
+
+bool Socket::create()
+{
+
+/*
+ m_sock = socket ( AF_INET, SOCK_STREAM, 0 );
+
+
+ if ( ! is_valid() )
+ return false;*/
+
+
+ // TIME_WAIT - argh
+// int on = 1;
+ //if ( setsockopt ( m_sock, SOL_SOCKET, SO_REUSEADDR, ( const char* ) &on, sizeof ( on ) ) == -1 )
+// return false;
+
+ return true;
+
+}
+
+
+
+bool Socket::bind ( const int port )
+{
+/* if ( ! is_valid() )
+ {
+ return false;
+ }
+
+
+
+ m_addr.sin_family = AF_INET;
+ m_addr.sin_addr.s_addr = INADDR_ANY;
+ m_addr.sin_port = htons ( port );
+
+ int bind_return = ::bind ( m_sock,
+ ( struct sockaddr * ) &m_addr,
+ sizeof ( m_addr ) );
+
+
+ if ( bind_return == -1 )
+ {
+ return false;
+ }
+*/
+ return true;
+}
+
+
+bool Socket::listen() const
+{
+ /*if ( ! is_valid() )
+ {
+ return false;
+ }
+
+ int listen_return = ::listen ( m_sock, MAXCONNECTIONS );
+
+
+ if ( listen_return == -1 )
+ {
+ return false;
+ }
+*/
+ return false;
+}
+
+
+bool Socket::accept ( Socket& new_socket ) const
+{
+ /*int addr_length = sizeof ( m_addr );
+ new_socket.m_sock = ::accept ( m_sock, ( sockaddr * ) &m_addr, ( socklen_t * ) &addr_length );
+
+ if ( new_socket.m_sock <= 0 )
+ return false;
+ else
+ return true;*/
+ return false;
+
+}
+
+bool Socket::send ( char *buf, int length ) const {
+ int status = Netlib_Send(this->netlibcon,buf, length,0); //::send ( m_sock, buf, length, 0);
+ if ( status == -1 )
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+}
+bool Socket::send ( const std::string s ) const
+{
+ int status = Netlib_Send(this->netlibcon,s.c_str(), s.size(),0); //::send ( m_sock, s.c_str(), s.size(), 0);
+ if ( status == -1 )
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+}
+
+int Socket::recv ( char *buf, int maxlen ) const {
+ int status = Netlib_Recv(this->netlibcon,buf,maxlen,0); //::recv( m_sock, buf, maxlen, 0 );
+
+ if ( status == -1 )
+ {
+ //std::cout << "status == -1 errno == " << errno << " in Socket::recv WSA:::" << ::WSAGetLastError() << "\n";
+ return 0;
+ }
+ return status;
+}
+
+int Socket::recv ( std::string& s ) const
+{
+ char buf [ MAXRECV + 1 ];
+
+ s = "";
+
+ memset ( buf, 0, MAXRECV + 1 );
+
+ int status = Netlib_Recv(this->netlibcon,buf,MAXRECV,0);//::recv ( m_sock, buf, MAXRECV, 0 );
+
+ if ( status == -1 )
+ {
+ //std::cout << "status == -1 errno == " << errno << " in Socket::recv\n";
+ return 0;
+ }
+ else if ( status == 0 )
+ {
+ return 0;
+ }
+ else
+ {
+ s = buf;
+ return status;
+ }
+}
+
+
+
+bool Socket::connect ( const std::string host, const int port, int useproxy,std::string proxyhost,int proxyport)
+{
+ //if ( ! is_valid() ) return false;
+
+ /*m_addr.sin_family = AF_INET;
+ if(useproxy)
+ {
+ m_addr.sin_port = htons ( proxyport );
+ m_addr.sin_addr.s_addr=inet_addr(proxyhost.c_str());
+ }
+ else
+ {
+ m_addr.sin_port = htons ( port );
+ m_addr.sin_addr.s_addr=inet_addr(host.c_str());
+ }
+ */
+
+ int status = 0; //inet_pton ( AF_INET, host.c_str(), &m_addr.sin_addr );
+
+ /* XDEBUG(("Is valid .. %d\n",status));
+ if ( errno == EAFNOSUPPORT ) return false; */
+ //status = ::connect ( m_sock, ( sockaddr * ) &m_addr, sizeof ( m_addr ) );
+
+ /*if(useproxy&&status==0) {
+ char temp[1024];
+ this->send("CONNECT cs.xfire.com:25999 HTTP/1.1\nHost: cs.xfire.com:25999\nUser-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)\n\n");
+ this->recv((char*)temp,1024);
+ }*/
+
+ NETLIBOPENCONNECTION ncon = { 0 };
+ ncon.cbSize = sizeof(ncon);
+ ncon.szHost = "cs.xfire.com";
+ ncon.wPort = (WORD)atol("25999");
+ ncon.timeout=5;
+ netlibcon = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) hNetlib, (LPARAM) & ncon);
+
+
+ //std::cout << "status: " << status << std::endl;
+ if ( netlibcon != NULL )
+ {
+ //CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) hNetlib, (LPARAM) & ncon);
+ m_sock=CallService(MS_NETLIB_GETSOCKET,(WPARAM) netlibcon,0);
+ return true;
+ }
+ else {
+ int errsv = errno;
+ if(errsv == SOCKET_ERROR) {
+ // std::cout << "Connection refused to " << host << ":" << port << std::endl;
+ throw SocketException( "Connection refused." );
+ }
+ //std::cout << "errno: " << errsv << std::endl;
+ return false;
+ }
+}
+
+void Socket::set_non_blocking ( const bool b )
+{
+/* u_long arg=0;
+
+ if(b) arg=1;*/
+
+ //ioctlsocket(m_sock, 0x8004667e,&arg);
+// int opts;
+
+ /* opts = fcntl ( m_sock,
+ F_GETFL );
+
+ if ( opts < 0 )
+ {
+ return;
+ }
+*/
+ //if ( b )
+ // opts = ( opts | O_NONBLOCK );
+ /*else
+ opts = ( opts & ~O_NONBLOCK );*/
+
+ /*fcntl ( m_sock,
+ F_SETFL,opts );*/
+
+}
diff --git a/protocols/Xfire/src/socket.h b/protocols/Xfire/src/socket.h
new file mode 100644
index 0000000000..370aeb74f7
--- /dev/null
+++ b/protocols/Xfire/src/socket.h
@@ -0,0 +1,67 @@
+// Copied from http://linuxgazette.net/issue74/tougher.html
+// (only slightly modified)
+
+
+// Definition of the Socket class
+
+
+#ifndef Socket_class
+#define Socket_class
+
+#include "stdafx.h"
+
+#include <sys/types.h>
+//#include <netinet/in.h>
+//#include <netdb.h>
+//#include <unistd.h>
+#include <string>
+//#include <arpa/inet.h>
+#include <winsock2.h>
+
+#include "socketexception.h"
+
+
+const int MAXHOSTNAME = 200;
+const int MAXCONNECTIONS = 5;
+const int MAXRECV = 500;
+
+class Socket
+{
+ public:
+ //proxy hinzugefügt dufte
+ Socket( std::string host, int port,int useproxy = 0,std::string proxyhost = " ", int proxyport = 0 );
+ virtual ~Socket();
+
+ // Server initialization
+ bool create();
+ bool bind ( const int port );
+ bool listen() const;
+ bool accept ( Socket& ) const;
+
+ // Client initialization
+ bool connect ( const std::string host, const int port, int useproxy,std::string proxyhost,int proxyport);
+
+ // Data Transimission
+ bool send ( char *buf, int length ) const;
+ bool send ( const std::string ) const;
+ int recv ( std::string& ) const;
+ int recv ( char *buf, int maxlen ) const;
+
+
+ void set_non_blocking ( const bool );
+
+ bool is_valid() const { return true; }
+
+ int m_sock;
+
+ private:
+
+
+ sockaddr_in m_addr;
+ HANDLE netlibcon;
+
+
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/socketexception.h b/protocols/Xfire/src/socketexception.h
new file mode 100644
index 0000000000..dc506aeaf7
--- /dev/null
+++ b/protocols/Xfire/src/socketexception.h
@@ -0,0 +1,45 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+// SocketException class
+
+
+#ifndef SocketException_class
+#define SocketException_class
+
+#include <string>
+
+class SocketException
+{
+ public:
+ SocketException ( std::string s ) : m_s ( s ) {};
+ ~SocketException (){};
+
+ std::string description() { return m_s; }
+
+ private:
+
+ std::string m_s;
+
+};
+
+#endif
diff --git a/protocols/Xfire/src/stdafx.cpp b/protocols/Xfire/src/stdafx.cpp
new file mode 100644
index 0000000000..f16632cd31
--- /dev/null
+++ b/protocols/Xfire/src/stdafx.cpp
@@ -0,0 +1,8 @@
+// stdafx.cpp : Quelldatei, die nur die Standard-Includes einbindet.
+// xfiretest.pch ist der vorkompilierte Header.
+// stdafx.obj enthält die vorkompilierten Typinformationen.
+
+#include "stdafx.h"
+
+// TODO: Auf zusätzliche Header verweisen, die in STDAFX.H
+// und nicht in dieser Datei erforderlich sind.
diff --git a/protocols/Xfire/src/stdafx.h b/protocols/Xfire/src/stdafx.h
new file mode 100644
index 0000000000..3b6a0d7bd2
--- /dev/null
+++ b/protocols/Xfire/src/stdafx.h
@@ -0,0 +1,36 @@
+// stdafx.h : Includedatei für Standardsystem-Includedateien
+// oder häufig verwendete projektspezifische Includedateien,
+// die nur in unregelmäßigen Abständen geändert werden.
+//
+
+#pragma once
+
+#ifndef _WIN32_WINNT // Lassen Sie die Verwendung spezifischer Features von Windows XP oder später zu.
+#define _WIN32_WINNT 0x0501 // Ändern Sie dies in den geeigneten Wert für andere Versionen von Windows.
+#endif
+
+#include <stdio.h>
+#include <cstdlib>
+#include <tchar.h>
+#include <iostream>
+
+#define uint unsigned int
+#define socklen_t int
+
+#define NO_PTHREAD
+
+#pragma warning(disable:4267)
+#pragma warning(disable:4244)
+#pragma warning(disable:4312)
+#pragma warning(disable:4099)
+#pragma warning(disable:4311)
+#pragma comment(lib,"ws2_32.lib")
+
+#ifndef NO_PTHREAD
+#pragma comment(lib,"pthreads.lib")
+#endif
+
+#pragma comment(lib,"user32.lib")
+#pragma comment(lib,"gdi32.lib")
+
+// TODO: Hier auf zusätzliche Header, die das Programm erfordert, verweisen.
diff --git a/protocols/Xfire/src/testclient/Jamfile b/protocols/Xfire/src/testclient/Jamfile
new file mode 100644
index 0000000000..29b07b1a20
--- /dev/null
+++ b/protocols/Xfire/src/testclient/Jamfile
@@ -0,0 +1,5 @@
+SubDir TOP src testclient ;
+
+LOCATE_TARGET = bin/testclient ;
+Main xfirelibtest : test.cpp ;
+LinkLibraries xfirelibtest : libxfirelib ;
diff --git a/protocols/Xfire/src/testclient/test.cpp b/protocols/Xfire/src/testclient/test.cpp
new file mode 100644
index 0000000000..0d4f2070ab
--- /dev/null
+++ b/protocols/Xfire/src/testclient/test.cpp
@@ -0,0 +1,310 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "../xdebug.h"
+
+
+#include <iostream>
+#include <string>
+#include <stdexcept>
+
+#include "test.h"
+#include "../client.h"
+#include "../xfirepacket.h"
+#include "../loginfailedpacket.h"
+#include "../otherloginpacket.h"
+#include "../messagepacket.h"
+#include "../sendstatusmessagepacket.h"
+#include "../sendmessagepacket.h"
+#include "../invitebuddypacket.h"
+#include "../sendacceptinvitationpacket.h"
+#include "../senddenyinvitationpacket.h"
+#include "../sendremovebuddypacket.h"
+#include "../sendnickchangepacket.h"
+#include "../sendgamestatuspacket.h"
+#include "../sendgamestatus2packet.h"
+#include "../dummyxfiregameresolver.h"
+#include "../sendgameserverpacket.h"
+#include "../recvoldversionpacket.h"
+
+namespace xfirelibtest {
+ using namespace std;
+ using namespace xfirelib;
+
+ XFireTestClient::XFireTestClient(string username_,string password_)
+ : username(username_), password(password_) {
+ client = new Client();
+ client->setGameResolver( new DummyXFireGameResolver() );
+ lastInviteRequest = NULL;
+ }
+ XFireTestClient::~XFireTestClient() {
+ delete client;
+ delete lastInviteRequest;
+ }
+
+ void XFireTestClient::run() {
+ client->connect(username,password);
+ client->addPacketListener(this);
+ // Starting input loop ...
+ string input;
+ bool done = false;
+ while(!done) {
+ cout << "Give me Your Commands:\n>>> ";
+ getline(cin,input);
+ //string words[10];
+ //split(input, words, 10, " ");
+ vector<string> cmds = explodeString(input," ");
+ //cout << "Command: " << cmds[0];
+ //XDEBUG(( "Input: %s %d Command: %s\n", input.c_str(), cmds.size(), cmds[0].c_str() ));
+ if(cmds.size() > 0) {
+ if(cmds[0] == "help") {
+ cout << "No help available right now :(" << endl;
+ cout << "But a short list of available commands: " << endl;
+ cout << " quit" << endl;
+ cout << " buddylist" << endl;
+ cout << " away" << endl;
+ cout << " back" << endl;
+ cout << " game <gameid>" << endl;
+ cout << " game2 <game2id>" << endl;
+ cout << " nick" << endl;
+ cout << " invite <username>" << endl;
+ cout << " accept [<username>]" << endl;
+ cout << " deny [<username>]" << endl;
+ cout << " remove <username>" << endl;
+ cout << " send <username> <message .....>" << endl;
+ } else if(cmds[0] == "quit") {
+ cout << "Quitting" << endl;
+ done = true;
+ } else if(cmds[0] == "buddylist") {
+ printBuddyList();
+ } else if(cmds[0] == "away" || cmds[0] == "back") {
+ SendStatusMessagePacket *packet = new SendStatusMessagePacket();
+ packet->awaymsg = joinString(cmds,1);//input.substr(5);
+ client->send( packet );
+ delete packet;
+ } else if(cmds[0] == "game" || cmds[0] == "game2") {
+ int gameid = 0;
+ if(cmds.size() > 1) {
+ gameid = atoi(cmds[1].c_str());
+ }
+ SendGameStatusPacket *packet =
+ (cmds[0] == "game" ? new SendGameStatusPacket() :
+ new SendGameStatus2Packet());
+ packet->gameid = 2;
+ packet->gameid = gameid;
+ char ip[] = {0,0,0,0};
+ memcpy(packet->ip,ip,4);
+ packet->port = 0;
+ client->send( packet );
+ delete packet;
+ } else if(cmds[0] == "nick"){
+ if(cmds.size() < 2) {
+ cout << "Usage: nick <nickname>" << endl;
+ continue;
+ }
+ SendNickChangePacket nick;
+ nick.nick = joinString(cmds,1);
+ client->send( &nick );
+ cout << "Sent nick change." << endl;
+ }else if(cmds[0] == "send"){
+ if(cmds.size() < 3) {
+ cout << "Usage: send <username> <message>" << endl;
+ continue;
+ }
+ SendMessagePacket msg;
+ msg.init(client, cmds[1], joinString(cmds,2));
+ client->send( &msg );
+ cout << "Sent message." << endl;
+ } else if(cmds[0] == "invite") {
+ if(cmds.size() < 3) {
+ cout << "Usage: invite <username> <message>" << endl;
+ } else {
+ InviteBuddyPacket invite;
+ invite.addInviteName( cmds[1], joinString(cmds,2) );
+ client->send( &invite );
+ cout << "Sent Invitation." << endl;
+ }
+ } else if(cmds[0] == "accept" || cmds[0] == "deny") {
+ string name;
+ if(cmds.size() < 2) {
+ if(lastInviteRequest == 0) {
+ cout << "No Invitation Request pending (try " << cmds[0] << " <username>)" << endl;
+ continue;
+ }
+ name = string(*lastInviteRequest);
+ delete lastInviteRequest;
+ lastInviteRequest = 0;
+ } else {
+ name = cmds[1];
+ }
+ if(cmds[0] == "accept") {
+ SendAcceptInvitationPacket accept;
+ accept.name = name;
+ client->send( &accept );
+ cout << "Sent Accept Invitation." << endl;
+ } else {
+ SendDenyInvitationPacket deny;
+ deny.name = name;
+ client->send( &deny );
+ cout << "Sent Deny Invitation." << endl;
+ }
+ } else if(cmds[0] == "remove") {
+ if(cmds.size() < 2) {
+ cout << "Usage: remove <user name>" << endl;
+ continue;
+ }
+ string name = cmds[1];
+ BuddyListEntry *entry = client->getBuddyList()->getBuddyByName( name );
+ if(entry == NULL) {
+ cout << "Noone with this name is in your buddy list ?" << endl;
+ continue;
+ }
+ SendRemoveBuddyPacket removeBuddy;
+ removeBuddy.userid = entry->userid;
+ client->send( &removeBuddy );
+ cout << "Sent Remove Buddy." << endl;
+ }
+
+ else {
+ cout << "Unknown Command." << endl;
+ }
+ }
+ }
+ client->disconnect();
+ delete client;
+ client = 0;
+ }
+ string XFireTestClient::joinString(vector<string> s, int startindex, int endindex, string delimiter) {
+ string ret;
+ int max = (unsigned)endindex > s.size() || endindex < 0 ? s.size() : endindex;
+ for(int i = startindex ; i < max ; i++) {
+ if(i != startindex)
+ ret += delimiter;
+ ret += s[i];
+ }
+ return ret;
+ }
+ vector<string> XFireTestClient::explodeString(string s, string e) {
+ vector<string> ret;
+ int iPos = s.find(e, 0);
+ int iPit = e.length();
+ while(iPos > -1) {
+ if(iPos != 0)
+ ret.push_back(s.substr(0,iPos));
+ s.erase(0,iPos+iPit);
+ iPos = s.find(e,0);
+ }
+ if(s!="")
+ ret.push_back(s);
+ return ret;
+ }
+
+ void XFireTestClient::receivedPacket(XFirePacket *packet) {
+ XFirePacketContent *content = packet->getContent();
+ cout << "TestClient : Received Packet: " << content->getPacketId() << endl;
+ switch(content->getPacketId()) {
+ case XFIRE_LOGIN_FAILED_ID: {
+ client->disconnect();
+ delete client;
+ client = 0;
+ cout << "TestClient : Login failed." << endl;
+ break;
+ }
+ case XFIRE_MESSAGE_ID: {
+ cout << "TestClient : Got Message." << endl;
+ if( (( MessagePacket*)content)->getMessageType() == 0){
+ cout << "TestClient : Message is " << ((MessagePacket*)content)->getMessage() <<endl;
+ BuddyListEntry *entry = client->getBuddyList()->getBuddyBySid( ((MessagePacket*)content)->getSid() );
+ cout << "TestClient : from user " << entry->nick << "(" << entry->username << ")" <<endl;
+ }
+ break;
+ }
+ case XFIRE_RECV_OLDVERSION_PACKET_ID: {
+ cout << "Testclient: Our protocol version is too old" << endl;
+ break;
+ }
+ case XFIRE_PACKET_INVITE_REQUEST_PACKET: {
+ cout << "Invitation Request: " << endl;
+ InviteRequestPacket *invite = (InviteRequestPacket*)content;
+ cout << " Name : " << invite->name << endl;
+ cout << " Nick : " << invite->nick << endl;
+ cout << " Message: " << invite->msg << endl;
+ cout << " -- type 'accept' for accepting this request. (or 'accept "
+ << invite->name << "' if you receive another invitation in the meantime." << endl;
+ lastInviteRequest = new string(invite->name);
+ break;
+ }
+ case XFIRE_OTHER_LOGIN:{
+ client->disconnect();
+ delete client;
+ client = 0;
+ cout << "TestClient : Someone loged in with our account.disconnect" << endl;
+ break;
+ }
+ case XFIRE_BUDDYS_NAMES_ID: {
+ printBuddyList();
+ }
+default:
+cout << "nothing--------" << endl;
+break;
+ }
+}
+
+ void XFireTestClient::printBuddyList() {
+ printf("Buddy List: (* marks online users)\n");
+ printf("----------------- Buddy List --------------------------------------------------------\n");
+ printf(" %20s | %20s | %10s | %20s | %7s | %7s\n","User Name", "Nick", "UserId", "Status Msg" ,"Gameid" ,"Gameid2" );
+ vector<BuddyListEntry*> *entries = client->getBuddyList()->getEntries();
+ for(uint i = 0 ; i < entries->size() ; i ++) {
+ BuddyListEntry *entry = entries->at(i);
+ printf("%1s %20s | %20s | %10ld | %20s | %7ld | %ld\n",
+ (entry->isOnline() ? "*" : ""),
+ entry->username.c_str(),
+ entry->nick.c_str(),
+ entry->userid,
+ entry->statusmsg.c_str(),
+ entry->game,
+ entry->game2);
+ }
+ printf("-------------------------------------------------------------------------------------\n\n");
+ }
+};
+
+using namespace std;
+using namespace xfirelib;
+using namespace xfirelibtest;
+
+int main(int argc, char **params) {
+ if(argc < 3) {
+ cout << "Usage: " << params[0] << " <username> <password>" << endl;
+ return 0;
+ }
+ XFireTestClient *testClient = new
+ XFireTestClient(string(params[1]),string(params[2]));
+ try {
+ testClient->run();
+ } catch( exception e ) {
+ cout << "Exception: " << e.what() << endl;
+ }
+ delete testClient;
+ return 0;
+}
diff --git a/protocols/Xfire/src/testclient/test.h b/protocols/Xfire/src/testclient/test.h
new file mode 100644
index 0000000000..55af5d6f4a
--- /dev/null
+++ b/protocols/Xfire/src/testclient/test.h
@@ -0,0 +1,60 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __TEST_H
+#define __TEST_H
+
+#include <string>
+#include <vector>
+#include "../packetlistener.h"
+#include "../xfirepacket.h"
+#include "../client.h"
+#include "../inviterequestpacket.h"
+
+namespace xfirelibtest {
+ using namespace std;
+ using namespace xfirelib;
+
+ class XFireTestClient : public PacketListener {
+
+ public:
+ XFireTestClient(string username, string password);
+ ~XFireTestClient();
+ void run();
+
+ void receivedPacket(XFirePacket *packet);
+
+ private:
+ vector<string> explodeString(string s, string e);
+ string joinString(vector<string> s, int startindex, int endindex=-1, string delimiter=" ");
+ void printBuddyList();
+
+ Client *client;
+ string *lastInviteRequest;
+
+ string username;
+ string password;
+ };
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/tools.cpp b/protocols/Xfire/src/tools.cpp
new file mode 100644
index 0000000000..44e755cd28
--- /dev/null
+++ b/protocols/Xfire/src/tools.cpp
@@ -0,0 +1,1077 @@
+/*
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ *
+ * Copyright (C) 2010 by
+ * dufte <dufte@justmail.de>
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Based on J. Lawler - BaseProtocol
+ * Herbert Poul/Beat Wolf - xfirelib
+ *
+ * Miranda ICQ: the free icq client for MS Windows
+ * Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
+ *
+ */
+
+#include "stdafx.h"
+
+#include <winsock2.h>
+#include "tools.h"
+#include "xdebug.h"
+
+extern HANDLE hNetlib;
+
+//convert buf to hexstring
+/*char* tohex(unsigned char*buf,int size) {
+ static char buffer[1024*10]="";
+
+ strcpy(buffer,"");
+
+ for(int i=0;i<size;i++)
+ {
+ if(i%16==0&&i!=0)
+ sprintf(buffer,"%s\n%02x ",buffer,buf[i]);
+ else
+ sprintf(buffer,"%s%02x ",buffer,buf[i]);
+ }
+
+ return buffer;
+}*/
+
+//von icqproto kopiert
+void EnableDlgItem(HWND hwndDlg, UINT control, int state)
+{
+ EnableWindow(GetDlgItem(hwndDlg, control), state);
+}
+
+
+//eigene string replace funktion, da die von der std:string klasse immer abstürzt
+BOOL str_replace(char*src,char*find,char*rep)
+{
+ string strpath = src;
+ int pos = strpath.find(find);
+
+ if(pos>-1)
+ {
+ char *temp=new char[strlen(src)+strlen(rep)+1];
+
+ strcpy(temp,src);
+ *(temp+pos)=0;
+
+ strcat(temp,rep);
+ strcat(temp,(src+pos+strlen(find)));
+ strcpy(src,temp);
+
+ delete temp;
+
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/* popup darstellen */
+int displayPopup(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,HICON hicon)
+{
+ static signed char bUsePopups = -1;
+ static BOOL bIconsNotLoaded = TRUE;
+
+ static HICON hicNotify = NULL, hicWarning = NULL, hicError = NULL;
+
+ if ((uType&MB_TYPEMASK) == MB_OK)
+ {
+ POPUPDATAEX ppd = {0};
+
+ if (bIconsNotLoaded)
+ {
+ hicNotify = Skin_GetIcon("popup_notify");
+ hicWarning = Skin_GetIcon("popup_warning");
+ hicError = Skin_GetIcon("popup_error");
+ bIconsNotLoaded = FALSE;
+ }
+
+ lstrcpynA(ppd.lpzContactName, lpCaption, sizeof(ppd.lpzContactName));
+ lstrcpynA(ppd.lpzText, lpText, sizeof(ppd.lpzText));
+
+ if ((uType&MB_ICONMASK) == MB_ICONSTOP)
+ {
+ ppd.lchIcon = hicError;
+ ppd.colorBack = RGB(191,0,0);
+ ppd.colorText = RGB(255,245,225);
+ } else
+ if ((uType&MB_ICONMASK) == MB_ICONWARNING)
+ {
+ ppd.lchIcon = hicWarning;
+ ppd.colorBack = RGB(210,210,150);
+ ppd.colorText = RGB(0,0,0);
+ } else
+ /* if ((uType&MB_ICONMASK) == MB_ICONINFORMATION) */
+ {
+ ppd.lchIcon = hicNotify;
+ ppd.colorBack = RGB(230,230,230);
+ ppd.colorText = RGB(0,0,0);
+ }
+
+ if(hicon!=NULL)
+ ppd.lchIcon=hicon;
+
+ PUAddPopUpEx(&ppd);
+ }
+
+ return IDOK;
+}
+
+char*menuitemtext(char*mtext)
+{
+ static char temp[256]="";
+ int anz=0;
+ int j=0;
+
+ if(!mtext)
+ return NULL;
+
+ int size=strlen(mtext);
+
+ if(!size || size>255)
+ return mtext;
+
+ //alle & zeichen zählen
+ for(int i=0;i<size;i++,j++)
+ {
+ temp[j]=mtext[i];
+ if(mtext[i]=='&')
+ {
+ j++;
+ temp[j]='&';
+ }
+ }
+ //terminieren
+ temp[j]=0;
+
+ return temp;
+}
+
+void Message(LPVOID msg)
+{
+ switch(DBGetContactSettingByte(NULL,protocolname,"nomsgbox",0))
+ {
+ case 1:
+ return;
+ case 2:
+ displayPopup(NULL,(LPCSTR)msg,"Miranda XFire Protocol Plugin",MB_OK);
+ return;
+ }
+
+ MSGBOXPARAMS mbp;
+ mbp.cbSize=sizeof(mbp);
+ mbp.hwndOwner=NULL;
+ mbp.hInstance=hinstance;
+ mbp.lpszText=(char*)msg;
+ mbp.lpszCaption="Miranda XFire Protocol Plugin";
+ mbp.dwStyle=MB_USERICON;
+ mbp.lpszIcon=MAKEINTRESOURCE(IDI_TM);
+ mbp.dwContextHelpId=NULL;
+ mbp.lpfnMsgBoxCallback=NULL;
+ mbp.dwLanguageId=LANG_ENGLISH;
+ MessageBoxIndirect(&mbp);
+ //MessageBoxA(0,(char*)msg,"Miranda XFire Protocol Plugin",MB_OK|MB_ICONINFORMATION);
+}
+
+void MessageE(LPVOID msg)
+{
+ static BOOL already=FALSE;
+ switch(DBGetContactSettingByte(NULL,protocolname,"nomsgbox",0))
+ {
+ case 0:
+ if(!already)
+ {
+ already=TRUE; //keine doppelte fehlernachrichten
+ Message(msg);
+ already=FALSE;
+ }
+ break;
+ case 2:
+ displayPopup(NULL,(LPCSTR)msg,"Miranda XFire Protocol Plugin",MB_OK|MB_ICONSTOP);
+ break;
+ }
+}
+
+//funktion soll pfad erkennen und zurückgeben
+char* GetLaunchPath(char*launch)
+{
+ static char temp[XFIRE_MAX_STATIC_STRING_LEN]="";
+ char find[]=".exe "; //gesucht wird
+ char * p = temp;
+ char * f = find;
+
+ if(launch==NULL)
+ return temp;
+
+ strcpy(temp,launch);
+
+ while(*p!=0&&*f!=0)
+ {
+ if(tolower(*p)==*f)
+ {
+ f++;
+ }
+ else
+ f=find;
+
+ p++;
+ }
+
+ if(*f==0)
+ {
+ *p=0;
+ }
+ else
+ return temp;
+
+ if(strrchr(temp,'\\'))
+ {
+ *(strrchr(temp,'\\'))=0;
+ }
+
+ return temp;
+}
+//roll bits, vllt ein tickschneller als die funktionen von winsock
+unsigned short r(unsigned short data)
+{
+ _asm {
+ mov ax,data
+ rol ax,8
+ mov data,ax
+ }
+ return data;
+}
+
+//simple und hoffetnlich schnelle teamspeakdetection
+BOOL FindTeamSpeak(DWORD*pid,int*vid) {
+ BOOL found=FALSE;
+ if(pid==NULL)
+ return FALSE;
+
+ HANDLE hSnapShot = CreateToolhelp32Snapshot ( TH32CS_SNAPALL, 0);
+ PROCESSENTRY32* processInfo = new PROCESSENTRY32;
+ processInfo->dwSize = sizeof ( PROCESSENTRY32);
+
+// XFireLog("Scanning for voiceprograms ...");
+
+
+ while ( Process32Next ( hSnapShot,processInfo ) != FALSE)
+ {
+ if(processInfo->th32ProcessID!=0) {
+ int size=strlen(processInfo->szExeFile);
+
+ if(size==13)
+ {
+ if((processInfo->szExeFile[0]=='T'||processInfo->szExeFile[0]=='t')&&
+ processInfo->szExeFile[1]=='e'&&
+ processInfo->szExeFile[2]=='a'&&
+ processInfo->szExeFile[3]=='m'&&
+ processInfo->szExeFile[4]=='S'&&
+ processInfo->szExeFile[5]=='p'&&
+ processInfo->szExeFile[6]=='e'&&
+ processInfo->szExeFile[7]=='a'&&
+ processInfo->szExeFile[8]=='k')
+ {
+ *pid=processInfo->th32ProcessID;
+ found=TRUE;
+ *vid=32;
+ break;
+ }
+ }
+ else if(size==12)
+ {
+ if((processInfo->szExeFile[0]=='V'||processInfo->szExeFile[0]=='v')&&
+ processInfo->szExeFile[1]=='e'&&
+ processInfo->szExeFile[2]=='n'&&
+ processInfo->szExeFile[3]=='t'&&
+ processInfo->szExeFile[4]=='r'&&
+ processInfo->szExeFile[5]=='i'&&
+ processInfo->szExeFile[6]=='l'&&
+ processInfo->szExeFile[7]=='o')
+ {
+ *pid=processInfo->th32ProcessID;
+ found=TRUE;
+ *vid=33;
+ break;
+ }
+ }
+ else if(size==10)
+ {
+ if((processInfo->szExeFile[0]=='m'||processInfo->szExeFile[0]=='M')&&
+ processInfo->szExeFile[1]=='u'&&
+ processInfo->szExeFile[2]=='m'&&
+ processInfo->szExeFile[3]=='b'&&
+ processInfo->szExeFile[4]=='l'&&
+ processInfo->szExeFile[5]=='e')
+ {
+ *pid=processInfo->th32ProcessID;
+ found=TRUE;
+ *vid=34;
+ break;
+ }
+ }
+ }
+ }
+ CloseHandle ( hSnapShot);
+ return found;
+}
+
+//funktion wird in main gesetzt
+extern pGetExtendedUdpTable _GetExtendedUdpTable;
+
+
+#include <vector>
+
+#define maxuppackets 4
+
+//funktion liefer ip/port einer verbindung
+BOOL GetServerIPPort(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1,char*ip2,char*ip3,char*ip4,long*port)
+{
+ static std::vector<int> localport;
+ static const int hdrInclude = 1;
+ static int lastip=0;
+ static int lastport=0;
+ static int lastpid=0;
+
+ //DUMP("***Suche IP/Port***","");
+
+ //wenn die funktion nicht initialisiert werden konnte, könne wir nicht serverip und port rausbekommen
+ if(_GetExtendedUdpTable==NULL)
+ {
+ XFireLog("no GetExtendedUdpTable function");
+ return FALSE;
+ }
+
+ if(pid!=lastpid)
+ {
+ lastip=lastport=0;
+ lastpid=pid;
+ }
+
+ DWORD size=0;
+ MIB_UDPTABLE_OWNER_PID * ptab=NULL;
+
+ _GetExtendedUdpTable(NULL,&size,FALSE, AF_INET, UDP_TABLE_OWNER_PID, 0);
+ ptab=(MIB_UDPTABLE_OWNER_PID*)malloc(size);
+ int ret=_GetExtendedUdpTable(ptab,&size,FALSE, AF_INET, UDP_TABLE_OWNER_PID, 0);
+ //alle grad geöffnet updverb nach der pid vom spiel suchen, um an den port ranzukommen
+ if(ret==NO_ERROR)
+ {
+ BOOL notfound=TRUE;
+ for(unsigned int i=0;i<ptab->dwNumEntries;i++)
+ {
+ if(ptab->table[i].dwOwningPid==pid) //spiel gefunden
+ {
+ localport.push_back(ptab->table[i].dwLocalPort);
+ //DUMP("Localport: %d",ptab->table[i].dwLocalPort);
+ //localport=; //port wird gesichert
+ //break; //wir brauchen nicht mehr suchen
+ notfound=FALSE;
+ }
+ }
+ if(notfound) //kein port gefunden
+ {
+ //DUMP("Kein Localport gefunden","");
+ XFireLog("no local port found");
+ return FALSE; //dann erstmal schluss
+ }
+ }
+ else
+ {
+ XFireLog("GetExtendedUdpTable error!");
+ return FALSE;
+ }
+
+ if(ptab) delete ptab; //speicher frei machn
+
+
+ //socker erstellen
+ SOCKET s;
+ s = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
+ if(s==INVALID_SOCKET)
+ {
+ //DUMP("Kann Rawsocket nicht erstellen. Error: %d",WSAGetLastError());
+ XFireLog("unable to create raw socket %d",WSAGetLastError());
+ closesocket(s);
+ return FALSE;
+ }
+
+ static struct sockaddr_in msockaddr;
+ memset(&msockaddr,0,sizeof(msockaddr));
+ msockaddr.sin_addr.s_addr = localaddr;
+ msockaddr.sin_family = AF_INET;
+ msockaddr.sin_port = 0;
+
+ //socket an nw binden
+ if (bind(s, (sockaddr *)&msockaddr, sizeof(msockaddr)) == SOCKET_ERROR)
+ {
+ //DUMP("Kann Rawsocket nicht binden. Error: %d",WSAGetLastError());
+ XFireLog("unable to bind raw socket %d",WSAGetLastError());
+ closesocket(s);
+ return FALSE;
+ }
+
+ //wir wollen alles was da reinkommt haben
+ static int I = 1;
+ static DWORD b;
+ if (WSAIoctl(s, _WSAIOW(IOC_VENDOR,1), &I, sizeof(I), NULL, NULL, &b, NULL, NULL) == SOCKET_ERROR)
+ {
+ //DUMP("IOCTL Error","");
+ /*closesocket(s);
+ return FALSE;*/
+ XFireLog("IOCTL error %d",WSAGetLastError());
+ //unter bestimmten umständen schlägt es hier fehl, dann lass trotzdem ip weiter erkennen
+ }
+
+ //socket soll timeout auswerfen, wenn nix kommt, damit der gamethread nicht hängt
+ //DUMP("timeout>>>","");
+ static int timeout=200;
+ if(setsockopt(s, SOL_SOCKET, SO_RCVTIMEO,(char*)&timeout, sizeof(timeout) == SOCKET_ERROR))
+ {
+ XFireLog("setsockopt(SO_RCVTIMEO) error %d",WSAGetLastError());
+ }
+
+ //updstruct, nur mit wichtigen sachen
+ struct mpacket {
+ unsigned char ipv;
+ char dmp[11]; //dummy
+ //srcip, serverip
+ unsigned char ip1;
+ unsigned char ip2;
+ unsigned char ip3;
+ unsigned char ip4;
+ //unsere nw
+ unsigned int ipdst;
+ char temp[1024];
+ };
+ struct mpacket2 {
+ unsigned char ipv;
+ char dmp[11]; //dummy
+ //srcip, serverip
+ unsigned long srcip;
+ //server ip
+ unsigned char ip1;
+ unsigned char ip2;
+ unsigned char ip3;
+ unsigned char ip4;
+ char temp[1024];
+ };
+ struct udp {
+ //srcport
+ u_short srcport;
+ //dstport
+ u_short dstport;
+ };
+
+ mpacket temp={0}; //empfamngsbuffer
+ udp * temp2;
+ char * temp3;
+ mpacket2 * temp4;
+
+ for (int I=0;I<maxuppackets;I++) //maximal 4 packete, das reicht
+ {
+ int msize=recv(s,(char*)&temp,sizeof(mpacket),0);
+ if(msize) //empfangen
+ {
+ /*DUMP("Packet empfangen","");
+ DUMP("Dump Full packet##############","");
+ DUMP(tohex((unsigned char*)&temp,msize),"");
+ DUMP("Dump Full packet##############","");
+
+ DUMP("Headersize: %d",(temp.ipv & 0x0f)*4);*/
+
+ temp3=(char*)&temp;
+ temp3+=(temp.ipv & 0x0f)*4;
+ temp2=(udp*)temp3;
+ temp4=(mpacket2*)&temp;
+
+ /*DUMP("Dump Udp##############","");
+ DUMP(tohex((unsigned char*)temp2,sizeof(udp)),"");
+ DUMP("Dump Udp##############","");*/
+
+
+ for(unsigned int i = 0 ; i < localport.size() ; i++)
+ {
+ //DUMP("destport %d ==",temp2->dstport);
+ //DUMP("== %d",localport.at(i));
+ if(temp2->dstport==localport.at(i)/*FIX: für XP SP3 ->*/&&temp4->srcip!=localaddr) //ist das ziel des packets, gleich dem port des spiels
+ {
+ *port=r(temp2->srcport); //ja dann serverdaten an gamethread übermitteln
+ *ip1=temp.ip1;
+ *ip2=temp.ip2;
+ *ip3=temp.ip3;
+ *ip4=temp.ip4;
+ closesocket(s); //socket zumachn
+
+ //DUMP("SourceIP %d",temp4->srcip);
+ //DUMP("SourcePort %d",temp2->srcport);
+ if(lastip!=temp4->srcip||temp2->srcport!=lastport)
+ {
+ lastport=temp2->srcport; //fixed port wechsel, damit dieser auch mitgetielt wird, wenn zb vorher nur serverinfos angefordert wurden
+ lastip=temp4->srcip;
+ closesocket(s);
+ //DUMP("IP gefunden","");
+ XFireLog("got ip!");
+ return TRUE;
+ }
+
+ XFireLog("no serverip found!");
+ return FALSE;
+ }
+ /* else if(temp4->srcip==localaddr && temp2->srcport==localport.at(i)) //gesendete gamepackets
+ {
+ *port=r(temp2->dstport); //ja dann serverdaten an gamethread übermitteln
+ *ip1=temp4->ip1;
+ *ip2=temp4->ip2;
+ *ip3=temp4->ip3;
+ *ip4=temp4->ip4;
+ closesocket(s); //socket zumachn
+ return TRUE;
+ }*/
+ }
+ }
+ else if(msize==SOCKET_ERROR)
+ {
+ XFireLog("recv() error %d",WSAGetLastError());
+ }
+ }
+ closesocket(s); //socket zumachn
+ lastip=0;
+ lastport=0;
+ return TRUE;
+}
+
+//funktion liefert ip/port einer verbindung, dupliziert für teamspeak/ventrilo, wegen static vals
+//TODO: eventuell umbauen, damit es für beide genutzt werden kann
+BOOL GetServerIPPort2(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1,char*ip2,char*ip3,char*ip4,long*port)
+{
+ static std::vector<int> localport;
+ static const int hdrInclude = 1;
+ static int lastip=0;
+ static int lastpid=0;
+ static int lastport=0;
+
+ //wenn die funktion nicht initialisiert werden konnte, könne wir nicht serverip und port rausbekommen
+ if(_GetExtendedUdpTable==NULL)
+ return FALSE;
+
+ if(pid!=lastpid)
+ {
+ lastip=lastport=0;
+ lastpid=pid;
+ }
+
+ DWORD size=0;
+ MIB_UDPTABLE_OWNER_PID * ptab=NULL;
+
+ _GetExtendedUdpTable(NULL,&size,FALSE, AF_INET, UDP_TABLE_OWNER_PID, 0);
+ ptab=(MIB_UDPTABLE_OWNER_PID*)malloc(size);
+ int ret=_GetExtendedUdpTable(ptab,&size,FALSE, AF_INET, UDP_TABLE_OWNER_PID, 0);
+ //alle grad geöffnet updverb nach der pid vom spiel suchen, um an den port ranzukommen
+ if(ret==NO_ERROR)
+ {
+ BOOL notfound=TRUE;
+ for(unsigned int i=0;i<ptab->dwNumEntries;i++)
+ {
+ if(ptab->table[i].dwOwningPid==pid) //spiel gefunden
+ {
+ localport.push_back(ptab->table[i].dwLocalPort);
+ //localport=; //port wird gesichert
+ //break; //wir brauchen nicht mehr suchen
+ notfound=FALSE;
+ }
+ }
+ if(notfound) //kein port gefunden
+ {
+ if(lastip!=0)
+ {
+ lastip=0;
+ lastport=0;
+ return TRUE;
+ }
+ return FALSE; //dann erstmal schluss
+ }
+ }
+ else
+ return FALSE;
+
+ if(ptab) delete ptab; //speicher frei machn
+
+
+ //socker erstellen
+ SOCKET s;
+ s = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
+
+ static struct sockaddr_in msockaddr;
+ memset(&msockaddr,0,sizeof(msockaddr));
+ msockaddr.sin_addr.s_addr = localaddr;
+ msockaddr.sin_family = AF_INET;
+ msockaddr.sin_port = 0;
+
+ //socket an nw binden
+ if (bind(s, (sockaddr *)&msockaddr, sizeof(msockaddr)) == SOCKET_ERROR)
+ {
+ closesocket(s);
+ return FALSE;
+ }
+
+ //wir wollen alles was da reinkommt haben
+ static int I = 1;
+ DWORD b;
+ if (WSAIoctl(s, _WSAIOW(IOC_VENDOR,1), &I, sizeof(I), NULL, NULL, &b, NULL, NULL) == SOCKET_ERROR)
+ {
+ /*closesocket(s);
+ return FALSE;*/
+ //unter bestimmten umständen schlägt es hier fehl, dann lass trotzdem ip weiter erkennen
+ }
+
+ //socket soll timeout auswerfen, wenn nix kommt, damit der gamethread nicht hängt
+ //DUMP("timeout>>>","");
+ static int timeout=200;
+ setsockopt(s, SOL_SOCKET, SO_RCVTIMEO,(char*)&timeout, sizeof(timeout));
+
+ //updstruct, nur mit wichtigen sachen
+ struct mpacket {
+ unsigned char ipv;
+ char dmp[11]; //dummy
+ //srcip, serverip
+ unsigned char ip1;
+ unsigned char ip2;
+ unsigned char ip3;
+ unsigned char ip4;
+ //unsere nw
+ unsigned int ipdst;
+ char temp[1024];
+ };
+ struct mpacket2 {
+ unsigned char ipv;
+ char dmp[11]; //dummy
+ //srcip, serverip
+ unsigned long srcip;
+ //server ip
+ unsigned char ip1;
+ unsigned char ip2;
+ unsigned char ip3;
+ unsigned char ip4;
+ char temp[1024];
+ };
+ struct udp {
+ //srcport
+ u_short srcport;
+ //dstport
+ u_short dstport;
+ };
+
+ mpacket temp={0}; //empfamngsbuffer
+ udp * temp2;
+ char * temp3;
+ mpacket2 * temp4;
+
+ for (int I=0;I<maxuppackets;I++) //maximal 4 packete, das reicht
+ {
+ int msize=recv(s,(char*)&temp,sizeof(mpacket),0);
+ if(msize) //empfangen
+ {
+ temp3=(char*)&temp;
+ temp3+=(temp.ipv & 0x0f)*4;
+ temp2=(udp*)temp3;
+ temp4=(mpacket2*)&temp;
+
+ for(unsigned int i = 0 ; i < localport.size() ; i++)
+ if(temp2->dstport==localport.at(i)/*FIX: für XP SP3 ->*/&&temp4->srcip!=localaddr) //ist das ziel des packets, gleich dem port des spiels
+ {
+ *port=r(temp2->srcport); //ja dann serverdaten an gamethread übermitteln
+ *ip1=temp.ip1;
+ *ip2=temp.ip2;
+ *ip3=temp.ip3;
+ *ip4=temp.ip4;
+ closesocket(s); //socket zumachn
+
+ if(lastip!=temp4->srcip||temp2->srcport!=lastport)
+ {
+ lastport=temp2->srcport; //fixed port wechsel, damit dieser auch mitgetielt wird, wenn zb vorher nur serverinfos angefordert wurden
+ lastip=temp4->srcip;
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+ /* else if(temp4->srcip==localaddr && temp2->srcport==localport.at(i)) //gesendete gamepackets
+ {
+ *port=r(temp2->dstport); //ja dann serverdaten an gamethread übermitteln
+ *ip1=temp4->ip1;
+ *ip2=temp4->ip2;
+ *ip3=temp4->ip3;
+ *ip4=temp4->ip4;
+ closesocket(s); //socket zumachn
+ return TRUE;
+ }*/
+ }
+ }
+ closesocket(s); //socket zumachn
+ lastip=0;
+ lastport=0;
+ return TRUE;
+}
+
+
+char * getItem(char * string,char delim,int count)
+{
+ static char item[255];
+ char i=0;
+
+ while(*string!='\0'&&count>0)
+ {
+ if(*string==delim)
+ {
+ item[i]=0;
+ i=0;
+ count--;
+ string++;
+ }
+ else {
+ item[i]=*string;
+ i++;
+ string++;
+ }
+ }
+ if(*string=='\0')
+ item[i]=0;
+ if(count>1)
+ item[0]=0;
+
+ for(unsigned int i=0;i<strlen(item);i++)
+ {
+ item[i]=tolower(item[i]);
+ }
+
+ return item;
+}
+
+// soll commandline der spiele prüfen
+//
+// TRUE bedeutet, entweder ok, oder konnte wegen systemfehler nicht geprüft werden
+// FALSE bedeutet beinhaltet nicht das, was es soll
+//
+// get process comamndline quelle hier:
+// http://forum.sysinternals.com/forum_posts.asp?TID=6510
+#define cb 1024
+
+pZwQueryInformationProcess _ZwQueryInformationProcess = NULL;
+//pZwClose _ZwClose = NULL;
+pZwReadVirtualMemory _ZwReadVirtualMemory = NULL;
+
+BOOL checkCommandLine(HANDLE hProcess,char * mustcontain,char * mustnotcontain)
+{
+ WCHAR * buffer;
+ char * buffer2;
+ PPEB peb = NULL;
+ PPROCESS_PARAMETERS proc_params = NULL;
+ PVOID UserPool = (PVOID)LocalAlloc(LPTR, 8192);
+ PROCESS_BASIC_INFORMATION ProcessInfo;
+
+ //strings leer abbruch
+ if(!mustcontain&&!mustnotcontain)
+ return TRUE;
+
+ //prüfe und lade nötige funktionen
+ if(_ZwQueryInformationProcess==NULL)
+ {
+ _ZwQueryInformationProcess = (pZwQueryInformationProcess)GetProcAddress(GetModuleHandle( "ntdll.dll"), "ZwQueryInformationProcess");
+ if(_ZwQueryInformationProcess==NULL)
+ {
+ return TRUE;
+ }
+ }
+ if(_ZwReadVirtualMemory==NULL)
+ {
+ _ZwReadVirtualMemory = (pZwReadVirtualMemory)GetProcAddress(GetModuleHandle( "ntdll.dll"), "ZwReadVirtualMemory");
+ if(_ZwReadVirtualMemory==NULL)
+ {
+ return TRUE;
+ }
+ }
+
+ //commandline bekommen, siehe link oben
+ ULONG rc = _ZwQueryInformationProcess(hProcess,ProcessBasicInformation,&ProcessInfo,sizeof(ProcessInfo),NULL);
+
+ rc = _ZwReadVirtualMemory(hProcess,ProcessInfo.PebBaseAddress, UserPool, sizeof(PEB), NULL);
+
+ peb = (PPEB)UserPool;
+ rc = _ZwReadVirtualMemory(hProcess,peb->ProcessParameters,UserPool,sizeof(PROCESS_PARAMETERS),NULL);
+
+ proc_params = (PPROCESS_PARAMETERS)UserPool;
+ ULONG uSize = 0;
+ LPVOID pBaseAddress = NULL;
+
+ uSize = proc_params->CommandLine.Length;
+ pBaseAddress = proc_params->CommandLine.Buffer;
+
+ //keine commandline?!
+ if(uSize==0||pBaseAddress==NULL)
+ {
+ LocalFree(UserPool);
+ return FALSE;
+ }
+
+ buffer=(WCHAR*)new char[uSize];
+
+ rc = _ZwReadVirtualMemory(hProcess, pBaseAddress, buffer, uSize, NULL);
+
+ //in ansi umwandeln
+ int correctsize=WideCharToMultiByte(CP_OEMCP, 0, buffer, -1, NULL, 0, NULL, NULL);
+
+ if(correctsize==0)
+ {
+ LocalFree(UserPool);
+ return FALSE;
+ }
+
+ buffer2=new char[correctsize];
+ WideCharToMultiByte(CP_OEMCP, 0, buffer, -1, buffer2,correctsize,NULL,NULL);
+ buffer2[correctsize-1]=0;
+
+
+ for(unsigned int i=0;i<strlen(buffer2);i++)
+ {
+ buffer2[i]=tolower(buffer2[i]);
+ }
+
+ //lowercase mustcontain/mustnotcontain
+ if(mustcontain)
+ for(unsigned int i=0;i<strlen(mustcontain);i++)
+ {
+ mustcontain[i]=tolower(mustcontain[i]);
+ }
+ if(mustnotcontain)
+ for(unsigned int i=0;i<strlen(mustnotcontain);i++)
+ {
+ mustnotcontain[i]=tolower(mustnotcontain[i]);
+ }
+
+ string cmdline=buffer2;
+
+ if(mustcontain)
+ if(cmdline.find(mustcontain)!=string::npos)
+ {
+ delete[] buffer;
+ delete[] buffer2;
+ LocalFree(UserPool);
+ return TRUE;
+ }
+ else
+ {
+ delete[] buffer;
+ delete[] buffer2;
+ LocalFree(UserPool);
+ return FALSE;
+ }
+
+ int count=1;
+ if(mustnotcontain)
+ {
+ char*str=getItem(mustnotcontain,';',count);
+ do {
+ if(cmdline.find(str)!=string::npos)
+ {
+ delete[] buffer;
+ delete[] buffer2;
+ LocalFree(UserPool);
+ return FALSE;
+ }
+ count++;
+ str=getItem(mustnotcontain,';',count);
+ }
+ while(*str!=0);
+ }
+
+ //_ZwClose(hProcess);
+ LocalFree(UserPool);
+ delete[] buffer;
+ delete[] buffer2;
+
+ return TRUE;
+}
+
+#define RECV_BUFFER_SIZE 6144
+
+BOOL CheckWWWContent(char*address) {
+ Netlib_Logf(hNetlib,"Check Url %s ...",address);
+
+ //netlib request
+ NETLIBHTTPREQUEST nlhr={0},*nlhrReply;
+ nlhr.cbSize = sizeof(nlhr);
+ nlhr.requestType= REQUEST_HEAD;
+ nlhr.flags = NLHRF_NODUMP|NLHRF_GENERATEHOST|NLHRF_SMARTAUTHHEADER;
+ nlhr.szUrl = address;
+
+ nlhrReply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,(WPARAM)hNetlib,(LPARAM)&nlhr);
+
+ if(nlhrReply) {
+ //nicht auf dem server
+ Netlib_Logf(hNetlib,"Resultcode %d ...",nlhrReply->resultCode);
+ if (nlhrReply->resultCode != 200) {
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
+ return FALSE;
+ }
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
+ }
+ else
+ return FALSE;
+
+ return TRUE;
+}
+
+
+BOOL GetWWWContent2(char*address,char*filename,BOOL dontoverwrite,char**tobuf,unsigned int* size) {
+ if(dontoverwrite==TRUE)
+ {
+ if(GetFileAttributes(filename)!=0xFFFFFFFF)
+ {
+ Netlib_Logf(hNetlib,"%s already exists, no overwrite.",filename);
+ return TRUE;
+ }
+ }
+ Netlib_Logf(hNetlib,"Download Url %s ...",address);
+
+ //netlib request
+ NETLIBHTTPREQUEST nlhr={0},*nlhrReply;
+ nlhr.cbSize = sizeof(nlhr);
+ nlhr.requestType= REQUEST_GET;
+ nlhr.flags = NLHRF_NODUMP|NLHRF_GENERATEHOST|NLHRF_SMARTAUTHHEADER;
+ nlhr.szUrl = address;
+
+ nlhrReply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,(WPARAM)hNetlib,(LPARAM)&nlhr);
+
+ if(nlhrReply) {
+ //nicht auf dem server
+ if (nlhrReply->resultCode != 200) {
+ Netlib_Logf(hNetlib,"Bad statuscode: %d",nlhrReply->resultCode);
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
+ return FALSE;
+ }
+ //keine daten für mich
+ else if (nlhrReply->dataLength < 1 || nlhrReply->pData == NULL)
+ {
+ Netlib_Logf(hNetlib,"No data received.");
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
+ return FALSE;
+ }
+ else
+ {
+ if(tobuf==NULL)
+ {
+ FILE * f = fopen(filename,"wb");
+ if(f==NULL)
+ {
+ Netlib_Logf(hNetlib,"Cannot open %s for binary write mode.",filename);
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
+ return FALSE;
+ }
+ fwrite(nlhrReply->pData,nlhrReply->dataLength,1,f);
+ fclose(f);
+ }
+ else
+ {
+ if(*tobuf==NULL)
+ {
+ *tobuf=new char[nlhrReply->dataLength+1];
+ memcpy_s(*tobuf,nlhrReply->dataLength,nlhrReply->pData,nlhrReply->dataLength);
+ //0 terminieren
+ (*tobuf)[nlhrReply->dataLength]=0;
+ //größe zurückliefern, wenn gewollt
+ if(size)
+ *size=nlhrReply->dataLength+1;
+ }
+ }
+ }
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
+ }
+ else
+ {
+ Netlib_Logf(hNetlib,"No valid Netlib Request.",filename);
+ return FALSE;
+ }
+ return TRUE;
+}
+//eigener www downloader, da winet exceptions erzeugt
+BOOL GetWWWContent(char*host,char* request,char*filename,BOOL dontoverwrite) {
+ char add[1024]="http://";
+ strcat(add,host);
+ strcat(add,request);
+
+ return GetWWWContent2(add,filename,dontoverwrite);
+}
+
+unsigned int getfilesize(char*path)
+{
+ FILE * f = NULL;
+ f=fopen(path,"rb");
+ if(f==NULL)
+ return 0;
+ fseek (f, 0, SEEK_END);
+ int size=ftell (f);
+ fclose (f);
+ return size;
+}
+
+//funktion soll erst in der userini suchen, danach in der xfire_games.ini
+DWORD xfire_GetPrivateProfileString(__in LPCTSTR lpAppName, __in LPCTSTR lpKeyName, __in LPCTSTR lpDefault, __out LPTSTR lpReturnedString, __in DWORD nSize, __in LPCTSTR lpFileName) {
+ //xfire_games.ini
+ int size=strlen(lpFileName);
+ if(size>15)
+ {
+ char*file=(char*)lpFileName;
+ int ret=0;
+ *(file+size-14)='u';
+ *(file+size-13)='s';
+ *(file+size-12)='e';
+ *(file+size-11)='r';
+ ret = GetPrivateProfileString( lpAppName,lpKeyName,lpDefault,lpReturnedString,nSize,lpFileName);
+ if(ret)
+ {
+ return ret;
+ }
+ else
+ {
+ *(file+size-14)='f';
+ *(file+size-13)='i';
+ *(file+size-12)='r';
+ *(file+size-11)='e';
+ return GetPrivateProfileString( lpAppName,lpKeyName,lpDefault,lpReturnedString,nSize,lpFileName);
+ }
+ }
+ return GetPrivateProfileString( lpAppName,lpKeyName,lpDefault,lpReturnedString,nSize,lpFileName);
+}
+
+
+BOOL mySleep(int ms,HANDLE evt) {
+ switch(WaitForSingleObject(evt,ms))
+ {
+ case WAIT_TIMEOUT:
+ return FALSE;
+ case WAIT_ABANDONED:
+ //MessageBox(NULL,"Abbruch","Abbruch",0);
+ return TRUE;
+ default:
+ return TRUE;
+ }
+
+ return FALSE;
+} \ No newline at end of file
diff --git a/protocols/Xfire/src/tools.h b/protocols/Xfire/src/tools.h
new file mode 100644
index 0000000000..ca0b906179
--- /dev/null
+++ b/protocols/Xfire/src/tools.h
@@ -0,0 +1,99 @@
+
+#ifndef _TOOLS_H
+#define _TOOLS_H
+
+#include "baseProtocol.h"
+
+#include <m_popup.h>
+#include <string>
+using std::string;
+
+//****************************
+//get commandline header stuff
+//****************************
+typedef struct _UNICODE_STRING {
+USHORT Length;
+USHORT MaximumLength;
+PWSTR Buffer;
+} UNICODE_STRING;
+typedef UNICODE_STRING *PUNICODE_STRING;
+typedef enum _PROCESSINFOCLASS {
+ ProcessBasicInformation
+} PROCESSINFOCLASS;
+typedef struct _PEB_LDR_DATA {
+ BYTE Reserved1[8];
+ PVOID Reserved2[3];
+ LIST_ENTRY InMemoryOrderModuleList;
+} PEB_LDR_DATA,
+ *PPEB_LDR_DATA;
+typedef struct _RTL_USER_PROCESS_PARAMETERS {
+ BYTE Reserved1[16];
+ PVOID Reserved2[10];
+ UNICODE_STRING ImagePathName;
+ UNICODE_STRING CommandLine;
+} RTL_USER_PROCESS_PARAMETERS,
+ *PRTL_USER_PROCESS_PARAMETERS;
+typedef struct _PEB {
+ BYTE Reserved1[2];
+ BYTE BeingDebugged;
+ BYTE Reserved2[1];
+ PVOID Reserved3[2];
+ PPEB_LDR_DATA Ldr;
+ PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
+ BYTE Reserved4[104];
+ PVOID Reserved5[52];
+ void* PostProcessInitRoutine;
+ BYTE Reserved6[128];
+ PVOID Reserved7[1];
+ ULONG SessionId;
+} PEB,
+ *PPEB;
+typedef struct
+{
+ULONG AllocationSize;
+ULONG ActualSize;
+ULONG Flags;
+ULONG Unknown1;
+UNICODE_STRING Unknown2;
+HANDLE InputHandle;
+HANDLE OutputHandle;
+HANDLE ErrorHandle;
+UNICODE_STRING CurrentDirectory;
+HANDLE CurrentDirectoryHandle;
+UNICODE_STRING SearchPaths;
+UNICODE_STRING ApplicationName;
+UNICODE_STRING CommandLine;
+PVOID EnvironmentBlock;
+ULONG Unknown[9];
+UNICODE_STRING Unknown3;
+UNICODE_STRING Unknown4;
+UNICODE_STRING Unknown5;
+UNICODE_STRING Unknown6;
+} PROCESS_PARAMETERS, *PPROCESS_PARAMETERS;
+typedef struct _PROCESS_BASIC_INFORMATION {
+ PVOID Reserved1;
+ PPEB PebBaseAddress;
+ PVOID Reserved2[2];
+ ULONG_PTR UniqueProcessId;
+ PVOID Reserved3;
+} PROCESS_BASIC_INFORMATION;
+
+typedef ULONG (WINAPI *pZwQueryInformationProcess)(
+ IN HANDLE ProcessHandle,
+ IN PROCESSINFOCLASS ProcessInformationClass,
+ OUT PVOID ProcessInformation,
+ IN ULONG ProcessInformationLength,
+ OUT PULONG ReturnLength OPTIONAL
+);
+typedef ULONG (WINAPI *pZwClose)(
+ IN HANDLE Handle
+);
+typedef ULONG (WINAPI *pZwReadVirtualMemory)(
+ IN HANDLE ProcessHandle,
+ IN PVOID BaseAddress,
+ OUT PVOID Buffer,
+ IN ULONG BufferLength,
+ OUT PULONG ReturnLength OPTIONAL
+);
+
+#endif \ No newline at end of file
diff --git a/protocols/Xfire/src/userdetails.cpp b/protocols/Xfire/src/userdetails.cpp
new file mode 100644
index 0000000000..4ea28ffa98
--- /dev/null
+++ b/protocols/Xfire/src/userdetails.cpp
@@ -0,0 +1,449 @@
+/*
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ *
+ * Copyright (C) 2010 by
+ * dufte <dufte@justmail.de>
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Based on J. Lawler - BaseProtocol
+ * Herbert Poul/Beat Wolf - xfirelib
+ *
+ * Miranda ICQ: the free icq client for MS Windows
+ * Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
+ *
+ */
+
+#include "stdafx.h"
+
+#include "baseProtocol.h"
+#include "Xfire_gamelist.h"
+#include <string>
+
+HWND ghwndDlg=NULL;
+extern HANDLE XFireWorkingFolder;
+extern Xfire_gamelist xgamelist;
+
+
+//als funktion, damit es per thread geladen werden kann
+void LoadProfilStatus(LPVOID lparam) {
+ if(!lparam || !ghwndDlg)
+ return;
+
+ //dl
+ char url[255]="http://miniprofile.xfire.com/bg/sh/type/1/";
+ char* buf=NULL;
+ unsigned int size=0;
+ strcat_s(url,255,(char*)lparam);
+ strcat_s(url,255,".png");
+
+ //versuche das icon aus dem inet zulasen
+ if(GetWWWContent2(url,NULL,FALSE,&buf,&size))
+ {
+ //aus dem buffer ein hicon erzeugen
+ HBITMAP hbitmap=xgamelist.createHBITMAPfromdata(buf,size);
+ //speicher freigeben
+ delete[] buf;
+ SendMessage(GetDlgItem(ghwndDlg,IDC_PROFILIMG),STM_SETIMAGE,IMAGE_BITMAP,(LPARAM)hbitmap);
+ }
+ delete[] lparam;
+}
+
+void SetItemTxt(HWND hwndDlg,int feldid,char*feld,HANDLE hcontact,int type)
+{
+ DBVARIANT dbv;
+ if(!DBGetContactSetting(hcontact,protocolname,feld,&dbv)) {
+ if(type==1)
+ {
+ char temp[255];
+ sprintf(temp,"%i",dbv.wVal);
+ SetDlgItemText(hwndDlg,feldid,temp);
+ }
+ else
+ {
+ SetDlgItemText(hwndDlg,feldid,dbv.pszVal);
+ }
+ DBFreeVariant(&dbv);
+ EnableDlgItem(hwndDlg,feldid,TRUE);
+ }
+ else
+ {
+ SetDlgItemText(hwndDlg,feldid,Translate("<not specified>"));
+ EnableDlgItem(hwndDlg,feldid,FALSE);
+ }
+}
+
+static int GetIPPortUDetails(HANDLE wParam,char* feld1,char* feld2)
+{
+ char temp[255];
+ HGLOBAL clipbuffer;
+ char* buffer;
+
+ if(DBGetContactSettingWord((HANDLE)wParam, protocolname, feld2, -1)==0)
+ return 0;
+
+ DBVARIANT dbv;
+ if(DBGetContactSettingTString((HANDLE)wParam, protocolname, feld1,&dbv))
+ return 0;
+
+ sprintf(temp,"%s:%d",dbv.pszVal,DBGetContactSettingWord((HANDLE)wParam, protocolname, feld2, -1));
+
+ DBFreeVariant(&dbv);
+
+ if(OpenClipboard(NULL))
+ {
+ EmptyClipboard();
+
+ clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(temp)+1);
+ buffer = (char*)GlobalLock(clipbuffer);
+ strcpy(buffer, LPCSTR(temp));
+ GlobalUnlock(clipbuffer);
+
+ SetClipboardData(CF_TEXT, clipbuffer);
+ CloseClipboard();
+ }
+
+ return 0;
+}
+
+void addToList(HWND listbox,HANDLE hContact,char*key,char*val)
+{
+ DBVARIANT dbv;
+ if(!DBGetContactSetting(hContact,protocolname,val,&dbv))
+ {
+ LVITEM lvitem;
+ memset(&lvitem,0,sizeof(lvitem));
+ lvitem.mask=LVIF_TEXT;
+ lvitem.cchTextMax=255;
+ lvitem.iItem=0;
+ lvitem.iSubItem=0;
+ lvitem.pszText=key;
+ SendMessageA(listbox,LVM_INSERTITEM,0,(LPARAM)&lvitem);
+ lvitem.iSubItem++;
+ lvitem.pszText=dbv.pszVal;
+ SendMessageA(listbox,LVM_SETITEM,0,(LPARAM)&lvitem);
+ DBFreeVariant(&dbv);
+ }
+}
+
+void setGameInfo(HWND listbox,char *mbuf)
+{
+ int ii=0;
+ char temp[255];
+ char mod=0;
+ char item=0;
+ char *mbuf2=(char*)mbuf;
+ LVITEM lvitem;
+ memset(&lvitem,0,sizeof(lvitem));
+ lvitem.mask=LVIF_TEXT;
+ lvitem.cchTextMax=255;
+
+ while(*mbuf2!=0)
+ {
+ if(*mbuf2==1&&mod==0)
+ {
+ temp[ii]=0;
+ mod=1;
+ lvitem.iItem=item;
+ lvitem.iSubItem=0;
+ lvitem.pszText=temp;
+ SendMessageA(listbox,LVM_INSERTITEM,0,(LPARAM)&lvitem);
+ item++;
+ ii=-1;
+ }
+ else if(*mbuf2==2&&mod==1)
+ {
+ temp[ii]=0;
+ mod=0;
+ lvitem.iSubItem++;
+ lvitem.pszText=temp;
+ SendMessageA(listbox,LVM_SETITEM,0,(LPARAM)&lvitem);
+ ii=-1;
+ }
+ else
+ temp[ii]=*mbuf2;
+ mbuf2++;
+ ii++;
+ }
+}
+
+static BOOL CALLBACK DlgProcUserDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ static char path[XFIRE_MAX_STATIC_STRING_LEN]="";
+ static WCHAR wpath[256];
+ static HICON gameicon=0;
+ static HICON voiceicon=0;
+ static HANDLE uhandle=0;
+ static HWND listbox;
+ LVCOLUMN pcol;
+
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+
+ ghwndDlg=hwndDlg;
+
+ listbox=GetDlgItem(hwndDlg,IDC_GAMEINFOLIST);
+ pcol.mask=LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
+ pcol.pszText="Key";
+ pcol.cx=65;
+ pcol.fmt=LVCFMT_LEFT;
+ SendMessageA(listbox,LVM_INSERTCOLUMNA,1,(LPARAM)&pcol);
+ pcol.cx=80;
+ pcol.pszText="Value";
+ SendMessageA(listbox,LVM_INSERTCOLUMNA,2,(LPARAM)&pcol);
+
+ HFONT hFont;
+ LOGFONT lfFont;
+
+ memset(&lfFont, 0x00, sizeof(lfFont));
+ memcpy(lfFont.lfFaceName, TEXT("Arial"), 8);
+
+ lfFont.lfHeight = 13;
+ lfFont.lfWeight = FW_BOLD;
+ lfFont.lfCharSet = ANSI_CHARSET;
+ lfFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
+ lfFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
+ lfFont.lfQuality = DEFAULT_QUALITY;
+
+ // Create the font from the LOGFONT structure passed.
+ hFont = CreateFontIndirect (&lfFont);
+
+ SendMessageA(listbox,WM_SETFONT,(WPARAM)hFont,TRUE);
+
+ return TRUE;
+ }
+ case WM_CTLCOLORSTATIC:
+ {
+ break;
+ }
+
+ case WM_NOTIFY:
+ {
+ switch (((LPNMHDR)lParam)->idFrom)
+ {
+
+ case 0:
+ {
+ switch (((LPNMHDR)lParam)->code)
+ {
+
+ case PSN_INFOCHANGED:
+ {
+ char* szProto;
+ HANDLE hContact = (HANDLE)((LPPSHNOTIFY)lParam)->lParam;
+ uhandle=hContact; //handle sichern
+
+ if (hContact == NULL)
+ szProto = protocolname;
+ else
+ szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+
+ if (szProto == NULL)
+ break;
+
+ //alle items aus der liste entfernen
+ SendMessage(listbox,LVM_DELETEALLITEMS,0,0);
+
+ if (hContact)
+ {
+ DBVARIANT dbv;
+ if(!DBGetContactSetting(hContact,protocolname,"Username",&dbv))
+ {
+ int usernamesize=strlen(dbv.pszVal)+1;
+ char* username=new char[usernamesize];
+ if(username)
+ {
+ strcpy_s(username,usernamesize,dbv.pszVal);
+ mir_forkthread(LoadProfilStatus,(LPVOID)username);
+ }
+ //LoadProfilStatus
+ DBFreeVariant(&dbv);
+ }
+
+ if(!DBGetContactSetting(hContact,protocolname,"GameInfo",&dbv))
+ {
+ setGameInfo(listbox,dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+
+ addToList(listbox,hContact,"Servername","ServerName");
+ addToList(listbox,hContact,"GameType","GameType");
+ addToList(listbox,hContact,"Map","Map");
+ addToList(listbox,hContact,"Players","Players");
+
+ SetItemTxt(hwndDlg,IDC_DNICK,"Nick",hContact,0);
+ SetItemTxt(hwndDlg,IDC_DUSERNAME,"Username",hContact,0);
+
+ SetItemTxt(hwndDlg,IDC_GIP,"ServerIP",hContact,0);
+ SetItemTxt(hwndDlg,IDC_VIP,"VServerIP",hContact,0);
+ SetItemTxt(hwndDlg,IDC_GPORT,"Port",hContact,1);
+ SetItemTxt(hwndDlg,IDC_VPORT,"VPort",hContact,1);
+
+ SetItemTxt(hwndDlg,IDC_GAME,"RGame",hContact,0);
+ SetItemTxt(hwndDlg,IDC_VNAME,"RVoice",hContact,0);
+
+ //render icons
+ {
+ DBVARIANT dbv;
+
+ if(!DBGetContactSetting(hContact,protocolname,"GameId",&dbv))
+ {
+ SendMessage(GetDlgItem(hwndDlg,IDC_GAMEICO),STM_SETICON,(WPARAM)xgamelist.iconmngr.getGameIcon(dbv.wVal),0);
+ DBFreeVariant(&dbv);
+ }
+ if(!DBGetContactSetting(hContact,protocolname,"VoiceId",&dbv))
+ {
+ SendMessage(GetDlgItem(hwndDlg,IDC_VOICEICO),STM_SETICON,(WPARAM)xgamelist.iconmngr.getGameIcon(dbv.wVal),0);
+ DBFreeVariant(&dbv);
+ }
+
+ if(DBGetContactSetting(hContact,protocolname,"ServerIP",&dbv))
+ {
+ EnableWindow(GetDlgItem(hwndDlg,IDC_COPYGAME),FALSE);
+ DBFreeVariant(&dbv);
+ }
+ if(DBGetContactSetting(hContact,protocolname,"VServerIP",&dbv))
+ {
+ EnableWindow(GetDlgItem(hwndDlg,IDC_COPYVOICE),FALSE);
+ DBFreeVariant(&dbv);
+ }
+
+ //ShowWindow(GetDlgItem(hwndDlg,IDC_VOICEICO),FALSE)
+ }
+ }
+ }
+ break;
+ }
+ }
+ break;
+ }
+ }
+ break;
+ case WM_COMMAND:
+ {
+ switch(wParam)
+ {
+ case IDC_COPYGAME:
+ GetIPPortUDetails(uhandle,"ServerIP","Port");
+ break;
+ case IDC_COPYVOICE:
+ GetIPPortUDetails(uhandle,"VServerIP","VPort");
+ break;
+ }
+ }
+ }
+ return FALSE;
+}
+
+/*static BOOL CALLBACK DlgProcUserDetails2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ char profil[2056]="";
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ return TRUE;
+ }
+ case WM_NOTIFY:
+ {
+ switch (((LPNMHDR)lParam)->idFrom)
+ {
+ case 0:
+ {
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case PSN_INFOCHANGED:
+ {
+ char* szProto;
+ HANDLE hContact = (HANDLE)((LPPSHNOTIFY)lParam)->lParam;
+
+ if (hContact == NULL)
+ szProto = protocolname;
+ else
+ szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+
+ if (szProto == NULL)
+ break;
+
+ if (hContact) {
+ DBVARIANT dbv;
+
+ char img[256]="";
+ char username[256]="";
+ char nick[256]="";
+ char status[256]="";
+ char game[512]="";
+ if(!DBGetContactSetting(hContact,"ContactPhoto","File",&dbv))
+ {
+ snprintf(img,256,"<img src=\"%s\">",dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+ if(!DBGetContactSetting(hContact,protocolname,"Username",&dbv))
+ {
+ snprintf(username,256,"<b>Username:</b> %s<br>",dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+ if(!DBGetContactSetting(hContact,protocolname,"Nick",&dbv))
+ {
+ snprintf(nick,256,"<b>Nick:</b> %s<br>",dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+ if(!DBGetContactSetting(hContact,protocolname,"XStatusMsg",&dbv))
+ {
+ snprintf(status,256,"<b>Status:</b> %s<br>",dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+ if(!DBGetContactSetting(hContact,protocolname,"RGame",&dbv))
+ {
+ snprintf(game,512,"<fieldset style='border:1px solid #0091d5;background-color:#0d2c3e;margin-bottom:8px;'><legend>Spiel</legend><table><tr><td valign=top style='font-family:Arial;font-size:11px;color:#fff;'><b><u>%s</u></b></td></tr></table></fieldset>",dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+ snprintf(profil,2056,"mshtml:<div style='position:absolute;top:0;left:0;border:1px solid #0091d5;background-color:#000;padding:6px;width:334px;height:249px'><table><tr><td valign=top>%s</td><td valign=top style='font-family:Arial;font-size:11px;color:#fff;'>%s%s%s</td></tr><tr><td valign=top colspan=\"2\" style='font-family:Arial;font-size:11px;color:#fff;'>%s%s</td></tr></table></div>",img,username,nick,status,game);
+ HWND hWnd = ::CreateWindow("AtlAxWin", profil,
+ WS_CHILD|WS_VISIBLE, 0, 0, 334, 249, hwndDlg, NULL,
+ ::GetModuleHandle(NULL), NULL);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return FALSE;
+}*/
+
+int OnDetailsInit(WPARAM wParam,LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp = {0};
+
+ if (!IsXFireContact((HANDLE)lParam))
+ return 0;
+
+ odp.cbSize = sizeof(odp);
+ odp.hIcon = NULL;
+ odp.hInstance = hinstance;
+ odp.pfnDlgProc = DlgProcUserDetails;
+ odp.position = -1900000000;
+ odp.pszTemplate = MAKEINTRESOURCE(IDD_UD);
+ odp.pszTitle = Translate("XFire");
+ odp.pszGroup = NULL;
+
+ UserInfo_AddPage(wParam, &odp);
+
+ return 0;
+} \ No newline at end of file
diff --git a/protocols/Xfire/src/variables.cpp b/protocols/Xfire/src/variables.cpp
new file mode 100644
index 0000000000..d8479b7dc6
--- /dev/null
+++ b/protocols/Xfire/src/variables.cpp
@@ -0,0 +1,168 @@
+//fürs varaibles händling - dufte
+#include "stdafx.h"
+
+#include "variables.h"
+#include <string>
+
+using namespace std;
+
+char* Varxfiregame(ARGUMENTSINFO *ai)
+{
+ if (ai->cbSize < sizeof(ARGUMENTSINFO))
+ return NULL;
+
+ if(ai->fi->hContact==NULL)
+ {
+ //
+ }
+ else
+ {
+ char temp[256];
+ DBVARIANT dbv3;
+ if(!DBGetContactSetting(ai->fi->hContact,protocolname, "RGame",&dbv3))
+ {
+ strncpy(temp,dbv3.pszVal,255);
+ DBFreeVariant(&dbv3);
+ return mir_strdup(temp);
+ }
+ }
+
+ ai->flags = AIF_FALSE;
+ return mir_strdup("");
+}
+
+char* Varmyxfiregame(ARGUMENTSINFO *ai)
+{
+ if (ai->cbSize < sizeof(ARGUMENTSINFO))
+ return NULL;
+
+ DBVARIANT dbv3;
+ if(!DBGetContactSetting(NULL,protocolname, "currentgamename",&dbv3))
+ {
+ char* ret=mir_strdup(dbv3.pszVal);
+ DBFreeVariant(&dbv3);
+ return ret;
+ }
+ ai->flags = AIF_FALSE;
+ return mir_strdup("");
+}
+
+char* Varxfirevoice(ARGUMENTSINFO *ai)
+{
+ if (ai->cbSize < sizeof(ARGUMENTSINFO))
+ return NULL;
+
+ DBVARIANT dbv3;
+ if(!DBGetContactSetting(ai->fi->hContact,protocolname, "RVoice",&dbv3))
+ {
+ char* ret=mir_strdup(dbv3.pszVal);
+ DBFreeVariant(&dbv3);
+ return ret;
+ }
+
+ ai->flags = AIF_FALSE;
+ return mir_strdup("");
+}
+
+
+char* Varmyxfirevoiceip(ARGUMENTSINFO *ai) {
+ if (ai->cbSize < sizeof(ARGUMENTSINFO))
+ return NULL;
+
+ DBVARIANT dbv3;
+ if(!DBGetContactSetting(NULL,protocolname, "VServerIP",&dbv3))
+ {
+ char* ret=mir_strdup(dbv3.pszVal);
+ DBFreeVariant(&dbv3);
+ return ret;
+ }
+
+ ai->flags = AIF_FALSE;
+ return mir_strdup("");
+}
+
+char* Varmyxfireserverip(ARGUMENTSINFO *ai) {
+ if (ai->cbSize < sizeof(ARGUMENTSINFO))
+ return NULL;
+
+ DBVARIANT dbv3;
+ if(!DBGetContactSetting(NULL,protocolname, "ServerIP",&dbv3))
+ {
+ char* ret=mir_strdup(dbv3.pszVal);
+ DBFreeVariant(&dbv3);
+ return ret;
+ }
+
+ ai->flags = AIF_FALSE;
+ return mir_strdup("");
+}
+
+char* Varxfireserverip(ARGUMENTSINFO *ai) {
+ if (ai->cbSize < sizeof(ARGUMENTSINFO))
+ return NULL;
+
+ if(ai->fi->hContact==NULL)
+ {
+ ai->flags = AIF_FALSE;
+ return mir_strdup("");
+ }
+ else
+ {
+ char temp[24];
+ DBVARIANT dbv3;
+ if(!DBGetContactSetting(ai->fi->hContact,protocolname, "ServerIP",&dbv3))
+ {
+ sprintf(temp,"%s:%d",dbv3.pszVal,DBGetContactSettingWord(ai->fi->hContact,protocolname, "Port",0));
+ DBFreeVariant(&dbv3);
+ return mir_strdup(temp);
+ }
+ ai->flags = AIF_FALSE;
+ return mir_strdup("");
+ }
+
+ ai->flags = AIF_FALSE;
+ return mir_strdup("");
+}
+
+char* Varxfirevoiceip(ARGUMENTSINFO *ai) {
+ if (ai->cbSize < sizeof(ARGUMENTSINFO))
+ return NULL;
+
+ if(ai->fi->hContact==NULL)
+ {
+ ai->flags = AIF_FALSE;
+ return mir_strdup("");
+ }
+ else
+ {
+ char temp[24];
+ DBVARIANT dbv3;
+ if(!DBGetContactSetting(ai->fi->hContact,protocolname, "VServerIP",&dbv3))
+ {
+ sprintf(temp,"%s:%d",dbv3.pszVal,DBGetContactSettingWord(ai->fi->hContact,protocolname, "VPort",0));
+ DBFreeVariant(&dbv3);
+ return mir_strdup(temp);
+ }
+ ai->flags = AIF_FALSE;
+ return mir_strdup("");
+ }
+
+ ai->flags = AIF_FALSE;
+ return mir_strdup("");
+}
+
+char* Varmyxfirevoice(ARGUMENTSINFO *ai)
+{
+ if (ai->cbSize < sizeof(ARGUMENTSINFO))
+ return NULL;
+
+ DBVARIANT dbv3;
+ if(!DBGetContactSetting(NULL,protocolname, "currentvoicename",&dbv3))
+ {
+ char* ret=mir_strdup(dbv3.pszVal);
+ DBFreeVariant(&dbv3);
+ return ret;
+ }
+
+ return mir_strdup("");
+} \ No newline at end of file
diff --git a/protocols/Xfire/src/variables.h b/protocols/Xfire/src/variables.h
new file mode 100644
index 0000000000..74a73b1176
--- /dev/null
+++ b/protocols/Xfire/src/variables.h
@@ -0,0 +1,11 @@
+#include "baseProtocol.h"
+#include "m_variables.h"
+
+char* Varxfiregame(ARGUMENTSINFO *ai);
+char* Varmyxfiregame(ARGUMENTSINFO *ai);
+char* Varmyxfirevoice(ARGUMENTSINFO *ai);
+char* Varxfireserverip(ARGUMENTSINFO *ai);
+char* Varxfirevoice(ARGUMENTSINFO *ai);
+char* Varxfirevoiceip(ARGUMENTSINFO *ai);
+char* Varmyxfirevoiceip(ARGUMENTSINFO *ai);
+char* Varmyxfireserverip(ARGUMENTSINFO *ai); \ No newline at end of file
diff --git a/protocols/Xfire/src/variablevalue.cpp b/protocols/Xfire/src/variablevalue.cpp
new file mode 100644
index 0000000000..584f64412c
--- /dev/null
+++ b/protocols/Xfire/src/variablevalue.cpp
@@ -0,0 +1,204 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include <string>
+#include "variablevalue.h"
+#include "xdebug.h"
+
+#include "math.h" // for pow(..)
+
+namespace xfirelib {
+
+using namespace std;
+
+ VariableValue::VariableValue() {
+ value = 0;
+ }
+ VariableValue::~VariableValue() {
+ if(value)
+ delete[] value;
+ }
+
+ void VariableValue::setName(std::string name){
+ this->name = name;
+ }
+
+ void VariableValue::setValueLength(int valueLength){
+ this->valueLength = valueLength;
+ }
+
+ void VariableValue::setValue( char * value) {
+ if(this->value) delete[] value;
+ this->value = value;
+ }
+ void VariableValue::setValue( std::string value ) {
+ const char *val = value.c_str();
+ setValue( val, value.length() );
+ }
+ void VariableValue::setValue( const char *value, int valueLength ) {
+ this->value = new char[valueLength];
+ memcpy( this->value, value, valueLength );
+ this->valueLength = valueLength;
+ }
+ void VariableValue::setValueFromLong( long value, int bytes ) {
+ this->valueLength = bytes;
+ this->value = new char[bytes];
+ for(int i = 0 ; i < bytes ; i++) {
+ this->value[i] = value % 256;
+ value = value / 256;
+ }
+ }
+
+ std::string VariableValue::getName(){
+ return name;
+ }
+
+ int VariableValue::getValueLength(){
+ return valueLength;
+ }
+
+ char* VariableValue::getValue(){
+ return value;
+ }
+
+ long VariableValue::getValueAsLong() {
+ long intVal = 0;
+ for(int i = 0 ; i < valueLength ; i++) {
+ intVal += ((unsigned char)value[i]) * myPow(256,i);
+ }
+ return intVal;
+ }
+
+ long VariableValue::myPow(int x, int y) {
+ long r = 1;
+ for(int i = 0 ; i < y ; i++) r *= x;
+ return r;
+ }
+
+ int VariableValue::readName(char *packet, int index) {
+ int read = 0;
+ int nameLength = packet[index];
+ read++;
+ char* namestr=new char[nameLength+1];
+ namestr[nameLength]=0;
+ memcpy(namestr,packet+index+read,nameLength);
+ name = string(namestr);
+ read+=nameLength;
+ return read;
+ }
+
+ int VariableValue::readValue(char *packet, int index, int length,int ignoreZeroAfterLength) {
+ int read = 0;
+ valueLength = length;
+ if(valueLength < 0) {
+ valueLength = (unsigned char)packet[index+read];read++;
+ if(ignoreZeroAfterLength) read++;
+ }
+
+ if(value) delete[] value;
+ value = new char[valueLength];
+ memcpy(value,packet+index+read,valueLength);
+ read+=valueLength;
+
+ return read;
+ }
+
+/*TODO: this cant work, attLength is always 0, needs to be fixed*/
+/* int VariableValue::readFixValue(char *packet, int index, int packetLength, int valueLength) {
+ VariableValue *value = this;
+ int nameLength = packet[index];
+
+ int i = 1;
+ int attLengthLength = 0;
+ int attLength = 0;
+ string name;
+
+ for(; i <= nameLength;i++){
+ name += packet[index+i];
+ }
+ value->setName(name);
+ index += i;
+ index++; //ignore next value
+
+ value->setValueLength(valueLength);
+
+ char *att = new char[attLength];
+ index += i+1;
+ for(i = 0; i < attLength;i++){
+ att[i] = packet[index+i];
+ }
+ index += i;
+ value->setValue(att);
+ return index;
+ }*/
+
+
+ int VariableValue::readVariableValue(char *packet, int index, int packetLength){
+ VariableValue *value = this;
+ int nameLength = packet[index];
+
+ int i = 1;
+ int attLengthLength = 0;
+ int attLength = 0;
+ string name;
+
+ for(; i <= nameLength;i++){
+ name += packet[index+i];
+ }
+ value->setName(name);
+
+ index += i;
+ attLengthLength = packet[index];
+ index++;
+
+ for(i = 0; i < attLengthLength;i++){
+ attLength += (unsigned char)packet[index+i];/*todo: make it work if length is longer than 1 byte*/
+ }
+ value->setValueLength(attLength);
+
+ char *att = new char[attLength];
+ index += i+1;
+ for(i = 0; i < attLength;i++){
+ att[i] = packet[index+i];
+ }
+ value->setValue(att);
+ index += i;
+ return index;
+ }
+
+
+
+
+ int VariableValue::writeName(char *buf, int index) {
+ int len = name.length();
+ buf[index] = len;
+ memcpy(buf+index+1,name.c_str(),len);
+ return len+1;
+ }
+ int VariableValue::writeValue(char *buf, int index) {
+ memcpy(buf+index,value,valueLength);
+ return valueLength;
+ }
+
+};
diff --git a/protocols/Xfire/src/variablevalue.h b/protocols/Xfire/src/variablevalue.h
new file mode 100644
index 0000000000..8282f47cbf
--- /dev/null
+++ b/protocols/Xfire/src/variablevalue.h
@@ -0,0 +1,65 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <string>
+
+#ifndef __VARIABVLEVALUE_H
+#define __VARIABVLEVALUE_H
+
+namespace xfirelib {
+
+class VariableValue {
+ public:
+ VariableValue();
+ ~VariableValue();
+
+ void setName(std::string name);
+ void setValueLength(int valueLength);
+ void setValue( char * value );
+ void setValue( std::string value );
+ void setValue( const char *value, int valueLength );
+ void setValueFromLong( long value, int bytes );
+ std::string getName();
+ int getValueLength();
+ char* getValue();
+
+ int readName(char *packet, int index);
+ int readValue(char *packet, int index, int length = -1, int ignoreZeroAfterLength = 0);
+ int readVariableValue(char *packet, int index, int packetLength);
+ /*TODO: disabled because of a bug in this method*/
+ //int VariableValue::readFixValue(char *packet, int index, int packetLength, int valueLength);
+
+ int writeName(char *buf, int index);
+ int writeValue(char *buf, int index);
+
+ long getValueAsLong();
+ private:
+ long myPow(int x, int y);
+
+ std::string name;
+ char *value;
+ int valueLength;
+};
+
+};
+
+#endif
diff --git a/protocols/Xfire/src/xdebug.h b/protocols/Xfire/src/xdebug.h
new file mode 100644
index 0000000000..ffc17b8095
--- /dev/null
+++ b/protocols/Xfire/src/xdebug.h
@@ -0,0 +1,149 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+
+#ifndef __XDEBUG_H
+#define __XDEBUG_H
+
+#define RESET 0
+
+#define BLACK 0
+#define RED 1
+#define GREEN 2
+#define YELLOW 3
+#define WHITE 7
+#include <stdio.h>
+//#include <pthread.h>
+
+//#define XFIRELIBDEBUG
+
+#ifndef XFIRELIBDEBUG
+
+#define XDEBUGS(args);
+#define XDEBUG(args) ;
+#define XDEBUG2(args,args2) ;
+#define XDEBUG3(args,args2,args3) ;
+#define XDEBUG4(args,args2,args3,args4) ;
+#define XDEBUG5(args,args2,args3,args4,args5) ;
+#define XDEBUG6(args,args2,args3,args4,args5,args6) ;
+#define DUMPPACKET(args) ;
+
+#define XINFO(args) ;
+#define XINFO2(args,args2) ;
+#define XINFO3(args,args2,args3) ;
+
+#define XERROR(args) ;
+#define XERROR2(args,args2) ;
+#define XERROR3(args,args2,args3) ;
+
+/*#define DUMP(args,args2) { FILE* errorfile=fopen("C:\\XFireDump.log","a"); \
+ fprintf(errorfile,args,args2); \
+ fprintf(errorfile,"\n",""); \
+ fclose(errorfile); }\*/
+
+/*#define XFireLog(args,args2) { FILE* errorfile=fopen("C:\\XFireDump.log","a"); \
+ fprintf(errorfile,args,args2); \
+ fprintf(errorfile,"\n",""); \
+ fclose(errorfile); }\*/
+
+/*#define XFireLog(args,args2) { \
+ char temp[266]; \
+ sprintf(temp,args,args2); \
+ MessageBoxA(NULL,temp,temp,0); }\*/
+
+#endif
+
+#ifdef XFIRELIBDEBUG
+
+#define XDEBUGS(args) { FILE* errorfile=fopen("XFire.log","wb"); \
+ fprintf(errorfile,args); \
+ fclose(errorfile); }\
+
+#define DUMPPACKET(args) { FILE* dumpfile=fopen(args,"wb"); \
+ fwrite(buf,length,1,dumpfile); \
+ fclose(dumpfile); }\
+
+
+#define XDEBUG(args) { FILE* errorfile=fopen("XFire.log","a"); \
+ fprintf(errorfile,args); \
+ fclose(errorfile); }\
+
+ #define XDEBUG2(args,args2) { FILE* errorfile=fopen("XFire.log","a"); \
+ fprintf(errorfile,args,args2); \
+ fclose(errorfile); } \
+
+
+ #define XDEBUG3(args,args2,args3) { FILE* errorfile=fopen("XFire.log","a"); \
+ fprintf(errorfile,args,args2,args3); \
+ fclose(errorfile); } \
+
+ #define XDEBUG4(args,args2,args3,args4) { FILE* errorfile=fopen("XFire.log","a"); \
+ fprintf(errorfile,args,args2,args3,args4); \
+ fclose(errorfile); } \
+
+ #define XDEBUG5(args,args2,args3,args4,args5) { FILE* errorfile=fopen("XFire.log","a"); \
+ fprintf(errorfile,args,args2,args3,args4,args5); \
+ fclose(errorfile); } \
+
+ #define XDEBUG6(args,args2,args3,args4,args5,args6) { FILE* errorfile=fopen("XFire.log","a"); \
+ fprintf(errorfile,args,args2,args3,args4,args5,args6); \
+ fclose(errorfile); } \
+
+
+#define XINFO(args) { FILE* errorfile=fopen("XFire.log","a"); \
+ fprintf(errorfile,args); \
+ fclose(errorfile); }\
+
+ #define XINFO2(args,args2) { FILE* errorfile=fopen("XFire.log","a"); \
+ fprintf(errorfile,args,args2); \
+ fclose(errorfile); } \
+
+
+ #define XINFO3(args,args2,args3) { FILE* errorfile=fopen("XFire.log","a"); \
+ fprintf(errorfile,args,args2,args3); \
+ fclose(errorfile); } \
+
+
+#define XERROR(args) { FILE* errorfile=fopen("XFire.log","a"); \
+ fprintf(errorfile,args); \
+ fclose(errorfile); }\
+
+ #define XERROR2(args,args2) { FILE* errorfile=fopen("XFire.log","a"); \
+ fprintf(errorfile,args,args2); \
+ fclose(errorfile); } \
+
+
+ #define XERROR3(args,args2,args3) { FILE* errorfile=fopen("XFire.log","a"); \
+ fprintf(errorfile,args,args2,args3); \
+ fclose(errorfile); } \
+
+
+
+
+
+
+
+
+
+#endif
+#endif \ No newline at end of file
diff --git a/protocols/Xfire/src/xfireclanpacket.cpp b/protocols/Xfire/src/xfireclanpacket.cpp
new file mode 100644
index 0000000000..c26577fae1
--- /dev/null
+++ b/protocols/Xfire/src/xfireclanpacket.cpp
@@ -0,0 +1,79 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "xfireclanpacket.h"
+#include "variablevalue.h"
+#include <string>
+
+namespace xfirelib {
+ using namespace std;
+
+ void XFireClanPacket::parseContent(char *buf, int nlength, int numberOfAtts) {
+ VariableValue val;
+ int index = 0;
+ int length = 0;
+ string stringvalue;
+
+ index += 3; // ersten 5 bytes skippen
+
+ this->count=(char)buf[index];
+
+ index += 2;
+
+ for(int i=0;i<this->count;i++)
+ {
+ index += val.readValue(buf,index,2); //clanid lesen
+ this->clanid[i] = val.getValueAsLong();
+ index += 2;
+ }
+
+ index += 5; // 7 bytes skippen
+
+ for(int i=0;i<this->count;i++)
+ {
+ length = (unsigned char)buf[index++]; //clannamen lesen
+ index++;
+ index += val.readValue(buf,index,length);
+ stringvalue = string(val.getValue(),length);
+
+ this->name[i] = stringvalue;
+ }
+
+ index += 5; // 5 skippen
+
+ for(int i=0;i<this->count;i++)
+ {
+ length = (unsigned char)buf[index++]; //url anhängsel auslesen
+ index++;
+ index += val.readValue(buf,index,length);
+ stringvalue = string(val.getValue(),length);
+
+ this->url[i] = stringvalue;
+ }
+
+ }
+
+};
diff --git a/protocols/Xfire/src/xfireclanpacket.h b/protocols/Xfire/src/xfireclanpacket.h
new file mode 100644
index 0000000000..7e5b1bc843
--- /dev/null
+++ b/protocols/Xfire/src/xfireclanpacket.h
@@ -0,0 +1,63 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __XFIRECLANPACKET_H
+#define __XFIRECLANPACKET_H
+
+#include <string>
+#include "xfirerecvpacketcontent.h"
+
+#define XFIRE_CLAN_PACKET 158
+
+namespace xfirelib {
+ using namespace std;
+
+ /**
+ * beinhaltet, clanid, name und weburl-zusatz
+ *
+ */
+ class XFireClanPacket : public XFireRecvPacketContent {
+ public:
+ XFirePacketContent* newPacket() { return new XFireClanPacket(); }
+
+
+ int getPacketId() { return XFIRE_CLAN_PACKET; }
+ int getPacketContent(char *buf) { return 0;}
+ int getPacketAttributeCount() { return 3; };
+ int getPacketSize() { return 1024; };
+ void parseContent(char *buf, int length, int numberOfAtts);
+
+ string name[10];
+ string url[10];
+ long clanid[10];
+ int count;
+
+ private:
+ };
+
+};
+
+
+#endif
+
diff --git a/protocols/Xfire/src/xfirefoundbuddys.cpp b/protocols/Xfire/src/xfirefoundbuddys.cpp
new file mode 100644
index 0000000000..dacae8f885
--- /dev/null
+++ b/protocols/Xfire/src/xfirefoundbuddys.cpp
@@ -0,0 +1,92 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+#include <vector>
+#include <string>
+
+#include "xfirefoundbuddys.h"
+#include "xfireparse.h"
+#include "variablevalue.h"
+#include "xdebug.h"
+
+namespace xfirelib {
+ using namespace std;
+
+ XFireFoundBuddys::XFireFoundBuddys() {
+ usernames = 0;
+ fname = 0;
+ lname = 0;
+ }
+ XFireFoundBuddys::~XFireFoundBuddys() {
+ delete usernames;
+ delete fname;
+ delete lname;
+ }
+
+ void XFireFoundBuddys::parseContent(char *buf, int length, int numberOfAtts) {
+ int index = 0;
+
+ VariableValue bs;
+
+ XDEBUG2( "Len: %ld\n", length );
+
+ XDEBUG2( "Byte1: %ld\n", (char)buf[index] );
+ XDEBUG2( "Byte2: %ld\n", (char)buf[index+1] );
+ XDEBUG2( "Byte3: %ld\n", (char)buf[index+2] );
+
+ usernames = new vector<string>;
+ index = readStrings(usernames,buf,index);
+
+ fname = new vector<string>;
+ index = readStrings(fname,buf,index);
+
+ lname = new vector<string>;
+ index = readStrings(lname,buf,index);
+
+ }
+
+ int XFireFoundBuddys::readStrings(vector<string> *strings, char *buf, int index) {
+ VariableValue friends;
+ index+=friends.readName(buf,index);
+ index ++; // Ignore 04
+ index ++; // Ignore 01
+
+ index+=friends.readValue(buf,index,2);
+
+ int numberOfStrings = friends.getValueAsLong();
+ XDEBUG3( "name: %s numberOfStrings: %d\n", friends.getName().c_str(), numberOfStrings );
+ for(int i = 0 ; i < numberOfStrings ; i++) {
+ XDEBUG2( "Index: %ld\n", index );
+ int length = (unsigned char)buf[index++];
+ index++;
+ index += friends.readValue(buf,index,length);
+ string stringvalue = string(friends.getValue(),length);
+ strings->push_back(stringvalue);
+ XDEBUG3( "String length: %2d : %s\n", length, stringvalue.c_str() );
+ }
+ return index;
+ }
+
+};
diff --git a/protocols/Xfire/src/xfirefoundbuddys.h b/protocols/Xfire/src/xfirefoundbuddys.h
new file mode 100644
index 0000000000..70d44f201b
--- /dev/null
+++ b/protocols/Xfire/src/xfirefoundbuddys.h
@@ -0,0 +1,65 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+//packet wird empfangen, wenn man eine buddysuche gestartet hat
+
+#ifndef __XFIREFOUNDBUDDYS_H
+#define __XFIREFOUNDBUDDYS_H
+
+#define XFIRE_FOUNDBUDDYS_ID 0x8f
+
+#include <vector>
+#include <string>
+
+#include "xfirerecvpacketcontent.h"
+#include "variablevalue.h"
+
+
+namespace xfirelib {
+ using namespace std;
+
+ class XFireFoundBuddys : public XFireRecvPacketContent {
+ public:
+ XFireFoundBuddys();
+ virtual ~XFireFoundBuddys();
+
+ XFirePacketContent* newPacket() { return new XFireFoundBuddys(); }
+
+ int getPacketId() { return XFIRE_FOUNDBUDDYS_ID; }
+ int getPacketContent(char *buf) { return 0; }
+ int getPacketAttributeCount() { return 0; };
+ int getPacketSize() { return 1024; };
+ void parseContent(char *buf, int length, int numberOfAtts);
+
+ //private:
+ int readStrings(vector<string> *strings, char *buf, int index);
+
+ vector<string> *usernames;
+ vector<string> *fname;
+ vector<string> *lname;
+ };
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/xfiregame.cpp b/protocols/Xfire/src/xfiregame.cpp
new file mode 100644
index 0000000000..e9b0e869bf
--- /dev/null
+++ b/protocols/Xfire/src/xfiregame.cpp
@@ -0,0 +1,27 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "xfiregame.h"
+
+
diff --git a/protocols/Xfire/src/xfiregame.h b/protocols/Xfire/src/xfiregame.h
new file mode 100644
index 0000000000..b8293750ad
--- /dev/null
+++ b/protocols/Xfire/src/xfiregame.h
@@ -0,0 +1,42 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#ifndef __XFIREGAME_H
+#define __XFIREGAME_H
+
+#include <string>
+
+namespace xfirelib {
+
+ class XFireGame {
+ public:
+ virtual ~XFireGame() { }
+ virtual int getGameId() = 0;
+ virtual std::string getGameName() = 0;
+ };
+
+
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/xfiregameresolver.cpp b/protocols/Xfire/src/xfiregameresolver.cpp
new file mode 100644
index 0000000000..af7b67f799
--- /dev/null
+++ b/protocols/Xfire/src/xfiregameresolver.cpp
@@ -0,0 +1,27 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "xfiregameresolver.h"
+
+
diff --git a/protocols/Xfire/src/xfiregameresolver.h b/protocols/Xfire/src/xfiregameresolver.h
new file mode 100644
index 0000000000..1215550009
--- /dev/null
+++ b/protocols/Xfire/src/xfiregameresolver.h
@@ -0,0 +1,52 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __XFIREGAMERESOLVER_H
+#define __XFIREGAMERESOLVER_H
+
+#include "buddylistgamespacket.h"
+#include "xfiregame.h"
+#include <string>
+
+namespace xfirelib {
+ /**
+ * This is a virtual class which users of the library can
+ * subclass so they can use their own gameid <-> XFireGame object
+ * resolver (Implementors might want to consider that their application
+ * also requires backward converting .. from game to gameid since
+ * SendGameStatusPacket requires a gameid.
+ */
+ class XFireGameResolver {
+ public:
+ virtual ~XFireGameResolver() { }
+
+ /**
+ * this method should resolve the gameid
+ * and return a new XFireGame object or NULL if it was not resolvable.
+ * (if more information is needed, it can be taken from packet->xxx[iterator])
+ */
+ virtual XFireGame *resolveGame(int gameid, int iterator, BuddyListGamesPacket *packet) = 0;
+ };
+
+};
+
+#endif
diff --git a/protocols/Xfire/src/xfirepacket.cpp b/protocols/Xfire/src/xfirepacket.cpp
new file mode 100644
index 0000000000..955881863f
--- /dev/null
+++ b/protocols/Xfire/src/xfirepacket.cpp
@@ -0,0 +1,145 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include <iostream>
+#include <stdlib.h>
+#include <string.h>
+#include "xfirepacket.h"
+
+#include "xdebug.h"
+
+#include "socketexception.h"
+
+namespace xfirelib {
+ using namespace std;
+
+ XFirePacket::XFirePacket(PacketReader *reader) {
+ this->reader = reader;
+ this->content = NULL;
+ }
+ XFirePacket::XFirePacket(XFirePacketContent *content) {
+ this->content = content;
+ this->reader = NULL;
+ }
+
+ XFirePacket::~XFirePacket() {
+ }
+
+
+ void XFirePacket::recvPacket(Socket *socket) {
+ char buf[5];
+ //char temp[255];
+ int nlen=0;
+ //FILE* f2;
+
+ if(socket==NULL) return;
+
+ int r = socket->recv( buf, 5 );
+ int missingbytes=5-r;
+ if(missingbytes != 0) {
+ XERROR3("Returned only %d bytes try last %d bytes again ?!: \n",r,missingbytes);
+ r+= socket->recv( &buf[r], missingbytes );
+ }
+ if(r != 5) {
+ XERROR2("Returned less than 5 ?!: %d\n",r);
+ throw SocketException("Connection Closed ?");
+ }
+ XDEBUG2("Read %d bytes ...\n", r );
+ unsigned int len = ((unsigned char)buf[0]) + (((unsigned char)buf[1]) * 256);
+
+ int packetid = buf[2];
+ int numberOfAtts = (unsigned char)buf[4];
+
+ char* contentbuf=new char[len-5];
+ XDEBUG2("calling socket->recv(contentbuf,%d)\n",len-5);
+ int r2 = socket->recv( contentbuf, len-5 );
+
+
+ char* ncontentbuf=contentbuf+r2;
+ int nsize=len-5-r2;
+ int dummyi=0;
+ //packet solang auslesen, bis fertig - dufte
+ while(nsize>0)
+ {
+ dummyi++;
+ XDEBUG2("nsize: %d\n", nsize);
+ r2=socket->recv( ncontentbuf, nsize );
+ ncontentbuf=ncontentbuf+r2;
+ nsize-=r2;
+ XDEBUG5("packetid: %d numberOfAtts: %d length: %d Got: %d\n", (unsigned char)packetid,numberOfAtts,len-5,len-5-nsize);
+ }
+
+ XDEBUG5("packetid: %d numberOfAtts: %d length: %d Got: %d\n", (unsigned char)packetid,numberOfAtts,len-5,r2);
+
+ if(r2 < 1) return;
+
+ /*if((unsigned char)packetid==131)
+ {
+ sprintf(temp,"packet%d_%d.dmp",(unsigned char)packetid,rand());
+ f2=fopen(temp,"wb");
+ fwrite(contentbuf,1,len-5,f2);
+ fclose(f2);
+ }*/
+
+ XFirePacketContent *contentClass = reader->getPacketContentClass( (unsigned char)packetid );
+
+ //sprintf(temp,"packet%d.dmp",(unsigned char)packetid);
+
+ if(contentClass == NULL) {
+ /*sprintf(temp,"packet%d.dmp",(unsigned char)packetid);
+ f2=fopen(temp,"wb");
+ fwrite(contentbuf,1,len-5,f2);
+ fclose(f2);*/
+ XERROR2("NO SUCH CONTENT PACKET (%d) :(\n", (unsigned char)packetid);
+ return;
+ }
+ XDEBUG(("Creating ContentClass Instance\n"));
+ content = contentClass->newPacket();
+
+ XDEBUG(("Parse Content\n"));
+ //statt r2 wird jetzt die komplette länge des packets genommen, also len-5 dufte
+ content->parseContent(contentbuf, len-5, numberOfAtts);
+ }
+
+ void XFirePacket::sendPacket(Socket *socket) {
+ int size = content->getPacketSize();
+ char *buf = (char*)malloc(size * sizeof(char));
+ XDEBUG3("Allocated %d characters (%d)\n", size, sizeof(char));
+ int rsize = content->getPacketContent( buf );
+ XDEBUG2("Real Size: %d\n", rsize);
+ int realsize = rsize + 5;
+ char *sendbuf = (char*)malloc(realsize * sizeof(char));
+ sendbuf[0] = realsize % 256;
+ sendbuf[1] = (int)realsize / 256;
+ sendbuf[2] = content->getPacketId();
+ XDEBUG2("Send Content Id: %d\n", content->getPacketId());
+ sendbuf[3] = 0;
+ sendbuf[4] = content->getPacketAttributeCount();
+ memcpy( sendbuf + 5, buf, rsize );
+
+ socket->send( sendbuf, realsize );
+
+ free(buf); free(sendbuf);
+ }
+};
diff --git a/protocols/Xfire/src/xfirepacket.h b/protocols/Xfire/src/xfirepacket.h
new file mode 100644
index 0000000000..c7b938e2f9
--- /dev/null
+++ b/protocols/Xfire/src/xfirepacket.h
@@ -0,0 +1,53 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __XFIREPACKET_H
+#define __XFIREPACKET_H
+
+#include "packetreader.h"
+#include "xfirepacketcontent.h"
+
+namespace xfirelib {
+ struct PacketReader;
+ struct XFirePacketContent;
+
+ class XFirePacket {
+ public:
+ XFirePacket(PacketReader *reader);
+ XFirePacket(XFirePacketContent *content);
+ ~XFirePacket();
+
+ int getSendBuffer(void *buf);
+ void recvPacket(Socket *socket);
+ void sendPacket(Socket *socket);
+ void sendPacket2(Socket *socket);
+
+ XFirePacketContent *getContent() { return content; }
+ private:
+ PacketReader *reader;
+
+ XFirePacketContent *content;
+ };
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/xfirepacketcontent.cpp b/protocols/Xfire/src/xfirepacketcontent.cpp
new file mode 100644
index 0000000000..87a7778357
--- /dev/null
+++ b/protocols/Xfire/src/xfirepacketcontent.cpp
@@ -0,0 +1,30 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "stdafx.h"
+
+#include "xfirepacketcontent.h"
+
+namespace xfirelib {
+ XFirePacketContent::XFirePacketContent() : MonitoredObj( ) {
+ }
+
+};
diff --git a/protocols/Xfire/src/xfirepacketcontent.h b/protocols/Xfire/src/xfirepacketcontent.h
new file mode 100644
index 0000000000..abb894f5fc
--- /dev/null
+++ b/protocols/Xfire/src/xfirepacketcontent.h
@@ -0,0 +1,47 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __XFIREPACKETCONTENT_H
+#define __XFIREPACKETCONTENT_H
+
+#include "monitoredobj.h"
+
+namespace xfirelib {
+ struct Client;
+
+ class XFirePacketContent : public MonitoredObj {
+ public:
+ XFirePacketContent();
+ virtual ~XFirePacketContent() { }
+ virtual XFirePacketContent* newPacket() = 0;
+
+ virtual int getPacketContent(char *buf) = 0;
+ virtual int getPacketId() = 0;
+ virtual int getPacketAttributeCount() = 0;
+ virtual int getPacketSize() = 0;
+ virtual void parseContent(char *buf, int length, int numberOfAtts) = 0;
+ };
+
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/xfireparse.cpp b/protocols/Xfire/src/xfireparse.cpp
new file mode 100644
index 0000000000..e286e14df0
--- /dev/null
+++ b/protocols/Xfire/src/xfireparse.cpp
@@ -0,0 +1,49 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "xfireparse.h"
+namespace xfirelib {
+
+using namespace std;
+
+XFireParse::XFireParse() {
+}
+
+
+/*void XFireParse::readVariableAttribut( char *value, char *packet, char *attr,int packet_length,int attr_length, int start,int max_length ) {
+int length_index = findString2(packet,attr, packet_length,strlen(attr),start)+attr_length+1;
+
+ unsigned int length = xfire_hex_to_intC(packet[length_index]);
+
+ if(max_length >= length){
+ memcpy(value,packet+length_index+2,length);
+ }
+ if(max_length > length){
+ memset(value+length,0,1);
+ }
+ return length_index+2+length;
+}*/
+
+
+};
diff --git a/protocols/Xfire/src/xfireparse.h b/protocols/Xfire/src/xfireparse.h
new file mode 100644
index 0000000000..e03e814a6e
--- /dev/null
+++ b/protocols/Xfire/src/xfireparse.h
@@ -0,0 +1,37 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+
+#ifndef __XFIREPARSE_H
+#define __XFIREPARSE_H
+#include "variablevalue.h"
+namespace xfirelib {
+
+class XFireParse {
+ public:
+ XFireParse();
+};
+
+};
+
+#endif
diff --git a/protocols/Xfire/src/xfireprefpacket.cpp b/protocols/Xfire/src/xfireprefpacket.cpp
new file mode 100644
index 0000000000..6afc613fed
--- /dev/null
+++ b/protocols/Xfire/src/xfireprefpacket.cpp
@@ -0,0 +1,50 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+#include "xfireprefpacket.h"
+#include <string.h>
+#include <iostream>
+
+namespace xfirelib {
+ using namespace std;
+
+ int XFirePrefPacket::getPacketContent(char *packet) {
+ int index = 0;
+
+ VariableValue val;
+ val.setName( "prefs" );
+ index += val.writeName( packet, index );
+ packet[index++] = 0x09;
+ packet[index++] = 0x00;
+
+ length = index;
+ return index;
+ }
+
+ int XFirePrefPacket::getPacketAttributeCount() {
+ return 1;
+ }
+
+}
diff --git a/protocols/Xfire/src/xfireprefpacket.h b/protocols/Xfire/src/xfireprefpacket.h
new file mode 100644
index 0000000000..f4e1709357
--- /dev/null
+++ b/protocols/Xfire/src/xfireprefpacket.h
@@ -0,0 +1,52 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * dufte <dufte@justmail.de>
+ *
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+//prefrencespacket, steuert wohl die persönlichen einstellungen
+
+#ifndef __XFIREPREFPACKET_H
+#define __XFIREPREFPACKET_H
+
+#include "xfiresendpacketcontent.h"
+#include "variablevalue.h"
+
+#include <string>
+
+namespace xfirelib {
+
+ class XFirePrefPacket : public XFireSendPacketContent {
+ public:
+ XFirePacketContent* newPacket() { return new XFirePrefPacket(); }
+
+ int getPacketId() { return 10; }
+ int getPacketContent(char *buf);
+ int getPacketAttributeCount();
+ int getPacketSize() { return 1000; };
+ void parseContent(char *buf, int length, int numberOfAtts) { };
+ private:
+ int length;
+ };
+
+};
+
+#endif
diff --git a/protocols/Xfire/src/xfirerecvpacketcontent.cpp b/protocols/Xfire/src/xfirerecvpacketcontent.cpp
new file mode 100644
index 0000000000..5abc70aa6b
--- /dev/null
+++ b/protocols/Xfire/src/xfirerecvpacketcontent.cpp
@@ -0,0 +1,26 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "xfirerecvpacketcontent.h"
+
diff --git a/protocols/Xfire/src/xfirerecvpacketcontent.h b/protocols/Xfire/src/xfirerecvpacketcontent.h
new file mode 100644
index 0000000000..2ca2aca424
--- /dev/null
+++ b/protocols/Xfire/src/xfirerecvpacketcontent.h
@@ -0,0 +1,45 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#ifndef __XFIRERECVPACKETCONTENT_H
+#define __XFIRERECVPACKETCONTENT_H
+
+#include "xfirepacketcontent.h"
+
+namespace xfirelib {
+
+ class XFireRecvPacketContent : public XFirePacketContent {
+ public:
+ XFireRecvPacketContent() : XFirePacketContent() { }
+ virtual ~XFireRecvPacketContent() { }
+
+ int getPacketContent(char *buf) { return 0; }
+ int getPacketAttributeCount() { return 0; }
+ int getPacketSize() { return 0; }
+ };
+
+};
+
+
+#endif
+
diff --git a/protocols/Xfire/src/xfiresendpacketcontent.cpp b/protocols/Xfire/src/xfiresendpacketcontent.cpp
new file mode 100644
index 0000000000..b743092973
--- /dev/null
+++ b/protocols/Xfire/src/xfiresendpacketcontent.cpp
@@ -0,0 +1,27 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "xfiresendpacketcontent.h"
+
+
diff --git a/protocols/Xfire/src/xfiresendpacketcontent.h b/protocols/Xfire/src/xfiresendpacketcontent.h
new file mode 100644
index 0000000000..7ce106d295
--- /dev/null
+++ b/protocols/Xfire/src/xfiresendpacketcontent.h
@@ -0,0 +1,43 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __XFIRESENDPACKETCONTENT_H
+#define __XFIRESENDPACKETCONTENT_H
+
+#include "xfirepacketcontent.h"
+
+namespace xfirelib {
+
+ class XFireSendPacketContent : public XFirePacketContent {
+ public:
+ /**
+ * This method is not needed for outgoing packets.. since this method is only
+ * used for parsing .. so return null
+ */
+ XFirePacketContent *newPacket() { return 0; }
+ void parseContent(char *buf, int length, int numberOfAtts) { }
+ };
+
+};
+
+
+#endif
diff --git a/protocols/Xfire/src/xfireutils.cpp b/protocols/Xfire/src/xfireutils.cpp
new file mode 100644
index 0000000000..5df7ba314b
--- /dev/null
+++ b/protocols/Xfire/src/xfireutils.cpp
@@ -0,0 +1,44 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "stdafx.h"
+
+#include "xdebug.h"
+#include <string.h>
+#include <iostream>
+#include "xfireutils.h"
+
+
+namespace xfirelib {
+
+using namespace std;
+
+ XFireUtils::XFireUtils() {
+ }
+
+ int XFireUtils::addAttributName(char *packet,int packet_length, char *att){
+ XDEBUG3( "Adding %d chars at position %d\n",strlen(att),packet_length);
+ packet[packet_length] = (char)strlen(att);//set att length
+ memcpy(packet+packet_length+1,att,strlen(att)); //set attname
+ return packet_length+1+strlen(att);
+ }
+};
diff --git a/protocols/Xfire/src/xfireutils.h b/protocols/Xfire/src/xfireutils.h
new file mode 100644
index 0000000000..a149b27a63
--- /dev/null
+++ b/protocols/Xfire/src/xfireutils.h
@@ -0,0 +1,40 @@
+/*
+ * xfirelib - C++ Library for the xfire protocol.
+ * Copyright (C) 2006 by
+ * Beat Wolf <asraniel@fryx.ch> / http://gfire.sf.net
+ * Herbert Poul <herbert.poul@gmail.com> / http://goim.us
+ * http://xfirelib.sphene.net
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#ifndef __XFIREUTILS_H
+#define __XFIREUTILS_H
+
+namespace xfirelib {
+
+class XFireUtils {
+ public:
+ XFireUtils();
+ /**
+ *Adds the name of a attribute with its length to the packet
+ */
+ static int addAttributName(char *packet,int packet_length, char *att);
+};
+
+};
+
+#endif
diff --git a/protocols/Xfire/xfire.vcxproj b/protocols/Xfire/xfire.vcxproj
new file mode 100644
index 0000000000..473b44fb20
--- /dev/null
+++ b/protocols/Xfire/xfire.vcxproj
@@ -0,0 +1,280 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>xfire</ProjectName>
+ <ProjectGuid>{E4CD8BBA-B580-4584-AC3E-B4E9915026AE}</ProjectGuid>
+ <RootNamespace>xFire</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>NotSet</CharacterSet>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>NotSet</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</GenerateManifest>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <AdditionalOptions>-D_SCL_SECURE_NO_WARNINGS %(AdditionalOptions)</AdditionalOptions>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;PTW32_STATIC_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ <AdditionalIncludeDirectories>../../include;../../plugins/ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>kernel32.lib</AdditionalDependencies>
+ <OutputFile>$(OutDir)XFire.dll</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineX86</TargetMachine>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib;..\..\bin10\lib</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <AdditionalOptions>-D_SCL_SECURE_NO_WARNINGS %(AdditionalOptions)</AdditionalOptions>
+ <Optimization>Full</Optimization>
+ <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;PTW32_STATIC_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <BufferSecurityCheck>true</BufferSecurityCheck>
+ <FloatingPointModel>Fast</FloatingPointModel>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ <ErrorReporting>None</ErrorReporting>
+ <AdditionalIncludeDirectories>../../include;../../plugins/ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>kernel32.lib</AdditionalDependencies>
+ <OutputFile>$(OutDir)XFire.dll</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <GenerateMapFile>true</GenerateMapFile>
+ <MapExports>true</MapExports>
+ <SubSystem>Windows</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <BaseAddress>
+ </BaseAddress>
+ <ImportLibrary>$(TargetDir)$XFire.lib</ImportLibrary>
+ <TargetMachine>MachineX86</TargetMachine>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib;..\..\bin10\lib</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\resource.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="src\Xfire_avatar_loader.cpp" />
+ <ClCompile Include="src\Xfire_base.cpp" />
+ <ClCompile Include="src\Xfire_game.cpp" />
+ <ClCompile Include="src\Xfire_gamelist.cpp" />
+ <ClCompile Include="src\Xfire_icon_mng.cpp" />
+ <ClCompile Include="src\Xfire_voicechat.cpp" />
+ <ClCompile Include="src\addgamedialog.cpp" />
+ <ClCompile Include="src\all_statusmsg.cpp" />
+ <ClCompile Include="src\iniupdater.cpp" />
+ <ClCompile Include="src\main.cpp" />
+ <ClCompile Include="src\options.cpp" />
+ <ClCompile Include="src\passworddialog.cpp" />
+ <ClCompile Include="src\processbuddyinfo.cpp" />
+ <ClCompile Include="src\pwd_dlg.cpp" />
+ <ClCompile Include="src\searching4games.cpp" />
+ <ClCompile Include="src\services.cpp" />
+ <ClCompile Include="src\setnickname.cpp" />
+ <ClCompile Include="src\tools.cpp" />
+ <ClCompile Include="src\userdetails.cpp" />
+ <ClCompile Include="src\variables.cpp" />
+ <ClCompile Include="src\Xfire_proxy.cpp" />
+ <ClCompile Include="src\authpacket.cpp" />
+ <ClCompile Include="src\buddyinfo.cpp" />
+ <ClCompile Include="src\buddylist.cpp" />
+ <ClCompile Include="src\buddylistgames2packet.cpp" />
+ <ClCompile Include="src\buddylistgamespacket.cpp" />
+ <ClCompile Include="src\buddylistnamespacket.cpp" />
+ <ClCompile Include="src\buddylistonlinepacket.cpp" />
+ <ClCompile Include="src\clanbuddylistnamespacket.cpp" />
+ <ClCompile Include="src\claninvitationpacket.cpp" />
+ <ClCompile Include="src\client.cpp" />
+ <ClCompile Include="src\clientinformationpacket.cpp" />
+ <ClCompile Include="src\clientloginpacket.cpp" />
+ <ClCompile Include="src\clientversionpacket.cpp" />
+ <ClCompile Include="src\dummyxfiregameresolver.cpp" />
+ <ClCompile Include="src\friendsoffriendlist.cpp" />
+ <ClCompile Include="src\gameinfopacket.cpp" />
+ <ClCompile Include="src\getbuddyinfo.cpp" />
+ <ClCompile Include="src\invitebuddypacket.cpp" />
+ <ClCompile Include="src\inviterequestpacket.cpp" />
+ <ClCompile Include="src\loginfailedpacket.cpp" />
+ <ClCompile Include="src\loginsuccesspacket.cpp" />
+ <ClCompile Include="src\messageackpacket.cpp" />
+ <ClCompile Include="src\messagepacket.cpp" />
+ <ClCompile Include="src\monitoredobj.cpp" />
+ <ClCompile Include="src\otherloginpacket.cpp" />
+ <ClCompile Include="src\packetreader.cpp" />
+ <ClCompile Include="src\recvbuddychangednick.cpp" />
+ <ClCompile Include="src\recvdidpacket.cpp" />
+ <ClCompile Include="src\recvoldversionpacket.cpp" />
+ <ClCompile Include="src\recvprefspacket.cpp" />
+ <ClCompile Include="src\recvremovebuddypacket.cpp" />
+ <ClCompile Include="src\recvstatusmessagepacket.cpp" />
+ <ClCompile Include="src\searchbuddy.cpp" />
+ <ClCompile Include="src\sendacceptinvitationpacket.cpp" />
+ <ClCompile Include="src\senddenyinvitationpacket.cpp" />
+ <ClCompile Include="src\sendgameserverpacket.cpp" />
+ <ClCompile Include="src\sendgamestatus2packet.cpp" />
+ <ClCompile Include="src\sendgamestatuspacket.cpp" />
+ <ClCompile Include="src\sendkeepalivepacket.cpp" />
+ <ClCompile Include="src\sendmessagepacket.cpp" />
+ <ClCompile Include="src\sendnickchangepacket.cpp" />
+ <ClCompile Include="src\sendremovebuddypacket.cpp" />
+ <ClCompile Include="src\sendsidpacket.cpp" />
+ <ClCompile Include="src\sendstatusmessagepacket.cpp" />
+ <ClCompile Include="src\sendtypingpacket.cpp" />
+ <ClCompile Include="src\SHA1.cpp" />
+ <ClCompile Include="src\socket.cpp" />
+ <ClCompile Include="src\stdafx.cpp">
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
+ </ClCompile>
+ <ClCompile Include="src\variablevalue.cpp" />
+ <ClCompile Include="src\xfireclanpacket.cpp" />
+ <ClCompile Include="src\xfirefoundbuddys.cpp" />
+ <ClCompile Include="src\xfiregame.cpp" />
+ <ClCompile Include="src\xfiregameresolver.cpp" />
+ <ClCompile Include="src\xfirepacket.cpp" />
+ <ClCompile Include="src\xfirepacketcontent.cpp" />
+ <ClCompile Include="src\xfireparse.cpp" />
+ <ClCompile Include="src\xfireprefpacket.cpp" />
+ <ClCompile Include="src\xfirerecvpacketcontent.cpp" />
+ <ClCompile Include="src\xfiresendpacketcontent.cpp" />
+ <ClCompile Include="src\xfireutils.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="src\Xfire_avatar_loader.h" />
+ <ClInclude Include="src\Xfire_base.h" />
+ <ClInclude Include="src\Xfire_game.h" />
+ <ClInclude Include="src\Xfire_gamelist.h" />
+ <ClInclude Include="src\Xfire_icon_mng.h" />
+ <ClInclude Include="src\Xfire_voicechat.h" />
+ <ClInclude Include="src\addgamedialog.h" />
+ <ClInclude Include="src\all_statusmsg.h" />
+ <ClInclude Include="src\baseProtocol.h" />
+ <ClInclude Include="src\iniupdater.h" />
+ <ClInclude Include="src\passworddialog.h" />
+ <ClInclude Include="src\processbuddyinfo.h" />
+ <ClInclude Include="src\pwd_dlg.h" />
+ <ClInclude Include="src\resource.h" />
+ <ClInclude Include="src\services.h" />
+ <ClInclude Include="src\setnickname.h" />
+ <ClInclude Include="src\stdafx.h" />
+ <ClInclude Include="src\tools.h" />
+ <ClInclude Include="src\variables.h" />
+ <ClInclude Include="src\m8.h" />
+ <ClInclude Include="src\Xfire_proxy.h" />
+ <ClInclude Include="src\authpacket.h" />
+ <ClInclude Include="src\buddyinfo.h" />
+ <ClInclude Include="src\buddylist.h" />
+ <ClInclude Include="src\buddylistgames2packet.h" />
+ <ClInclude Include="src\buddylistgamespacket.h" />
+ <ClInclude Include="src\buddylistnamespacket.h" />
+ <ClInclude Include="src\buddylistonlinepacket.h" />
+ <ClInclude Include="src\clanbuddylistnamespacket.h" />
+ <ClInclude Include="src\claninvitationpacket.h" />
+ <ClInclude Include="src\client.h" />
+ <ClInclude Include="src\clientinformationpacket.h" />
+ <ClInclude Include="src\clientloginpacket.h" />
+ <ClInclude Include="src\clientversionpacket.h" />
+ <ClInclude Include="src\dummyxfiregameresolver.h" />
+ <ClInclude Include="src\friendsoffriendlist.h" />
+ <ClInclude Include="src\gameinfopacket.h" />
+ <ClInclude Include="src\getbuddyinfo.h" />
+ <ClInclude Include="src\invitebuddypacket.h" />
+ <ClInclude Include="src\inviterequestpacket.h" />
+ <ClInclude Include="src\loginfailedpacket.h" />
+ <ClInclude Include="src\loginsuccesspacket.h" />
+ <ClInclude Include="src\messageackpacket.h" />
+ <ClInclude Include="src\messagepacket.h" />
+ <ClInclude Include="src\monitoredobj.h" />
+ <ClInclude Include="src\otherloginpacket.h" />
+ <ClInclude Include="src\packetlistener.h" />
+ <ClInclude Include="src\packetreader.h" />
+ <ClInclude Include="src\recvbuddychangednick.h" />
+ <ClInclude Include="src\recvdidpacket.h" />
+ <ClInclude Include="src\recvoldversionpacket.h" />
+ <ClInclude Include="src\recvprefspacket.h" />
+ <ClInclude Include="src\recvremovebuddypacket.h" />
+ <ClInclude Include="src\recvstatusmessagepacket.h" />
+ <ClInclude Include="src\searchbuddy.h" />
+ <ClInclude Include="src\sendacceptinvitationpacket.h" />
+ <ClInclude Include="src\senddenyinvitationpacket.h" />
+ <ClInclude Include="src\sendgameserverpacket.h" />
+ <ClInclude Include="src\sendgamestatus2packet.h" />
+ <ClInclude Include="src\sendgamestatuspacket.h" />
+ <ClInclude Include="src\sendkeepalivepacket.h" />
+ <ClInclude Include="src\sendmessagepacket.h" />
+ <ClInclude Include="src\sendnickchangepacket.h" />
+ <ClInclude Include="src\sendremovebuddypacket.h" />
+ <ClInclude Include="src\sendsidpacket.h" />
+ <ClInclude Include="src\sendstatusmessagepacket.h" />
+ <ClInclude Include="src\sendtypingpacket.h" />
+ <ClInclude Include="src\SHA1.h" />
+ <ClInclude Include="src\socket.h" />
+ <ClInclude Include="src\socketexception.h" />
+ <ClInclude Include="src\variablevalue.h" />
+ <ClInclude Include="src\xdebug.h" />
+ <ClInclude Include="src\xfireclanpacket.h" />
+ <ClInclude Include="src\xfirefoundbuddys.h" />
+ <ClInclude Include="src\xfiregame.h" />
+ <ClInclude Include="src\xfiregameresolver.h" />
+ <ClInclude Include="src\xfirepacket.h" />
+ <ClInclude Include="src\xfirepacketcontent.h" />
+ <ClInclude Include="src\xfireparse.h" />
+ <ClInclude Include="src\xfireprefpacket.h" />
+ <ClInclude Include="src\xfirerecvpacketcontent.h" />
+ <ClInclude Include="src\xfiresendpacketcontent.h" />
+ <ClInclude Include="src\xfireutils.h" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/protocols/Xfire/xfire.vcxproj.filters b/protocols/Xfire/xfire.vcxproj.filters
new file mode 100644
index 0000000000..1acfc098e7
--- /dev/null
+++ b/protocols/Xfire/xfire.vcxproj.filters
@@ -0,0 +1,548 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Miranda Plugin">
+ <UniqueIdentifier>{429b4466-b5e0-4103-b9a3-79d9329ed56b}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Miranda Plugin\Xfire_class">
+ <UniqueIdentifier>{410d3a2b-b464-427e-bae6-6b53052ce281}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Miranda Plugin\Xfire_class\source">
+ <UniqueIdentifier>{85b62d89-d9b7-48e6-ad47-b69e16fad26e}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Miranda Plugin\Xfire_class\headers">
+ <UniqueIdentifier>{e5faded7-3c56-4a55-8376-ff856dcdf14a}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Miranda Plugin\plugin">
+ <UniqueIdentifier>{faa98de2-0992-4e8f-9619-339ddf7d63a8}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Miranda Plugin\plugin\sources">
+ <UniqueIdentifier>{ed3814dc-25c9-4508-8f49-6151c76a3a17}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Miranda Plugin\plugin\headers">
+ <UniqueIdentifier>{7f2aaa40-a5ee-4710-8c18-d5d8fb6393ec}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Miranda Plugin\m8">
+ <UniqueIdentifier>{ab6c436e-ae19-4c55-a704-c5d3289d4741}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Miranda Plugin\proxy">
+ <UniqueIdentifier>{1b5978a1-4944-4647-9e92-11cb4662302e}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="XFirelib">
+ <UniqueIdentifier>{beadf7dd-8c9c-4b89-a764-5eb6fc0190f7}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="XFirelib\sources">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="XFirelib\headers">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resources">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="src\Xfire_avatar_loader.cpp">
+ <Filter>Miranda Plugin\Xfire_class\source</Filter>
+ </ClCompile>
+ <ClCompile Include="src\Xfire_base.cpp">
+ <Filter>Miranda Plugin\Xfire_class\source</Filter>
+ </ClCompile>
+ <ClCompile Include="src\Xfire_game.cpp">
+ <Filter>Miranda Plugin\Xfire_class\source</Filter>
+ </ClCompile>
+ <ClCompile Include="src\Xfire_gamelist.cpp">
+ <Filter>Miranda Plugin\Xfire_class\source</Filter>
+ </ClCompile>
+ <ClCompile Include="src\Xfire_icon_mng.cpp">
+ <Filter>Miranda Plugin\Xfire_class\source</Filter>
+ </ClCompile>
+ <ClCompile Include="src\Xfire_voicechat.cpp">
+ <Filter>Miranda Plugin\Xfire_class\source</Filter>
+ </ClCompile>
+ <ClCompile Include="src\addgamedialog.cpp">
+ <Filter>Miranda Plugin\plugin\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\all_statusmsg.cpp">
+ <Filter>Miranda Plugin\plugin\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\iniupdater.cpp">
+ <Filter>Miranda Plugin\plugin\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\main.cpp">
+ <Filter>Miranda Plugin\plugin\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\options.cpp">
+ <Filter>Miranda Plugin\plugin\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\passworddialog.cpp">
+ <Filter>Miranda Plugin\plugin\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\processbuddyinfo.cpp">
+ <Filter>Miranda Plugin\plugin\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\pwd_dlg.cpp">
+ <Filter>Miranda Plugin\plugin\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\searching4games.cpp">
+ <Filter>Miranda Plugin\plugin\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\services.cpp">
+ <Filter>Miranda Plugin\plugin\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\setnickname.cpp">
+ <Filter>Miranda Plugin\plugin\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\tools.cpp">
+ <Filter>Miranda Plugin\plugin\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\userdetails.cpp">
+ <Filter>Miranda Plugin\plugin\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\variables.cpp">
+ <Filter>Miranda Plugin\plugin\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\Xfire_proxy.cpp">
+ <Filter>Miranda Plugin\proxy</Filter>
+ </ClCompile>
+ <ClCompile Include="src\authpacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\buddyinfo.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\buddylist.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\buddylistgames2packet.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\buddylistgamespacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\buddylistnamespacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\buddylistonlinepacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\clanbuddylistnamespacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\claninvitationpacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\client.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\clientinformationpacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\clientloginpacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\clientversionpacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\dummyxfiregameresolver.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\friendsoffriendlist.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\gameinfopacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\getbuddyinfo.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\invitebuddypacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\inviterequestpacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\loginfailedpacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\loginsuccesspacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\messageackpacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\messagepacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\monitoredobj.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\otherloginpacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\packetreader.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\recvbuddychangednick.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\recvdidpacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\recvoldversionpacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\recvprefspacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\recvremovebuddypacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\recvstatusmessagepacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\searchbuddy.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\sendacceptinvitationpacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\senddenyinvitationpacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\sendgameserverpacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\sendgamestatus2packet.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\sendgamestatuspacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\sendkeepalivepacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\sendmessagepacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\sendnickchangepacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\sendremovebuddypacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\sendsidpacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\sendstatusmessagepacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\sendtypingpacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\SHA1.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\socket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\stdafx.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\variablevalue.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\xfireclanpacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\xfirefoundbuddys.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\xfiregame.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\xfiregameresolver.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\xfirepacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\xfirepacketcontent.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\xfireparse.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\xfireprefpacket.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\xfirerecvpacketcontent.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\xfiresendpacketcontent.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ <ClCompile Include="src\xfireutils.cpp">
+ <Filter>XFirelib\sources</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="src\Xfire_avatar_loader.h">
+ <Filter>Miranda Plugin\Xfire_class\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\Xfire_base.h">
+ <Filter>Miranda Plugin\Xfire_class\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\Xfire_game.h">
+ <Filter>Miranda Plugin\Xfire_class\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\Xfire_gamelist.h">
+ <Filter>Miranda Plugin\Xfire_class\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\Xfire_icon_mng.h">
+ <Filter>Miranda Plugin\Xfire_class\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\Xfire_voicechat.h">
+ <Filter>Miranda Plugin\Xfire_class\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\addgamedialog.h">
+ <Filter>Miranda Plugin\plugin\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\all_statusmsg.h">
+ <Filter>Miranda Plugin\plugin\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\baseProtocol.h">
+ <Filter>Miranda Plugin\plugin\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\iniupdater.h">
+ <Filter>Miranda Plugin\plugin\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\passworddialog.h">
+ <Filter>Miranda Plugin\plugin\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\processbuddyinfo.h">
+ <Filter>Miranda Plugin\plugin\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\pwd_dlg.h">
+ <Filter>Miranda Plugin\plugin\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\resource.h">
+ <Filter>Miranda Plugin\plugin\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\services.h">
+ <Filter>Miranda Plugin\plugin\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\setnickname.h">
+ <Filter>Miranda Plugin\plugin\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\stdafx.h">
+ <Filter>Miranda Plugin\plugin\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\tools.h">
+ <Filter>Miranda Plugin\plugin\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\variables.h">
+ <Filter>Miranda Plugin\plugin\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\m8.h">
+ <Filter>Miranda Plugin\m8</Filter>
+ </ClInclude>
+ <ClInclude Include="src\Xfire_proxy.h">
+ <Filter>Miranda Plugin\proxy</Filter>
+ </ClInclude>
+ <ClInclude Include="src\authpacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\buddyinfo.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\buddylist.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\buddylistgames2packet.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\buddylistgamespacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\buddylistnamespacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\buddylistonlinepacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\clanbuddylistnamespacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\claninvitationpacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\client.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\clientinformationpacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\clientloginpacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\clientversionpacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\dummyxfiregameresolver.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\friendsoffriendlist.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\gameinfopacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\getbuddyinfo.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\invitebuddypacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\inviterequestpacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\loginfailedpacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\loginsuccesspacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\messageackpacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\messagepacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\monitoredobj.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\otherloginpacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\packetlistener.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\packetreader.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\recvbuddychangednick.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\recvdidpacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\recvoldversionpacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\recvprefspacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\recvremovebuddypacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\recvstatusmessagepacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\searchbuddy.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\sendacceptinvitationpacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\senddenyinvitationpacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\sendgameserverpacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\sendgamestatus2packet.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\sendgamestatuspacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\sendkeepalivepacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\sendmessagepacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\sendnickchangepacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\sendremovebuddypacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\sendsidpacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\sendstatusmessagepacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\sendtypingpacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\SHA1.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\socket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\socketexception.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\variablevalue.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\xdebug.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\xfireclanpacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\xfirefoundbuddys.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\xfiregame.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\xfiregameresolver.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\xfirepacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\xfirepacketcontent.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\xfireparse.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\xfireprefpacket.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\xfirerecvpacketcontent.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\xfiresendpacketcontent.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ <ClInclude Include="src\xfireutils.h">
+ <Filter>XFirelib\headers</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\resource.rc">
+ <Filter>Resources</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file