diff --git a/de.fu_berlin.inf.dpp/.classpath b/de.fu_berlin.inf.dpp/.classpath deleted file mode 100644 index 74d61819ff443436ce8e83a48782d2dee5fe8195..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/.classpath +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/> - <classpathentry kind="lib" path="lib/smack.jar" sourcepath="/Smack3Jingle/src"/> - <classpathentry kind="lib" path="lib/smackx.jar" sourcepath="C:/Development/smack/source"/> - <classpathentry kind="lib" path="lib/smackx-debug.jar"/> - <classpathentry kind="lib" path="lib/smackx-jingle_3.5.0.jar"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/de.fu_berlin.inf.dpp/.project b/de.fu_berlin.inf.dpp/.project deleted file mode 100644 index 8b794760e1e3d76196f8a79105cc5dff17332ac9..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/.project +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>Saros</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.ManifestBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.SchemaBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/de.fu_berlin.inf.dpp/.settings/org.eclipse.jdt.ui.prefs b/de.fu_berlin.inf.dpp/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index 442fee40761520acd852ddae5d0453175f30dc5c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Sun Aug 20 21:46:20 CEST 2006 -eclipse.preferences.version=1 -internal.default.compliance=user -org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\r\n * @return the ${bare_field_name}\r\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\r\n * @param ${param} the ${bare_field_name} to set\r\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/**\r\n * \r\n */</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author rdjemili\r\n *\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\r\n * ${see_to_overridden}\r\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\r\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\r\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\r\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates> diff --git a/de.fu_berlin.inf.dpp/CHANGELOG b/de.fu_berlin.inf.dpp/CHANGELOG deleted file mode 100644 index 49536bcd17246aac5287571860287cd5d9e0459b..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/CHANGELOG +++ /dev/null @@ -1,33 +0,0 @@ - -Saros CHANGELOG - -1.0.1 - New Features - - Better selection support for both driver and observer. - - Usability Enhancements - - Added Confirm Dialog to before actually deleting a contact. - - Better tool-tip for connect button (shows current username). - - Disallow connect if username is not set. - - Allow to connect also if in Error-State (after a failed connect). - - Create Jabber-Account requires repeated password entry and - stores configuration by default. - - Can automatically start follow mode. - - On first install a configuration dialog is shown. - - Bugs - - Fixed leak of timer resources since sharing a project was actually never stopped. - - Fixed bug in rename action. - - Fixed [ 1607388 ] Invitation dialog should suggest project name - - Fixed [ 1607387 ] Invitation dialog fails if project already exists - -1.0 - - added skype support - -0.8.2 - - Fixed severe bug in project synchronization - - Fixed severe bug in account creation - - Show invitee name without XMPP-Resource on invitation wizard - -0.8.1 - - First beta release \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/DEV b/de.fu_berlin.inf.dpp/DEV deleted file mode 100644 index c953ae6d6069a25612bd0fa2cdf2427f9ad3d76a..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/DEV +++ /dev/null @@ -1,145 +0,0 @@ - -Saros Developer Readme - ------------------------------------------------------------------ -Content - -1. Introduction -2. The repository -3. Java packages -4. Special Topics - ------------------------------------------------------------------ - -1. Introduction - - Saros is a Eclipse plugin for distributed pair programming. It - features code editing in real-time, view port and text - selection awareness and full project support. Saros is - is free open source software, licensed under the GPL. - - This document is for developing on the Saros project. If you're - completly new to Saros it's better to read the README file - first. - -2. The repository - - The official SVN code repository for Saros can be found at - - https://svn.sourceforge.net/svnroot/dpp - - For more information on how to access it, please see the - Sourceforge information at - - http://sourceforge.net/svn/?group_id=167540 - - The repository is laid out in the following structure. All main - development happens in the trunk. - - + root - + trunk - + de.fu_berlin.dpp - - Contains the code for the Saros plugin (including - necessary libs and resources) - - + de.fu_berlin.dpp.test - - Contains unit tests for the Saros plugin. - - + de.fu_berlin.dpp.feature - - Contains the feature project for the Saros plugin - - + de.fu_berlin.dpp.ecg - - Contains the SarosECG plugin - an extension of the ECG- - Eclipse sensor with new distributed-pair-programming - micro activities. - - + de.fu_berlin.dpp.ecg.feature - - Contains the feature project for the SarosECG plugin - - + de.fu_berlin.dpp.update - - Contains the update site for the Saros and SarosECG - plugins. - - + branches - - Contains stable releases and experimental feature branches. - - + tags - - Generally branches should be used over tags. - -3. Java packages - - The Saros plugin (located under /trunk/de.fu_berlin.dpp) uses - the following packages. Generally all main packages have a - package named 'internal'. This shouldn't be accessed outside of - the Saros plugin. - - + de.fu_berlin.dpp - + de.fu_berlin.dpp.activities - - An activity is a action that can be captured and replicated - on the remote system. It's the basic model for the Saros - system. This package contains all activity classes. - - + de.fu_berlin.dpp.editor - + de.fu_berlin.dpp.editor.internal - - Types that deal with editors and capturing and - replicated text changes, view port changes, text selections - and so on. - - + de.fu_berlin.dpp.editor.annotations - - Custom annotations that are used within the editors to add - visual information (e.g. the current view port of the - driver). - - + de.fu_berlin.dpp.editor.invitation - + de.fu_berlin.dpp.editor.invitation.internal - - Types that deal with incoming and outgoing invitations to - shared projects. They are used to initiate projects. - - + de.fu_berlin.dpp.editor.net - + de.fu_berlin.dpp.editor.net.internal - - Types that deal with sending and receiving data over the - network. Currently only a XMPP-implementation is supported. - - + de.fu_berlin.dpp.editor.project - + de.fu_berlin.dpp.editor.project.internal - - Types that deal with general shared project organization, - like handling the life cycle of a shared project or - managing floor control. - - + de.fu_berlin.dpp.editor.ui - + de.fu_berlin.dpp.editor.ui.actions - + de.fu_berlin.dpp.editor.ui.wizards - + de.fu_berlin.dpp.editor.ui.decorators - - Handles visual aspects, like showing wizards and adding - actions and decorators. - -4. Special topics - -4.1. About Selections - -SelectionAnnotation is the type used to represent a selection annotation. - -org.eclipse.jface.text.source.AnnotationPainter is the class that we need to watch. - -Tom Eicher answers good stuff about Painter - -http://dev.eclipse.org/newslists/news.eclipse.platform/msg55356.html - -Another interesting one: - -ttp://dev.eclipse.org/newslists/news.eclipse.platform/msg56587.html \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/LICENSE b/de.fu_berlin.inf.dpp/LICENSE deleted file mode 100644 index 45645b4b53c803dfd92453900f5a1fc83460e40b..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/LICENSE +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <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/de.fu_berlin.inf.dpp/META-INF/MANIFEST.MF b/de.fu_berlin.inf.dpp/META-INF/MANIFEST.MF deleted file mode 100644 index 4679c50f199d5d32508eea3aba114de6aada351d..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/META-INF/MANIFEST.MF +++ /dev/null @@ -1,346 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Saros Plug-in -Bundle-SymbolicName: de.fu_berlin.inf.dpp;singleton:=true -Bundle-Version: 1.0.8 -Bundle-Activator: de.fu_berlin.inf.dpp.Saros -Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime, - org.eclipse.jdt.ui, - org.eclipse.jdt.core, - org.eclipse.ui.workbench.texteditor, - org.eclipse.jface.text, - org.eclipse.ui.editors, - org.eclipse.core.resources, - org.eclipse.ui.ide -Eclipse-LazyStart: true -Bundle-ClassPath: bin/, - lib/log4j-1.2.15.jar, - ., - lib/smack.jar, - lib/smackx.jar, - lib/smackx-debug.jar, - lib/smackx-jingle_3.5.0.jar -Export-Package: com.jcraft.jzlib, - de.fu_berlin.inf.dpp; - uses:="de.fu_berlin.inf.dpp.net, - org.jivesoftware.smack.packet, - de.fu_berlin.inf.dpp.net.internal, - org.eclipse.core.runtime.preferences, - org.osgi.framework, - org.jivesoftware.smack, - org.eclipse.core.resources, - de.fu_berlin.inf.dpp.ui, - org.jivesoftware.smackx, - de.fu_berlin.inf.dpp.project, - org.eclipse.ui.plugin, - org.jivesoftware.smackx.muc, - org.eclipse.core.runtime", - de.fu_berlin.inf.dpp.activities;uses:="de.fu_berlin.inf.dpp.net,org.eclipse.core.runtime", - de.fu_berlin.inf.dpp.editor; - uses:="de.fu_berlin.inf.dpp.net, - de.fu_berlin.inf.dpp.invitation, - org.xmlpull.v1, - org.eclipse.jface.text, - de.fu_berlin.inf.dpp.project, - de.fu_berlin.inf.dpp.activities, - de.fu_berlin.inf.dpp.editor.internal, - org.eclipse.core.runtime, - org.eclipse.ui", - de.fu_berlin.inf.dpp.editor.annotations; - uses:="org.eclipse.jface.util, - org.eclipse.swt.graphics, - org.eclipse.swt.widgets, - org.eclipse.jface.text.source", - de.fu_berlin.inf.dpp.editor.internal;x-internal:=true, - de.fu_berlin.inf.dpp.invitation; - uses:="de.fu_berlin.inf.dpp.net, - de.fu_berlin.inf.dpp, - org.eclipse.core.resources, - org.eclipse.core.runtime", - de.fu_berlin.inf.dpp.invitation.internal;x-internal:=true, - de.fu_berlin.inf.dpp.net; - uses:="de.fu_berlin.inf.dpp.concurrent, - org.jivesoftware.smack.packet, - org.jivesoftware.smack, - org.eclipse.core.resources, - de.fu_berlin.inf.dpp.invitation, - de.fu_berlin.inf.dpp.project, - de.fu_berlin.inf.dpp.activities, - de.fu_berlin.inf.dpp, - org.eclipse.core.runtime, - de.fu_berlin.inf.dpp.concurrent.jupiter", - de.fu_berlin.inf.dpp.net.internal;x-internal:=true, - de.fu_berlin.inf.dpp.project; - uses:="de.fu_berlin.inf.dpp.net, - de.fu_berlin.inf.dpp.invitation, - org.xmlpull.v1, - org.jivesoftware.smack, - de.fu_berlin.inf.dpp.activities, - de.fu_berlin.inf.dpp, - org.eclipse.core.resources", - de.fu_berlin.inf.dpp.project.internal;x-internal:=true, - de.fu_berlin.inf.dpp.ui; - uses:="org.eclipse.jface.util, - org.eclipse.jface.dialogs, - de.fu_berlin.inf.dpp.net, - org.eclipse.swt.graphics, - org.jivesoftware.smack, - org.eclipse.ui, - org.eclipse.ui.part, - org.eclipse.jface.preference, - de.fu_berlin.inf.dpp.invitation, - de.fu_berlin.inf.dpp.project, - org.eclipse.jface.window, - de.fu_berlin.inf.dpp, - org.eclipse.jface.resource, - org.eclipse.swt.widgets", - de.fu_berlin.inf.dpp.ui.actions; - uses:="de.fu_berlin.inf.dpp.net, - org.eclipse.jface.viewers, - de.fu_berlin.inf.dpp.invitation, - de.fu_berlin.inf.dpp.project, - org.jivesoftware.smack, - de.fu_berlin.inf.dpp, - org.eclipse.jface.action, - org.eclipse.ui.actions, - org.eclipse.ui", - de.fu_berlin.inf.dpp.ui.decorators; - uses:="org.eclipse.jface.viewers, - de.fu_berlin.inf.dpp.editor, - de.fu_berlin.inf.dpp.invitation, - de.fu_berlin.inf.dpp.project, - org.eclipse.core.runtime", - de.fu_berlin.inf.dpp.ui.wizards; - uses:="de.fu_berlin.inf.dpp.net, - de.fu_berlin.inf.dpp.invitation, - org.eclipse.jface.wizard, - org.eclipse.swt.widgets", - de.fu_berlin.inf.dpp.util;uses:="org.jivesoftware.smack.packet,org.eclipse.core.resources", - de.javawi.jstun;uses:="junit.framework", - de.javawi.jstun.attribute;uses:="junit.framework,de.javawi.jstun.util", - de.javawi.jstun.header;uses:="de.javawi.jstun.attribute", - de.javawi.jstun.test;uses:="de.javawi.jstun.attribute", - de.javawi.jstun.test.demo, - de.javawi.jstun.test.demo.ice;uses:="de.javawi.jstun.util", - de.javawi.jstun.util;uses:="junit.framework", - images, - org.apache.log4j;uses:="org.apache.log4j.or,org.apache.log4j.spi,org.apache.log4j.helpers", - org.apache.log4j.chainsaw; - uses:="javax.swing.event, - org.apache.log4j, - org.xml.sax, - org.apache.log4j.spi, - org.xml.sax.helpers, - javax.swing.table, - javax.swing", - org.apache.log4j.config;uses:="org.apache.log4j", - org.apache.log4j.helpers;uses:="org.apache.log4j,org.apache.log4j.spi", - org.apache.log4j.jdbc;uses:="org.apache.log4j,org.apache.log4j.spi", - org.apache.log4j.jmx;uses:="org.apache.log4j,org.apache.log4j.spi,javax.management", - org.apache.log4j.lf5;uses:="org.apache.log4j,org.apache.log4j.lf5.viewer,org.apache.log4j.spi", - org.apache.log4j.lf5.config, - org.apache.log4j.lf5.util;uses:="org.apache.log4j.lf5.viewer,org.apache.log4j.lf5", - org.apache.log4j.lf5.viewer; - uses:="javax.swing.table, - org.apache.log4j.lf5.viewer.categoryexplorer, - org.apache.log4j.lf5, - javax.swing.event, - org.apache.log4j.lf5.viewer.configure, - org.apache.log4j.lf5.util, - javax.swing", - org.apache.log4j.lf5.viewer.categoryexplorer; - uses:="javax.swing.event, - javax.swing.tree, - javax.swing.table, - org.apache.log4j.lf5, - javax.swing", - org.apache.log4j.lf5.viewer.configure;uses:="org.apache.log4j.lf5.viewer,javax.swing.tree,org.w3c.dom", - org.apache.log4j.lf5.viewer.images, - org.apache.log4j.net; - uses:="org.apache.log4j.spi, - org.apache.log4j.xml, - org.w3c.dom, - org.apache.log4j, - javax.naming, - javax.mail.internet, - javax.mail, - javax.jms, - org.apache.log4j.helpers", - org.apache.log4j.nt;uses:="org.apache.log4j,org.apache.log4j.spi", - org.apache.log4j.or;uses:="org.apache.log4j.spi", - org.apache.log4j.or.jms;uses:="org.apache.log4j.or", - org.apache.log4j.or.sax;uses:="org.apache.log4j.or", - org.apache.log4j.spi;uses:="org.apache.log4j.or,org.apache.log4j", - org.apache.log4j.varia;uses:="org.apache.log4j,org.apache.log4j.spi", - org.apache.log4j.xml; - uses:="org.apache.log4j, - org.xml.sax, - org.apache.log4j.spi, - javax.xml.parsers, - org.w3c.dom, - org.apache.log4j.helpers, - org.apache.log4j.config", - org.jivesoftware.smack; - uses:="org.jivesoftware.smack.filter, - org.jivesoftware.smack.packet, - new org.jivesoftware.smack, - javax.net, - javax.net.ssl", - org.jivesoftware.smack.debugger; - uses:="org.jivesoftware.smack.packet, - org.jivesoftware.smack, - org.jivesoftware.smack.util, - javax.swing", - org.jivesoftware.smack.filter;uses:="org.jivesoftware.smack.packet", - org.jivesoftware.smack.packet;uses:="new org.jivesoftware.smack.packet", - org.jivesoftware.smack.provider;uses:="org.jivesoftware.smack.packet,org.xmlpull.v1", - org.jivesoftware.smack.sasl;uses:="org.jivesoftware.smack", - org.jivesoftware.smack.util; - uses:="org.jivesoftware.smack.packet, - org.jivesoftware.smack.util.collections, - org.xmlpull.v1, - new new org.jivesoftware.smack.util, - new org.jivesoftware.smack.util", - org.jivesoftware.smack.util.collections, - org.jivesoftware.smackx; - uses:="org.jivesoftware.smackx.packet, - org.jivesoftware.smackx.provider, - org.jivesoftware.smack.filter, - org.jivesoftware.smack.packet, - org.xmlpull.v1, - org.jivesoftware.smack.provider, - org.jivesoftware.smack, - new org.jivesoftware.smackx", - org.jivesoftware.smackx.bookmark; - uses:="org.jivesoftware.smackx.packet, - org.jivesoftware.smackx.provider, - org.xmlpull.v1, - org.jivesoftware.smack", - org.jivesoftware.smackx.debugger; - uses:="new org.jivesoftware.smackx.debugger, - org.jivesoftware.smack.packet, - javax.swing.table, - org.jivesoftware.smack, - org.jivesoftware.smack.debugger, - org.jivesoftware.smack.util, - javax.swing", - org.jivesoftware.smackx.filetransfer; - uses:="org.jivesoftware.smackx.packet, - org.jivesoftware.smack.packet, - org.jivesoftware.smack.filter, - org.jivesoftware.smack", - org.jivesoftware.smackx.jingle; - uses:="org.jivesoftware.smackx.packet, - org.jivesoftware.smack.filter, - org.jivesoftware.smack.packet, - org.jivesoftware.smackx.jingle.media, - org.jivesoftware.smackx.jingle.listeners, - org.jivesoftware.smack, - org.jivesoftware.smackx.jingle.nat", - org.jivesoftware.smackx.jingle.listeners; - uses:="org.jivesoftware.smackx.jingle.media, - org.jivesoftware.smack, - org.jivesoftware.smackx.jingle.nat, - org.jivesoftware.smackx.jingle", - org.jivesoftware.smackx.jingle.media; - uses:="org.jivesoftware.smackx.packet, - org.jivesoftware.smack.packet, - org.jivesoftware.smackx.jingle.nat, - org.jivesoftware.smackx.jingle", - org.jivesoftware.smackx.jingle.mediaimpl, - org.jivesoftware.smackx.jingle.mediaimpl.jmf; - uses:="javax.media, - javax.media.rtp.event, - javax.media.rtp, - org.jivesoftware.smackx.jingle.media, - javax.media.format, - org.jivesoftware.smackx.jingle.nat, - org.jivesoftware.smackx.jingle", - org.jivesoftware.smackx.jingle.mediaimpl.jspeex; - uses:="org.jivesoftware.smackx.jingle.media, - javax.media.rtp.rtcp, - mil.jfcom.cie.media.session, - org.jivesoftware.smackx.jingle.nat, - org.jivesoftware.smackx.jingle", - org.jivesoftware.smackx.jingle.mediaimpl.multi;uses:="org.jivesoftware.smackx.jingle.media,org.jivesoftware.smackx.jingle.nat,org.jivesoftware.smackx.jingle", - org.jivesoftware.smackx.jingle.mediaimpl.sshare; - uses:="org.jivesoftware.smackx.jingle.media, - org.jivesoftware.smackx.jingle.mediaimpl.sshare.api, - org.jivesoftware.smackx.jingle.nat, - org.jivesoftware.smackx.jingle", - org.jivesoftware.smackx.jingle.mediaimpl.sshare.api, - org.jivesoftware.smackx.jingle.nat; - uses:="org.jivesoftware.smackx.packet, - org.jivesoftware.smack.packet, - org.jivesoftware.smackx.jingle.media, - org.jivesoftware.smack, - de.javawi.jstun.test.demo.ice, - org.xmlpull.v1, - org.jivesoftware.smackx.jingle.listeners, - org.jivesoftware.smack.provider, - org.jivesoftware.smackx.jingle, - new org.jivesoftware.smackx.jingle.nat", - org.jivesoftware.smackx.muc; - uses:="org.jivesoftware.smackx.packet, - org.jivesoftware.smack.filter, - org.jivesoftware.smackx, - org.jivesoftware.smack.packet, - new org.jivesoftware.smackx.muc, - org.jivesoftware.smack", - org.jivesoftware.smackx.packet; - uses:="org.jivesoftware.smack.packet, - org.jivesoftware.smackx.jingle.media, - org.xmlpull.v1, - org.jivesoftware.smack.provider, - org.jivesoftware.smackx.jingle.nat, - org.jivesoftware.smackx.jingle", - org.jivesoftware.smackx.provider; - uses:="org.jivesoftware.smackx.packet, - org.jivesoftware.smack.packet, - org.jivesoftware.smackx.jingle.media, - org.xmlpull.v1, - org.jivesoftware.smack.provider", - org.jivesoftware.smackx.search; - uses:="org.jivesoftware.smack.packet, - org.jivesoftware.smackx, - org.xmlpull.v1, - org.jivesoftware.smack, - org.jivesoftware.smack.provider", - org.jivesoftware.smackx.workgroup;uses:="org.jivesoftware.smack.packet", - org.jivesoftware.smackx.workgroup.agent; - uses:="org.jivesoftware.smack.packet, - org.jivesoftware.smackx.workgroup, - org.jivesoftware.smackx.workgroup.ext.notes, - org.jivesoftware.smack, - org.jivesoftware.smackx.workgroup.ext.macros, - org.jivesoftware.smackx.workgroup.packet, - org.jivesoftware.smackx.workgroup.settings, - org.jivesoftware.smackx, - org.jivesoftware.smackx.workgroup.ext.history, - org.xmlpull.v1, - org.jivesoftware.smack.provider", - org.jivesoftware.smackx.workgroup.ext.forms;uses:="org.jivesoftware.smack.packet,org.xmlpull.v1,org.jivesoftware.smack.provider", - org.jivesoftware.smackx.workgroup.ext.history;uses:="org.jivesoftware.smack.packet,org.xmlpull.v1,org.jivesoftware.smack.provider", - org.jivesoftware.smackx.workgroup.ext.macros;uses:="org.jivesoftware.smack.packet,org.xmlpull.v1,org.jivesoftware.smack.provider", - org.jivesoftware.smackx.workgroup.ext.notes;uses:="org.jivesoftware.smack.packet,org.xmlpull.v1,org.jivesoftware.smack.provider", - org.jivesoftware.smackx.workgroup.packet; - uses:="org.jivesoftware.smackx.workgroup, - org.jivesoftware.smack.packet, - org.jivesoftware.smackx.workgroup.agent, - org.xmlpull.v1, - org.jivesoftware.smack.provider, - new org.jivesoftware.smackx.workgroup.packet", - org.jivesoftware.smackx.workgroup.settings;uses:="org.jivesoftware.smack.packet,org.xmlpull.v1,org.jivesoftware.smack.provider", - org.jivesoftware.smackx.workgroup.user; - uses:="org.jivesoftware.smackx.workgroup, - org.jivesoftware.smackx, - org.jivesoftware.smack.packet, - org.jivesoftware.smack, - org.jivesoftware.smackx.muc, - org.jivesoftware.smackx.workgroup.settings", - org.jivesoftware.smackx.workgroup.util;uses:="org.xmlpull.v1", - org.xmlpull.mxp1;uses:="org.xmlpull.v1", - org.xmlpull.v1 -Bundle-Vendor: FU-Berlin -Import-Package: org.apache.log4j diff --git a/de.fu_berlin.inf.dpp/META-INF/smack-config.xml b/de.fu_berlin.inf.dpp/META-INF/smack-config.xml deleted file mode 100644 index eb0ea25cec637bfa3ed1d4947707821ed82e9a48..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/META-INF/smack-config.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0"?> -<!-- Smack configuration file. --> -<smack> - - <!-- Classes that will be loaded when Smack starts --> - <startupClasses> - <className>org.jivesoftware.smackx.ServiceDiscoveryManager</className> - <className>org.jivesoftware.smackx.XHTMLManager</className> - <className>org.jivesoftware.smackx.muc.MultiUserChat</className> - <className>org.jivesoftware.smackx.filetransfer.FileTransferManager</className> - </startupClasses> - - <!-- Paket reply timeout in milliseconds --> - <packetReplyTimeout>5000</packetReplyTimeout> - - <!-- Keep-alive interval in milleseconds --> - <keepAliveInterval>30000</keepAliveInterval> - -</smack> \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/META-INF/smack.providers b/de.fu_berlin.inf.dpp/META-INF/smack.providers deleted file mode 100644 index 88b1be56a3cf84b5d0994c67b64a517d5a50cdec..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/META-INF/smack.providers +++ /dev/null @@ -1,192 +0,0 @@ -<?xml version="1.0"?> -<!-- Providers file for default Smack extensions --> -<smackProviders> - - <!-- Private Data Storage --> - <iqProvider> - <elementName>query</elementName> - <namespace>jabber:iq:private</namespace> - <className>org.jivesoftware.smackx.PrivateDataManager$PrivateDataIQProvider</className> - </iqProvider> - - <!-- Time --> - <iqProvider> - <elementName>query</elementName> - <namespace>jabber:iq:time</namespace> - <className>org.jivesoftware.smackx.packet.Time</className> - </iqProvider> - - <!-- Roster Exchange --> - <extensionProvider> - <elementName>x</elementName> - <namespace>jabber:x:roster</namespace> - <className>org.jivesoftware.smackx.provider.RosterExchangeProvider</className> - </extensionProvider> - - <!-- Message Events --> - <extensionProvider> - <elementName>x</elementName> - <namespace>jabber:x:event</namespace> - <className>org.jivesoftware.smackx.provider.MessageEventProvider</className> - </extensionProvider> - - <!-- XHTML --> - <extensionProvider> - <elementName>html</elementName> - <namespace>http://jabber.org/protocol/xhtml-im</namespace> - <className>org.jivesoftware.smackx.provider.XHTMLExtensionProvider</className> - </extensionProvider> - - <!-- Group Chat Invitations --> - <extensionProvider> - <elementName>x</elementName> - <namespace>jabber:x:conference</namespace> - <className>org.jivesoftware.smackx.GroupChatInvitation$Provider</className> - </extensionProvider> - - <!-- Service Discovery # Items --> - <iqProvider> - <elementName>query</elementName> - <namespace>http://jabber.org/protocol/disco#items</namespace> - <className>org.jivesoftware.smackx.provider.DiscoverItemsProvider</className> - </iqProvider> - - <!-- Service Discovery # Info --> - <iqProvider> - <elementName>query</elementName> - <namespace>http://jabber.org/protocol/disco#info</namespace> - <className>org.jivesoftware.smackx.provider.DiscoverInfoProvider</className> - </iqProvider> - - <!-- Data Forms--> - <extensionProvider> - <elementName>x</elementName> - <namespace>jabber:x:data</namespace> - <className>org.jivesoftware.smackx.provider.DataFormProvider</className> - </extensionProvider> - - <!-- MUC User --> - <extensionProvider> - <elementName>x</elementName> - <namespace>http://jabber.org/protocol/muc#user</namespace> - <className>org.jivesoftware.smackx.provider.MUCUserProvider</className> - </extensionProvider> - - <!-- MUC Admin --> - <iqProvider> - <elementName>query</elementName> - <namespace>http://jabber.org/protocol/muc#admin</namespace> - <className>org.jivesoftware.smackx.provider.MUCAdminProvider</className> - </iqProvider> - - <!-- MUC Owner --> - <iqProvider> - <elementName>query</elementName> - <namespace>http://jabber.org/protocol/muc#owner</namespace> - <className>org.jivesoftware.smackx.provider.MUCOwnerProvider</className> - </iqProvider> - - <!-- Delayed Delivery --> - <extensionProvider> - <elementName>x</elementName> - <namespace>jabber:x:delay</namespace> - <className>org.jivesoftware.smackx.provider.DelayInformationProvider</className> - </extensionProvider> - - <!-- Version --> - <iqProvider> - <elementName>query</elementName> - <namespace>jabber:iq:version</namespace> - <className>org.jivesoftware.smackx.packet.Version</className> - </iqProvider> - - <!-- VCard --> - <iqProvider> - <elementName>vCard</elementName> - <namespace>vcard-temp</namespace> - <className>org.jivesoftware.smackx.provider.VCardProvider</className> - </iqProvider> - - <!-- Offline Message Requests --> - <iqProvider> - <elementName>offline</elementName> - <namespace>http://jabber.org/protocol/offline</namespace> - <className>org.jivesoftware.smackx.packet.OfflineMessageRequest$Provider</className> - </iqProvider> - - <!-- Offline Message Indicator --> - <extensionProvider> - <elementName>offline</elementName> - <namespace>http://jabber.org/protocol/offline</namespace> - <className>org.jivesoftware.smackx.packet.OfflineMessageInfo$Provider</className> - </extensionProvider> - - <!-- Last Activity --> - <iqProvider> - <elementName>query</elementName> - <namespace>jabber:iq:last</namespace> - <className>org.jivesoftware.smackx.packet.LastActivity$Provider</className> - </iqProvider> - - <!-- User Search --> - <iqProvider> - <elementName>query</elementName> - <namespace>jabber:iq:search</namespace> - <className>org.jivesoftware.smackx.search.UserSearch$Provider</className> - </iqProvider> - - <!-- SharedGroupsInfo --> - <iqProvider> - <elementName>sharedgroup</elementName> - <namespace>http://www.jivesoftware.org/protocol/sharedgroup</namespace> - <className>org.jivesoftware.smackx.packet.SharedGroupsInfo$Provider</className> - </iqProvider> - - <!-- JEP-33: Extended Stanza Addressing --> - <extensionProvider> - <elementName>addresses</elementName> - <namespace>http://jabber.org/protocol/address</namespace> - <className>org.jivesoftware.smackx.provider.MultipleAddressesProvider</className> - </extensionProvider> - - <!-- FileTransfer --> - <iqProvider> - <elementName>si</elementName> - <namespace>http://jabber.org/protocol/si</namespace> - <className>org.jivesoftware.smackx.provider.StreamInitiationProvider</className> - </iqProvider> - - <iqProvider> - <elementName>query</elementName> - <namespace>http://jabber.org/protocol/bytestreams</namespace> - <className>org.jivesoftware.smackx.provider.BytestreamsProvider</className> - </iqProvider> - - <iqProvider> - <elementName>open</elementName> - <namespace>http://jabber.org/protocol/ibb</namespace> - <className>org.jivesoftware.smackx.provider.IBBProviders$Open</className> - </iqProvider> - - <iqProvider> - <elementName>close</elementName> - <namespace>http://jabber.org/protocol/ibb</namespace> - <className>org.jivesoftware.smackx.provider.IBBProviders$Close</className> - </iqProvider> - - <extensionProvider> - <elementName>data</elementName> - <namespace>http://jabber.org/protocol/ibb</namespace> - <className>org.jivesoftware.smackx.provider.IBBProviders$Data</className> - </extensionProvider> - - <!-- Photo - <extensionProvider> - <elementName>x</elementName> - <namespace>vcard-temp:x:update</namespace> - <className>org.jivesoftware.smackx.provider.VCardTempXUpdateProvider</className> - </extensionProvider> ---> - - -</smackProviders> \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/build.properties b/de.fu_berlin.inf.dpp/build.properties deleted file mode 100644 index b8dbc46032a46a690ccf2778ba1a4bdb3fe59363..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/build.properties +++ /dev/null @@ -1,25 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - plugin.xml,\ - icons/,\ - lib/smack.jar,\ - lib/smackx-debug.jar,\ - bin/,\ - lib/log4j-1.2.15.jar,\ - lib/smackx.jar,\ - log4j.properties,\ - lib/smackx-jingle_3.5.0.jar -src.includes = icons/,\ - src/,\ - plugin.xml,\ - lib/junit.jar,\ - lib/smack.jar,\ - lib/smackx-debug.jar,\ - lib/smackx.jar,\ - LICENSE,\ - log4j.properties,\ - lib/smackx-jingle_3.5.0.jar -jars.compile.order = .,\ - lib/log4j-1.2.15.jar diff --git a/de.fu_berlin.inf.dpp/build.xml b/de.fu_berlin.inf.dpp/build.xml deleted file mode 100644 index f62a63f125f7596e5edc79193f1398bc13439286..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/build.xml +++ /dev/null @@ -1,260 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project name="de.fu_berlin.inf.dpp" default="build.update.jar" basedir="."> - - <property name="basews" value="${ws}"/> - <property name="baseos" value="${os}"/> - <property name="basearch" value="${arch}"/> - <property name="basenl" value="${nl}"/> - - <!-- Compiler settings. --> - <property name="javacFailOnError" value="false"/> - <property name="javacDebugInfo" value="on"/> - <property name="javacVerbose" value="true"/> - <property name="logExtension" value=".log"/> - <property name="compilerArg" value=""/> - <property name="javacSource" value="1.5"/> - <property name="javacTarget" value="1.5"/> - <path id="path_bootclasspath"> - <fileset dir="${java.home}/lib"> - <include name="*.jar"/> - </fileset> - </path> - <property name="bootclasspath" refid="path_bootclasspath"/> - <property name="bundleJavacSource" value="${javacSource}"/> - <property name="bundleJavacTarget" value="${javacTarget}"/> - <property name="bundleBootClasspath" value="${bootclasspath}"/> - - <target name="init" depends="properties"> - <condition property="pluginTemp" value="${buildTempFolder}/plugins"> - <isset property="buildTempFolder"/> - </condition> - <property name="pluginTemp" value="${basedir}"/> - <condition property="build.result.folder" value="${pluginTemp}/Plugin"> - <isset property="buildTempFolder"/> - </condition> - <property name="build.result.folder" value="${basedir}"/> - <property name="temp.folder" value="${basedir}/temp.folder"/> - <property name="plugin.destination" value="${basedir}"/> - <property name="eclipse.dir" value="/home/troll/download/Eclipse/eclipse"/> - <property name="saros.version" value="1.0.x"/> - </target> - - <target name="properties" if="eclipse.running"> - <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/> - - </target> - - <target name="build.update.jar" depends="init" description="Build the plug-in: de.fu_berlin.inf.dpp for an update site."> - <delete dir="${temp.folder}"/> - <mkdir dir="${temp.folder}"/> - <antcall target="build.jars"/> - <antcall target="gather.bin.parts"> - <param name="destination.temp.folder" value="${temp.folder}/"/> - </antcall> - <zip destfile="${plugin.destination}/de.fu_berlin.inf.dpp_${saros.version}.jar" basedir="${temp.folder}/de.fu_berlin.inf.dpp_${saros.version}" filesonly="false" whenempty="skip" update="false"/> - <delete dir="${temp.folder}"/> - </target> - - <target name="@dot" depends="init" unless="@dot" description="Create jar: de.fu_berlin.inf.dpp @dot."> - <delete dir="${temp.folder}/@dot.bin"/> - <mkdir dir="${temp.folder}/@dot.bin"/> - <path id="@dot.classpath"> - <!-- - <pathelement path="C:\dkfajfk\/plugins/org.eclipse.ui_3.2.0.I20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.runtime_3.2.0.v20060601b.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.osgi_3.2.0.v20060601.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.equinox.common_3.2.0.v20060601a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.jobs_3.2.0.v20060601a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060602/runtime_registry_compatibility.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060602"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.equinox.registry_3.2.0.v20060601.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.equinox.preferences_3.2.0.v20060601.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060602/@dot"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.contenttype_3.2.0.v20060601a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.runtime.compatibility.auth_3.2.0.v20060601.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.swt_3.2.0.v3232l.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.swt.win32.win32.x86_3.2.0.v3232l.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jface_3.2.0.I20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.commands_3.2.0.I20060511-0800a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.workbench_3.2.0.I20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.workbench.compatibility_3.2.0.I20060511-2000/@dot"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.workbench.compatibility_3.2.0.I20060511-2000/compatibility.jar"/> - <pathelement path="${eclipse.home}/plugins/com.ibm.icu_3.4.4.1.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.help_3.2.0.v20060518.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.expressions_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.resources_3.2.0.v20060601a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.resources.compatibility_3.2.0.v20060601a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.resources.win32_3.2.0.v20060601a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.runtime.compatibility_3.1.100.v20060601a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.update.configurator_3.2.0.v20060511.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ant.core_3.1.100.v20060531.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.variables_3.1.100.v20060517.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.filesystem_1.0.0.v20060601a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.filesystem.win32.x86_1.0.0.v20060601a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.ui_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.console_3.1.100.v20060518.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jface.text_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.text_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.workbench.texteditor_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.core_3.2.0.v_670.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.team.core_3.2.0.I200605181830.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.search_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.filebuffers_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.ide_3.2.0.I20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.win32_3.2.0.I20060511-2000.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.views_3.2.0.I20060511-2000.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.update.core_3.2.0.v20060602.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.update.core.win32_3.2.0.v20060511.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.update.ui_3.2.0.v20060601.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.forms_3.2.0.v20060530.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.debug.core_3.2.0.v20060601.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.debug.ui_3.2.0.v20060601.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.editors_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.launching_3.2.0.v20060525.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.debug_3.2.0.v20060601/jdi.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.debug_3.2.0.v20060601/jdimodel.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.debug_3.2.0.v20060601/tools.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.compare_3.2.0.v20060525.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.team.ui_3.2.0.I200606011710.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.navigator_3.2.0.I20060526-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.navigator.resources_3.2.0.I20060511-2000.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.views.properties.tabbed_3.2.0.I20060511-0800a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ltk.core.refactoring_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ltk.ui.refactoring_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.core.manipulation_1.0.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.intro_3.2.0.v20060601.jar"/> - <pathelement path="${eclipse.home}/plugins/org.apache.lucene_1.4.103.v20060601/lucene-1.4.3.jar"/> - <pathelement path="${eclipse.home}/plugins/org.apache.lucene_1.4.103.v20060601/parser.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.help.base_3.2.0.v20060601.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.help.appserver_3.1.100.v20060510b.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.cheatsheets_3.2.0.v20060516.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.help.ui_3.2.0.v20060510b.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.debug.ui_3.2.0.v20060517.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.doc.isv_3.2.0.v20060602-1130.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.doc.user_3.2.0.v20060602-1130.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.junit_3.2.0.v20060602-0010/junitsupport.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.junit.runtime_3.2.0.v20060602-0010/junitruntime.jar"/> - <pathelement path="${eclipse.home}/plugins/org.junit_3.8.1/junit.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.source_3.2.0.v20060602-0010-F7snq0fulF-UQcP/@dot"/> - --> - <fileset dir="${eclipse.dir}/plugins/"> - <include name="**/*.jar"/> - <exclude name="**/org.jivesoftware.smack_2.2.1.jar"/> - </fileset> - <pathelement path="bin/"/> - <fileset dir="${basedir}/lib"> - <include name="**/*.jar"/> - </fileset> - <!-- - <pathelement path="${build.result.folder}/../de.fu_berlin.inf.dpp/bin/"/> - <pathelement path="lib/smack.jar"/> - <pathelement path="${build.result.folder}/../de.fu_berlin.inf.dpp/lib/smack.jar"/> - <pathelement path="lib/smackx.jar"/> - <pathelement path="${build.result.folder}/../de.fu_berlin.inf.dpp/lib/smackx.jar"/> - <pathelement path="lib/smackx-debug.jar"/> - <pathelement path="${build.result.folder}/../de.fu_berlin.inf.dpp/lib/smackx-debug.jar"/> - --> - </path> - <!-- compile the source code --> - <javac destdir="${temp.folder}/@dot.bin" failonerror="${javacFailOnError}" verbose="${javacVerbose}" debug="${javacDebugInfo}" includeAntRuntime="no" bootclasspath="${bundleBootClasspath}" source="${bundleJavacSource}" target="${bundleJavacTarget}" > - <compilerarg line="${compilerArg}" compiler="${build.compiler}"/> - <classpath refid="@dot.classpath" /> - <src path="src/" /> - <compilerarg value="@${basedir}/javaCompiler...args" compiler="org.eclipse.jdt.core.JDTCompilerAdapter"/> - <compilerarg line="-log '${temp.folder}/@dot.bin${logExtension}'" compiler="org.eclipse.jdt.core.JDTCompilerAdapter"/> - </javac> - <!-- Copy necessary resources --> - <copy todir="${temp.folder}/@dot.bin" failonerror="true" overwrite="false"> - <fileset dir="src/" excludes="**/*.java, **/package.htm*" /> - </copy> - <mkdir dir="${build.result.folder}"/> - <copy todir="${build.result.folder}/@dot" failonerror="true" overwrite="false"> - <fileset dir="${temp.folder}/@dot.bin" /> - </copy> - <delete dir="${temp.folder}/@dot.bin"/> - </target> - - <target name="src.zip" depends="init" unless="src.zip"> - <mkdir dir="${build.result.folder}"/> - <zip destfile="${build.result.folder}/src.zip" filesonly="false" whenempty="skip" update="false"> - <fileset dir="src/" includes="**/*.java" /> - </zip> - </target> - - <target name="build.jars" depends="init" description="Build all the jars for the plug-in: de.fu_berlin.inf.dpp."> - <available property="@dot" file="${build.result.folder}/@dot"/> - <antcall target="@dot"/> - </target> - - <target name="build.sources" depends="init"> - <available property="src.zip" file="${build.result.folder}/src.zip"/> - <antcall target="src.zip"/> - </target> - - <target name="gather.bin.parts" depends="init" if="destination.temp.folder"> - <mkdir dir="${destination.temp.folder}/de.fu_berlin.inf.dpp_${saros.version}"/> - <copy todir="${destination.temp.folder}/de.fu_berlin.inf.dpp_${saros.version}" failonerror="true" overwrite="false"> - <fileset dir="${build.result.folder}/@dot" includes="**" /> - </copy> - <copy todir="${destination.temp.folder}/de.fu_berlin.inf.dpp_${saros.version}" failonerror="true" overwrite="false"> - <fileset dir="${basedir}"> - <include name="META-INF/"/> - <include name="plugin.xml"/> - <include name="icons/"/> - <include name="lib/smack*.jar"/> - <include name="lib/log*.jar"/> - <include name="log4j*"/> - </fileset> - <!--fileset dir="${basedir}" includes="META-INF/,plugin.xml,icons/,lib/smack.jar,lib/smackx-debug.jar,lib/smackx.jar,bin/" /--> - </copy> - </target> - - <target name="build.zips" depends="init"> - </target> - - <target name="gather.sources" depends="init" if="destination.temp.folder"> - <mkdir dir="${destination.temp.folder}/de.fu_berlin.inf.dpp_${saros.version}"/> - <copy file="${build.result.folder}/src.zip" todir="${destination.temp.folder}/de.fu_berlin.inf.dpp_${saros.version}" failonerror="false" overwrite="false"/> - <copy todir="${destination.temp.folder}/de.fu_berlin.inf.dpp_${saros.version}" failonerror="false" overwrite="false"> - <fileset dir="${basedir}" includes="icons/,src/,plugin.xml,lib/junit.jar,lib/smack.jar,lib/smackx-debug.jar,lib/smackx.jar" /> - </copy> - </target> - - <target name="gather.logs" depends="init" if="destination.temp.folder"> - <mkdir dir="${destination.temp.folder}/de.fu_berlin.inf.dpp_${saros.version}"/> - <copy file="${temp.folder}/@dot.bin${logExtension}" todir="${destination.temp.folder}/de.fu_berlin.inf.dpp_${saros.version}" failonerror="false" overwrite="false"/> - </target> - - <target name="clean" depends="init" description="Clean the plug-in: de.fu_berlin.inf.dpp of all the zips, jars and logs created."> - <delete dir="${build.result.folder}/@dot"/> - <delete file="${build.result.folder}/src.zip"/> - <delete file="${plugin.destination}/de.fu_berlin.inf.dpp_${saros.version}.jar"/> - <delete file="${plugin.destination}/de.fu_berlin.inf.dpp_${saros.version}.zip"/> - <delete dir="${temp.folder}"/> - </target> - - <target name="refresh" depends="init" if="eclipse.running" description="Refresh this folder."> - <eclipse.convertPath fileSystemPath="D:/Coding/Java/Saros/Plugin" property="resourcePath"/> - <eclipse.refreshLocal resource="${resourcePath}" depth="infinite"/> - </target> - - <target name="zip.plugin" depends="init" description="Create a zip containing all the elements for the plug-in: de.fu_berlin.inf.dpp."> - <delete dir="${temp.folder}"/> - <mkdir dir="${temp.folder}"/> - <antcall target="build.jars"/> - <antcall target="build.sources"/> - <antcall target="gather.bin.parts"> - <param name="destination.temp.folder" value="${temp.folder}/"/> - </antcall> - <antcall target="gather.sources"> - <param name="destination.temp.folder" value="${temp.folder}/"/> - </antcall> - <delete> - <fileset dir="${temp.folder}" includes="**/*.bin${logExtension}" /> - </delete> - <zip destfile="${plugin.destination}/de.fu_berlin.inf.dpp_${saros.version}.zip" basedir="${temp.folder}" filesonly="true" whenempty="skip" update="false"/> - <delete dir="${temp.folder}"/> - </target> - -</project> diff --git a/de.fu_berlin.inf.dpp/credits.txt b/de.fu_berlin.inf.dpp/credits.txt deleted file mode 100644 index 7808a28e04059a19a4fe2276c0d56982e5462bfd..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/credits.txt +++ /dev/null @@ -1,8 +0,0 @@ - - Author: Riad Djemili, Christopher Oezbek, Bj�rn Gustavs, Oliver Rieger - - Icons: Eclipse Org. & Silk Icon set by http://www.famfamfam.com - - Jupiter Algorithm Implementation taken from "ace - A Collaborative Editor" - - This project uses the following libraries: Log4J, Smack \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/header.txt b/de.fu_berlin.inf.dpp/header.txt deleted file mode 100644 index d0dcd6284a0685cd681da43a57ad41ada1fad077..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/header.txt +++ /dev/null @@ -1,19 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universit�t Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ diff --git a/de.fu_berlin.inf.dpp/icons/add.png b/de.fu_berlin.inf.dpp/icons/add.png deleted file mode 100644 index 6332fefea4be19eeadf211b0b202b272e8564898..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/add.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/bullet_feed.png b/de.fu_berlin.inf.dpp/icons/bullet_feed.png deleted file mode 100644 index 4367cd0df6b582b723da9aea197f2b77c1ad7379..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/bullet_feed.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/bullet_green.png b/de.fu_berlin.inf.dpp/icons/bullet_green.png deleted file mode 100644 index a2748cf726a11c8891da01acd45d6bf4197c1243..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/bullet_green.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/bullet_yellow.png b/de.fu_berlin.inf.dpp/icons/bullet_yellow.png deleted file mode 100644 index 29b10262b65ba9e572bbfd6542432cd9521fed05..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/bullet_yellow.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/comment.png b/de.fu_berlin.inf.dpp/icons/comment.png deleted file mode 100644 index 7bc9233ea63c89d52a99494dd0f0735a29a3ec3b..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/comment.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/connect.png b/de.fu_berlin.inf.dpp/icons/connect.png deleted file mode 100644 index 024138eb33b9124af6db8149747adbb41c1b8cfc..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/connect.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/disconnect.png b/de.fu_berlin.inf.dpp/icons/disconnect.png deleted file mode 100644 index b335cb11c4d1a397b307883adcfe1e00c4cf8e6a..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/disconnect.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/door_open.png b/de.fu_berlin.inf.dpp/icons/door_open.png deleted file mode 100644 index 64bab57ddd0e95ad9a73a3828ec29b5d0b4dd675..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/door_open.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/group.png b/de.fu_berlin.inf.dpp/icons/group.png deleted file mode 100644 index 7fb4e1f1e1cd6ee67d33ffd24f09ddd5c3478bec..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/group.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/ibb_connection.png b/de.fu_berlin.inf.dpp/icons/ibb_connection.png deleted file mode 100644 index db52b85a5f7fbe6258088192c264f1fcefb67c32..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/ibb_connection.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/invites.png b/de.fu_berlin.inf.dpp/icons/invites.png deleted file mode 100644 index 6f9a198bea5326d8c5b6cf4fcb864af496152377..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/invites.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/jingle_connection.png b/de.fu_berlin.inf.dpp/icons/jingle_connection.png deleted file mode 100644 index 9af2f636b0359af47c209c077ac8650ca1c44855..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/jingle_connection.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/monitor_add.png b/de.fu_berlin.inf.dpp/icons/monitor_add.png deleted file mode 100644 index a818066400860830a2e397c2f2a08039dd8284cb..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/monitor_add.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/monitor_delete.png b/de.fu_berlin.inf.dpp/icons/monitor_delete.png deleted file mode 100644 index 37332563f2418c8ec38dfb2191c6a2efff3983b3..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/monitor_delete.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/monitor_edit.png b/de.fu_berlin.inf.dpp/icons/monitor_edit.png deleted file mode 100644 index f772c562f4f5534cd81918f26d60ee96bb039511..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/monitor_edit.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/monitor_go.png b/de.fu_berlin.inf.dpp/icons/monitor_go.png deleted file mode 100644 index 8af3eda9f2db79939652cb5f81e045dee47c5395..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/monitor_go.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/monitor_lightning.png b/de.fu_berlin.inf.dpp/icons/monitor_lightning.png deleted file mode 100644 index 06e53a9d196cd92062583424247872d50b31255e..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/monitor_lightning.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/read_only.gif b/de.fu_berlin.inf.dpp/icons/read_only.gif deleted file mode 100644 index dde3cbd615033cbb942d8b088f917dfbd2e04894..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/read_only.gif and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/sample.gif b/de.fu_berlin.inf.dpp/icons/sample.gif deleted file mode 100644 index 34fb3c9d8cb7d489681b7f7aee4bdcd7eaf53610..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/sample.gif and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/start_invitation.png b/de.fu_berlin.inf.dpp/icons/start_invitation.png deleted file mode 100644 index 0def963e879544834c6b7746a9885056387ac83a..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/start_invitation.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/stop.gif b/de.fu_berlin.inf.dpp/icons/stop.gif deleted file mode 100644 index dc47edf06955eca15fee8118b3be43f019cae3f4..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/stop.gif and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/table_edit.png b/de.fu_berlin.inf.dpp/icons/table_edit.png deleted file mode 100644 index bfcb0249afde587618c63a1eaf776e7af2179f9c..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/table_edit.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/telephone.png b/de.fu_berlin.inf.dpp/icons/telephone.png deleted file mode 100644 index cecc436fbdcc58e9c40b9dc52112c89f3654cace..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/telephone.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/transmit.png b/de.fu_berlin.inf.dpp/icons/transmit.png deleted file mode 100644 index f54bf736cdc0d58a07c0a0171cc5a25b5e007e0e..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/transmit.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/transmit_add.png b/de.fu_berlin.inf.dpp/icons/transmit_add.png deleted file mode 100644 index b7fd4e685f6069f24879e9f0e381bc410832a85d..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/transmit_add.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/transmit_blue.png b/de.fu_berlin.inf.dpp/icons/transmit_blue.png deleted file mode 100644 index 7b1142fc70adfd598ce6eac581421d7e6295f370..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/transmit_blue.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/user.png b/de.fu_berlin.inf.dpp/icons/user.png deleted file mode 100644 index 79f35ccbdad44489dbf07d1bf688c411aa3b612c..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/user.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/user_add.png b/de.fu_berlin.inf.dpp/icons/user_add.png deleted file mode 100644 index deae99bcff9815d8530a920e754d743700ddd5fb..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/user_add.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/user_edit.png b/de.fu_berlin.inf.dpp/icons/user_edit.png deleted file mode 100644 index c1974cda745278a404b9e29fa91e0503a84accb1..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/user_edit.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/vcard_add.png b/de.fu_berlin.inf.dpp/icons/vcard_add.png deleted file mode 100644 index 2a68453811f26444e2d04da5713c9c757dc999c0..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/vcard_add.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/easymock.jar b/de.fu_berlin.inf.dpp/lib/easymock.jar deleted file mode 100644 index c4159f5a0a4c19d6afc89cbc271208acb8ba7dff..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/easymock.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/junit.jar b/de.fu_berlin.inf.dpp/lib/junit.jar deleted file mode 100644 index 674d71e89ea154dbe2e3cd032821c22b39e8fd68..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/junit.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/junitsrc.zip b/de.fu_berlin.inf.dpp/lib/junitsrc.zip deleted file mode 100644 index 88049093b58cdefdbd9f658e9efe0ea3538d4a79..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/junitsrc.zip and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/log4j-1.2.15.jar b/de.fu_berlin.inf.dpp/lib/log4j-1.2.15.jar deleted file mode 100644 index c930a6ab4d4b73c1a6feb9e929091205664bb340..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/log4j-1.2.15.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/smack.jar b/de.fu_berlin.inf.dpp/lib/smack.jar deleted file mode 100644 index 6bfc8f2594bf826a97518693afee3d8038023479..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/smack.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/smack_3.5.0.jar b/de.fu_berlin.inf.dpp/lib/smack_3.5.0.jar deleted file mode 100644 index dd1c891be13bb5c2f9ac5520170095a32e544bb4..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/smack_3.5.0.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/smackx-debug.jar b/de.fu_berlin.inf.dpp/lib/smackx-debug.jar deleted file mode 100644 index b3ac895f0653c8c39aeadac7744e22812ae45679..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/smackx-debug.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/smackx-debug_3.5.0.jar b/de.fu_berlin.inf.dpp/lib/smackx-debug_3.5.0.jar deleted file mode 100644 index fb462f075672b22b96b6b085b734fcdd10cb29a3..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/smackx-debug_3.5.0.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/smackx-jingle.jar b/de.fu_berlin.inf.dpp/lib/smackx-jingle.jar deleted file mode 100644 index c14af0a240944114eaebfcc17884f9f62ad48617..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/smackx-jingle.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/smackx-jingle_3.5.0.jar b/de.fu_berlin.inf.dpp/lib/smackx-jingle_3.5.0.jar deleted file mode 100644 index 03589c954ee9710c9c827b8d0c6c6cb55cda092f..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/smackx-jingle_3.5.0.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/smackx.jar b/de.fu_berlin.inf.dpp/lib/smackx.jar deleted file mode 100644 index 38b8e9122ebb447f5f58af610f30a1f31a46f7fe..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/smackx.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/smackx_3.5.0.jar b/de.fu_berlin.inf.dpp/lib/smackx_3.5.0.jar deleted file mode 100644 index 5c113886717795b6760a132dc00a85411c7ca5a8..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/smackx_3.5.0.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/log4j.properties b/de.fu_berlin.inf.dpp/log4j.properties deleted file mode 100644 index 4c96578a5b4808e1c550bfb6fb9d4db57f84f3aa..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/log4j.properties +++ /dev/null @@ -1,32 +0,0 @@ -log4j.rootLogger=WARN, MeinConsoleAppender, MeinDaRoFiAppender - -log4j.appender.MeinConsoleAppender=org.apache.log4j.ConsoleAppender -log4j.appender.MeinConsoleAppender.layout=org.apache.log4j.PatternLayout -log4j.appender.MeinConsoleAppender.layout.ConversionPattern=%-5p %d{yyyy-MM-dd : HH:mm:ss} (%F:%L) : %m%n -#log4j.appender.MeinConsoleAppender.layout.ConversionPattern=%-5p %d{yyyy-MM-dd : HH:mm:ss} %l %m%n -#log4j.appender.MeinConsoleAppender.layout.ConversionPattern=%-5p %d %l:%n%m%n -#log4j.appender.MeinConsoleAppender.layout.ConversionPattern=%d{MM-dd@HH:mm:ss} %-5p (%13F:%L) %3x - %m%n - -#log4j.appender.MeinDaRoFiAppender=org.apache.log4j.FileAppender -log4j.appender.MeinDaRoFiAppender=org.apache.log4j.RollingFileAppender -#log4j.appender.MeinDaRoFiAppender.datePattern='.'yyyy-MM-dd_HH-mm -log4j.appender.MeinDaRoFiAppender.file=Saros.log -log4j.appender.MeinDaRoFiAppender.Append=false -log4j.appender.MeinDaRoFiAppender.layout=org.apache.log4j.PatternLayout -log4j.appender.MeinDaRoFiAppender.layout.ConversionPattern=%-5p %d{yyyy-MM-dd : HH:mm:ss} (%F:%L) : %m%n -#log4j.appender.MeinDaRoFiAppender.layout.ConversionPattern=%-5p %d %l: %n%m%n - -log4j.logger.de.fu_berlin.inf.dpp=ERROR -log4j.logger.de.fu_berlin.inf.dpp.concurrent=WARN -log4j.logger.de.fu_berlin.inf.dpp.project.internal=ERROR -log4j.logger.de.fu_berlin.inf.dpp.invitation.internal=ERROR -log4j.logger.de.fu_berlin.inf.dpp.net=ERROR -log4j.logger.de.fu_berlin.inf.dpp.ui.ChatView=DEBUG -log4j.logger.de.fu_berlin.inf.dpp.util=ERROR -log4j.logger.de.fu_berlin.inf.dpp.net.internal=ERROR -log4j.logger.de.fu_berlin.inf.dpp.net.internal.XMPPChatTransmitter=INFO -log4j.logger.de.fu_berlin.inf.dpp.net.internal.MultiUserChatManager=DEBUG -log4j.logger.de.fu_berlin.inf.dpp.MessagingManager=DEBUG -log4j.logger.de.fu_berlin.inf.dpp.net.internal.ActivitySequencer=DEBUG -log4j.logger.de.fu_berlin.inf.dpp.net.internal.ExecuterQueue=INFO -log4j.logger.de.fu_berlin.inf.dpp.net.jingle=ERROR diff --git a/de.fu_berlin.inf.dpp/plugin.xml b/de.fu_berlin.inf.dpp/plugin.xml deleted file mode 100644 index fe8b2c30184abc40b91eb0376d4a667a25102dc1..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/plugin.xml +++ /dev/null @@ -1,392 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.0"?> -<plugin> - <extension - point="org.eclipse.ui.views"> - <category - id="Saros" - name="Saros"/> - <view - category="Saros" - class="de.fu_berlin.inf.dpp.ui.RosterView" - icon="icons/sample.gif" - id="de.fu_berlin.inf.dpp.ui.RosterView" - name="Roster"/> - <view - category="Saros" - class="de.fu_berlin.inf.dpp.ui.SessionView" - icon="icons/sample.gif" - id="de.fu_berlin.inf.dpp.ui.SessionView" - name="Saros Session"/> - <view - category="Saros" - class="de.fu_berlin.inf.dpp.ui.ChatView" - icon="icons/comment.png" - id="de.fu_berlin.inf.dpp.ui.ChatView" - name="Chat"/> - </extension> - <extension - point="org.eclipse.ui.perspectiveExtensions"> - <perspectiveExtension targetID="org.eclipse.ui.resourcePerspective"> - <view - id="de.fu_berlin.inf.dpp.ui.RosterView" - ratio="0.5" - relationship="right" - relative="org.eclipse.ui.views.TaskList"/> - </perspectiveExtension> - <perspectiveExtension targetID="org.eclipse.ui.resourcePerspective"> - <view - id="de.fu_berlin.inf.dpp.ui.SessionView" - ratio="0.5" - relationship="right" - relative="org.eclipse.ui.views.TaskList"/> - </perspectiveExtension> - </extension> - <extension - point="org.eclipse.ui.popupMenus"> - <objectContribution - adaptable="true" - id="de.fu_berlin.inf.dpp.ui.popupmenu" - objectClass="org.eclipse.core.resources.IResource"> - <menu - id="Saros.menu1" - label="Saros.menu1"/> - <action - class="de.fu_berlin.inf.dpp.ui.actions.NewSessionAction" - icon="icons/transmit.png" - id="Saros.action1" - label="Share project..."> - </action> - <visibility> - <or> - <objectClass name="org.eclipse.core.resources.IProject"/> - <objectClass name="org.eclipse.jdt.core.IJavaProject"/> - </or> - </visibility> - </objectContribution> - </extension> - <extension - point="org.eclipse.ui.decorators"> - <decorator - adaptable="true" - class="de.fu_berlin.inf.dpp.ui.decorators.SharedProjectDecorator" - id="de.fu_berlin.inf.dpp.ui.decorators.SharedProjectDecorator" - label="Shared Project Decorator" - lightweight="true" - state="true"> - <enablement> - <objectClass name="org.eclipse.core.resources.IFile"/> - </enablement> - </decorator> - </extension> - <extension - point="org.eclipse.ui.preferencePages"> - <page - class="de.fu_berlin.inf.dpp.ui.PreferencePage" - id="de.fu_berlin.inf.dpp.preferences" - name="Saros"/> - <page - category="de.fu_berlin.inf.dpp.preferences/" - class="de.fu_berlin.inf.dpp.ui.AdvancedPreferencePage" - id="de.fu_berlin.inf.dpp.preferences.advanced" - name="Advanced"/> - </extension> - <extension - point="org.eclipse.core.runtime.preferences"> - <initializer class="de.fu_berlin.inf.dpp.PreferenceInitializer"/> - </extension> - <extension - point="org.eclipse.ui.actionSets"> - <actionSet - id="de.fu_berlin.inf.dpp.actionSet" - label="Saros" - visible="true"> - <menu - id="de.fu_berlin.inf.dpp.menu" - label="Saros"> - <separator name="de.fu_berlin.inf.dpp.menu.group"/> - </menu> - <action - class="de.fu_berlin.inf.dpp.ui.actions.NewAccountAction" - icon="icons/vcard_add.png" - id="de.fu_berlin.inf.dpp.ui.actions.createAccountAction" - label="&Create Account" - menubarPath="de.fu_berlin.inf.dpp.menu/de.fu_berlin.inf.dpp.menu.group" - /> - </actionSet> - </extension> - <extension - point="org.eclipse.ui.editors.documentProviders"> - <provider - class="de.fu_berlin.inf.dpp.editor.internal.SharedDocumentProvider" - id="Saros.shared_document_provider" - inputTypes="org.eclipse.ui.IFileEditorInput"/> - </extension> - <extension - point="org.eclipse.ui.editors.annotationTypes"> - <type - markerType="de.fu_berlin.inf.dpp.annotations.viewport" - name="de.fu_berlin.inf.dpp.annotations.viewport"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.contribution" - name="de.fu_berlin.inf.dpp.annotations.contribution"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.contribution.1" - name="de.fu_berlin.inf.dpp.annotations.contribution.1"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.contribution.2" - name="de.fu_berlin.inf.dpp.annotations.contribution.2"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.contribution3" - name="de.fu_berlin.inf.dpp.annotations.contribution.3"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.contribution.4" - name="de.fu_berlin.inf.dpp.annotations.contribution.4"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.contribution.5" - name="de.fu_berlin.inf.dpp.annotations.contribution.5"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.selection.1" - name="de.fu_berlin.inf.dpp.annotations.selection.1"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.selection.2" - name="de.fu_berlin.inf.dpp.annotations.selection.2"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.selection.3" - name="de.fu_berlin.inf.dpp.annotations.selection.3"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.selection.4" - name="de.fu_berlin.inf.dpp.annotations.selection.4"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.selection.5" - name="de.fu_berlin.inf.dpp.annotations.selection.5"/> - </extension> - <extension - point="org.eclipse.ui.editors.markerAnnotationSpecification"> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.viewport" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.viewport.color" - colorPreferenceValue="0,255,0" - contributesToHeader="true" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.viewport.highlight" - highlightPreferenceValue="false" - includeOnPreferencePage="true" - label="DPP Viewport" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.viewport.overview" - overviewRulerPreferenceValue="true" - presentationLayer="8" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.viewport.text" - textPreferenceValue="false" - textStylePreferenceValue="NONE" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.viewport.ruler" - verticalRulerPreferenceValue="true"/> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.contribution" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.color" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.highlight" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.overview" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.text" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.textstyle" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.ruler" - colorPreferenceValue="138,165,189" - contributesToHeader="false" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP User" - overviewRulerPreferenceValue="false" - presentationLayer="7" - textPreferenceValue="true" - textStylePreferenceValue="NONE" - verticalRulerPreferenceValue="false"/> - - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.contribution.1" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.color.1" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.highlight.1" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.overview.1" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.text.1" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.textstyle.1" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.ruler.1" - colorPreferenceValue="255,0,0" - contributesToHeader="false" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP User" - overviewRulerPreferenceValue="false" - presentationLayer="7" - textPreferenceValue="true" - textStylePreferenceValue="UNDERLINE" - verticalRulerPreferenceValue="false"/> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.contribution.2" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.color.2" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.highlight.2" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.overview.2" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.text.2" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.textstyle.2" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.ruler.2" - colorPreferenceValue="0,255,0" - contributesToHeader="false" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP User" - overviewRulerPreferenceValue="false" - presentationLayer="7" - textPreferenceValue="true" - textStylePreferenceValue="UNDERLINE" - verticalRulerPreferenceValue="false"/> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.contribution.3" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.color.3" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.highlight.3" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.overview.3" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.text.3" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.textstyle.3" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.ruler.3" - colorPreferenceValue="0,0,255" - contributesToHeader="false" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP User" - overviewRulerPreferenceValue="false" - presentationLayer="7" - textPreferenceValue="true" - textStylePreferenceValue="UNDERLINE" - verticalRulerPreferenceValue="false"/> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.contribution.4" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.color.4" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.highlight.4" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.overview.4" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.text.4" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.textstyle.4" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.ruler.4" - colorPreferenceValue="255,255,0" - contributesToHeader="false" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP User" - overviewRulerPreferenceValue="false" - presentationLayer="7" - textPreferenceValue="true" - textStylePreferenceValue="UNDERLINE" - verticalRulerPreferenceValue="false"/> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.contribution.5" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.color.5" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.highlight.5" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.overview.5" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.text.5" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.textstyle.5" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.ruler.5" - colorPreferenceValue="0,255,255" - contributesToHeader="false" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP User" - overviewRulerPreferenceValue="false" - presentationLayer="7" - textPreferenceValue="true" - textStylePreferenceValue="UNDERLINE" - verticalRulerPreferenceValue="false"/> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.selection.1" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.color.1" - colorPreferenceValue="255,0,0" - contributesToHeader="false" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.highlight.1" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP Selection of remote user 1" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.overview.1" - overviewRulerPreferenceValue="true" - presentationLayer="8" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.text.1" - textPreferenceValue="true" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.textstyle.1" - textStylePreferenceValue="BOX" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.ruler.1" - verticalRulerPreferenceValue="false"/> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.selection.2" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.color.2" - colorPreferenceValue="0,255,0" - contributesToHeader="false" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.highlight.2" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP Selection of remote user 2" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.overview.2" - overviewRulerPreferenceValue="true" - presentationLayer="8" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.text.2" - textPreferenceValue="true" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.textstyle.2" - textStylePreferenceValue="BOX" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.ruler.2" - verticalRulerPreferenceValue="false"/> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.selection.3" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.color.3" - colorPreferenceValue="0,0,255" - contributesToHeader="false" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.highlight.3" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP Selection of remote user 3" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.overview.3" - overviewRulerPreferenceValue="true" - presentationLayer="8" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.text.3" - textPreferenceValue="true" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.textstyle.3" - textStylePreferenceValue="BOX" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.ruler.3" - verticalRulerPreferenceValue="false"/> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.selection.4" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.color.4" - colorPreferenceValue="255,255,0" - contributesToHeader="false" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.highlight.4" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP Selection of remote user 4" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.overview.4" - overviewRulerPreferenceValue="true" - presentationLayer="8" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.text.4" - textPreferenceValue="true" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.textstyle.4" - textStylePreferenceValue="BOX" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.ruler.4" - verticalRulerPreferenceValue="false"/> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.selection.5" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.color.5" - colorPreferenceValue="0,255,255" - contributesToHeader="false" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.highlight.5" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP Selection of remote user 5" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.overview.5" - overviewRulerPreferenceValue="true" - presentationLayer="8" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.text.5" - textPreferenceValue="true" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.textstyle.5" - textStylePreferenceValue="BOX" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.ruler.5" - verticalRulerPreferenceValue="false"/> - - </extension> - <extension - id="de.fu_berlin.inf.dpp.modelProvider" - point="org.eclipse.core.resources.modelProviders"> - <modelProvider class="de.fu_berlin.inf.dpp.project.internal.SharedModelProvider"/> - <enablement> - <instanceof value="org.eclipse.core.resources.IResource"/> - </enablement> - </extension> -</plugin> diff --git a/de.fu_berlin.inf.dpp/readme.html b/de.fu_berlin.inf.dpp/readme.html deleted file mode 100644 index 4a4196df05a794fdd582d76f5e658c2d65add0c9..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/readme.html +++ /dev/null @@ -1,137 +0,0 @@ -<html> -<body> - -<h1>DPP Readme</h1> - -<h2>Installation</h2> - -<ol> - <li>Open the software updates manager (Help > Software Updates > Find - and Install...)</li> - <li>Select 'Search for new features to install' and click on next</li> - <li>Click on 'New Remote Site...'</li> - <li>Enter 'Saros' as name and 'http://riad.de/thesis/update' as URL</li> - <li>The new location should've been added to the list and be checked. Click - on 'Finish'</li> - <li>Check the plugin in the 'Search Results' and select 'Next'</li> - <li>Accept the license agreement and select 'Next'</li> - <li>In the next window select 'Finish' to start installation</li> - <li>Select 'Install' on the Feature Verification</li> - <li>Select 'Yes' when you're asked to restart</li> -</ol> - -<h2>Limitations</h2> - -The following limitations need to be considered as of version 0.6.1 - -<ul> - <li>Sessions can only have one participant (besides the host).</li> - <li>Sometimes files are transmitted with wrong line delimiters, which results in - different checksums for files when checking them for identicalness.</li> -</ul> - -<h2>Connecting to a server</h2> - -You need a Jabber account to use Saros. You can create a new account from Saros -if you don't already have one. - -<h3>Creating a new account</h3> - -<ol> - <li>Open the Roster View (Select it from Window > Show View > - Other... > Roster)</li> - <li>Click on the second button on the Roster toolbar</li> - <li>Fill the fields (you can use jabber.org as a Jabber server)</li> - <li>Check the 'Store the new configuration in your preferences'</li> - <li>Select 'Finish'</li> -</ol> - -<h3>Using an existing account</h3> - -<ol> - <li>Open the preferences window (Window > Preferences...).</li> - <li>Select the 'Saros' category.</li> - <li>Enter your account data.</li> -</ol> - -To connect select the Roster View (Menu > Window > Show View > -Other... > Roster). Click on the connect button (1st button in the local -toolbar). The button will always show you, your current connection status. You -also see the status line of the Roster View for more detailed information. - -By default you will have to click the button to connect, but you in the Saros -preferences, you will also find the option to automatically connect on startup. -When you're connected your contacts will be loaded from the server and shown in -the roster viewer. - -<h2>Beginning a shared project sessions</h2> - -<h3>Hosting a shared project session</h3> - -<ol> - <li>Right-Click on a project in your resource navigator (or package navigator) - and select 'Share project...' from the context menu.</li> - <li>Now you see the 'Shared Project Session' viewer and yourself as - only participant.</li> - <li>To invite other users, select the 'Roster' viewer again.</li> - <li>Right-click on a user and select 'Invite user to shared project...'</li> -</ol> - -<h3>Joining a running shared project session</h3> - -To join a running shared project session you need to be invited by a -participant of that session (see above). - -<ol> - <li>If you're invited a wizard dialog will appear on your screen, stating - who the inviter is and an additional short description. Select 'Next' if you - want to accept the invitation.</li> - <li>Before being able to work on the shared project it needs to be fully - replicated to your system. You can accelerate this process by providing a local - project which will be used as base for the synchronization between your - system and the remotely shared project. Select the project from the list - which has the highest value in parentheses. The value states the identicalness - of the local project and the remotely shared project. The higher the number, - the less synchronization will be needed before starting the session.</li> - <li>Select wether you would like to overwrite your local project or to create - a new project. Practically this will create a new project, which contains all - files of your chosen base project.</li> - <li>Select 'Finish'.</li> -</ol> - -<h2>Using a shared project session</h2> - -Only the driver is allowed to edit the resources in the shared project. -There can only be one driver at any time. When starting a shared project -session the host is automatically the driver. - -When the driver opens a file, a small green dot will decorate the resource in the -navigator. This mark always shows the latest resource that the driver is using -or has used. - -<h3>Replicated actions</h3> - -The following types of actions are currently supported and replicated in real time.. - -<ul> - <li>Text changes</li> - <li>Cursor positions and selections</li> - <li>File additions/removals</li> -</ul> - -<h3>Changing the user role</h3> - -There are two ways to change the owner of the driver role. - -<ul> - <li>If you're the current driver or host of the session, you can give the - driver role to another user. To do this select a user in the 'Shared - Project Session' viewer and select 'Give driver role' from the context - menu.</li> - <li>If you're the host of the session, you can take back the driver role - at every moment. Select the 'Take driver role' button from the session - viewer.</li> -</ul> - -</body> -</html> diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/FileList.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/FileList.java deleted file mode 100644 index 47d1da08870ab3a076054f31705b450bf79f19e7..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/FileList.java +++ /dev/null @@ -1,368 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp; - -import java.io.IOException; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.xmlpull.mxp1.MXParser; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - -import de.fu_berlin.inf.dpp.util.FileUtil; - -/** - * A FileList is a list of resources - files and folders - which can be compared - * to other file lists. Folders are denoted by a trailing separator. - * - * @author rdjemili - */ -public class FileList { - private Map<IPath, Long> all = new HashMap<IPath, Long>(); - - private Map<IPath, Long> added = new HashMap<IPath, Long>(); - - private Map<IPath, Long> removed = new HashMap<IPath, Long>(); - - private Map<IPath, Long> altered = new HashMap<IPath, Long>(); - - private Map<IPath, Long> unaltered = new HashMap<IPath, Long>(); - - private Comparator<IPath> comparator = new PathLengthComprarator(); - - private class PathLengthComprarator implements Comparator<IPath> { - /* - * (non-Javadoc) - * - * @see java.util.Comparator - */ - public int compare(IPath p1, IPath p2) { - int l1 = p1.toString().length(); - int l2 = p2.toString().length(); - - if (l1 < l2) - return -1; - else if (l1 > l2) - return 1; - else - return 0; - } - } - - /** - * Creates an empty file list. - */ - public FileList() { - } - - /** - * Creates a new file list from the file tree in given container. - * - * @param container - * the resource container that should be represented by the new - * file list. - * @throws CoreException - * exception that might happen while fetching the files from the - * given container. - */ - public FileList(IContainer container) throws CoreException { - container.refreshLocal(IResource.DEPTH_INFINITE, null); - addMembers(container.members(), all, true); - unaltered.putAll(all); - } - - /** - * Creates a new file list from the file tree in given container. - * - * @param container - * the resource container that should be represented by the new - * file list. - * @param ignoreDerived - * <code>true</code> if derived resources should be ignored. - * @throws CoreException - * exception that might happen while fetching the files from the - * given container. - */ - public FileList(IContainer container, boolean ignoreDerived) throws CoreException { - - container.refreshLocal(IResource.DEPTH_INFINITE, null); - addMembers(container.members(), all, ignoreDerived); - unaltered.putAll(all); - } - - /** - * Creates a new file list from given resources. - * - * @param resources - * the resources that should be added to this file list. - * @throws CoreException - */ - public FileList(IResource[] resources) throws CoreException { - - addMembers(resources, all, false); - unaltered.putAll(all); - } - - /** - * Build the FileList from its XML representation. - * - * @throws XmlPullParserException - * @throws IOException - */ - public FileList(String xml) throws XmlPullParserException, IOException { - MXParser parser = new MXParser(); - parser.setInput(new StringReader(xml)); - - Map<IPath, Long> context = added; - - boolean done = false; - while (!done) { - int eventType = parser.next(); - if (eventType == XmlPullParser.START_TAG) { - - if (parser.getName().equals("added")) { - context = added; - - } else if (parser.getName().equals("removed")) { - context = removed; - - } else if (parser.getName().equals("altered")) { - context = altered; - - } else if (parser.getName().equals("unaltered")) { - context = unaltered; - - } else if (parser.getName().equals("file")) { - IPath path = new Path(parser.getAttributeValue(null, "path")); - Long checksum = Long.parseLong(parser.getAttributeValue(null, "checksum")); - - context.put(path, checksum); - - if (context != removed) - all.put(path, checksum); - - } else if (parser.getName().equals("folder")) { - IPath path = new Path(parser.getAttributeValue(null, "path")); - - context.put(path, null); - - if (context != removed) - all.put(path, null); - } - - } else if (eventType == XmlPullParser.END_TAG) { - if (parser.getName().equals("filelist")) { - done = true; - } - } - } - } - - // TODO invert diff direction - /** - * Returns a new FileList which contains the diff from the two FileLists. - * - * @param other - * the other FileList with which this FileList is compared with. - * - * @return a new FileList which contains the diff information from the two - * FileLists. The diff contains the operations which are needed to - * get from this FileList to the other FileList. - */ - public FileList diff(FileList other) { - FileList fileList = new FileList(); - - for (Map.Entry<IPath, Long> entry : all.entrySet()) { - if (!other.all.containsKey(entry.getKey())) { - fileList.removed.put(entry.getKey(), entry.getValue()); - } - } - - for (Map.Entry<IPath, Long> entry : other.all.entrySet()) { - if (!all.containsKey(entry.getKey())) { - fileList.added.put(entry.getKey(), entry.getValue()); - } - } - - for (Map.Entry<IPath, Long> entry : all.entrySet()) { - IPath path = entry.getKey(); - if (other.all.containsKey(path)) { - - if (path.hasTrailingSeparator()) { - fileList.unaltered.put(path, null); - - } else { - long checksum = entry.getValue(); - long otherChecksum = other.all.get(path); - - if (checksum == otherChecksum) { - fileList.unaltered.put(path, checksum); - } else { - fileList.altered.put(path, checksum); - } - } - - } - } - - fileList.all = new HashMap<IPath, Long>(other.all); - return fileList; - } - - /** - * @return the amount in percentage by which this file list has the same - * files as the other filelist. - */ - public int match(FileList other) { - return getPaths().size() == 0 ? 0 : 100 * diff(other).getUnalteredPaths().size() - / getPaths().size(); - } - - /** - * @return a sorted list of all paths in this file list. The paths are - * sorted by their character length. - */ - public List<IPath> getPaths() { - return sorted(all.keySet()); - } - - public List<IPath> getAddedPaths() { - return sorted(added.keySet()); - } - - public List<IPath> getRemovedPaths() { - return sorted(removed.keySet()); - } - - public List<IPath> getAlteredPaths() { - return sorted(altered.keySet()); - } - - public List<IPath> getUnalteredPaths() { - return sorted(unaltered.keySet()); - } - - /** - * @return the XML representation of this FileList. You can use the returned - * string to construct the same file list again. - */ - public String toXML() { - StringBuilder sb = new StringBuilder(); - sb.append("<filelist>"); - - appendFileGroup(sb, "added", added); - appendFileGroup(sb, "removed", removed); - appendFileGroup(sb, "altered", altered); - appendFileGroup(sb, "unaltered", unaltered); - - sb.append("</filelist>"); - - return sb.toString(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - - if (!(obj instanceof FileList)) - return false; - - FileList other = (FileList) obj; - return all.equals(other.all) && added.equals(other.added) && removed.equals(other.removed) - && altered.equals(other.altered) && unaltered.equals(other.unaltered); - } - - @Override - public String toString() { - return "FileList(files:" + all.size() + ")"; - } - - private List<IPath> sorted(Set<IPath> pathSet) { - List<IPath> paths = new ArrayList<IPath>(pathSet); - Collections.sort(paths, comparator); - return paths; - } - - private void addMembers(IResource[] resources, Map<IPath, Long> members, boolean ignoreDerived) - throws CoreException { - - for (int i = 0; i < resources.length; i++) { - if (ignoreDerived && resources[i].isDerived()) - continue; - - if (resources[i] instanceof IFile) { - IFile file = (IFile) resources[i]; - if (file.exists()==false) - continue; - - Long checksum=FileUtil.checksum(file); - if (checksum!=-1) - members.put(file.getProjectRelativePath(), checksum); - - } else if (resources[i] instanceof IFolder) { - IFolder folder = (IFolder) resources[i]; - - IPath path = folder.getProjectRelativePath(); - if (!path.hasTrailingSeparator()) - path = path.addTrailingSeparator(); - - members.put(path, null); - addMembers(folder.members(), members, ignoreDerived); - } - } - } - - private void appendFileGroup(StringBuilder sb, String element, Map<IPath, Long> map) { - - if (map.size() == 0) - return; - - sb.append('<').append(element).append('>'); - for (Map.Entry<IPath, Long> entry : map.entrySet()) { - IPath path = entry.getKey(); - - if (path.hasTrailingSeparator()) { - sb.append("<folder path=\"").append(path).append("\"/>"); - - } else { - long checksum = entry.getValue(); - sb.append("<file path=\"").append(path).append("\" "); - sb.append("checksum=\"").append(checksum).append("\"/>"); - } - - } - sb.append("</").append(element).append('>'); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/MessagingManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/MessagingManager.java deleted file mode 100644 index d7b8ff8330012bd07b7e293ae4ae70c31cb4e4e8..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/MessagingManager.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import org.apache.log4j.Logger; -import org.jivesoftware.smack.PacketListener; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.filter.MessageTypeFilter; -import org.jivesoftware.smack.packet.Message; -import org.jivesoftware.smack.packet.Packet; -import org.jivesoftware.smackx.muc.MultiUserChat; - -import de.fu_berlin.inf.dpp.Saros.ConnectionState; -import de.fu_berlin.inf.dpp.net.IConnectionListener; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.net.internal.MultiUserChatManager; -import de.fu_berlin.inf.dpp.ui.ChatView; - -/** - * MessagingManager handles all instant messaging related communications. - * - * @author rdjemili,chjacob(chris_fu) - */ -public class MessagingManager implements PacketListener, IConnectionListener { - - private static Logger log = Logger.getLogger(MessagingManager.class - .getName()); - - private MultiUserChatManager multitrans = null; - private String CHAT_ROOM = "saros"; - private MultiChatSession session; - - // TODO Use ListenerList - private List<IChatListener> chatListeners = new ArrayList<IChatListener>(); - - public class ChatLine { - public String sender; - public String text; - public Date date; - public String packedID; - } - - public MultiChatSession getSession() { - return session; - } - - public class MultiChatSession implements PacketListener { - - private Logger logCH = Logger.getLogger(MultiChatSession.class - .getName()); - private String name; - private MultiUserChat muc; - private JID participant; - private List<ChatLine> history = new ArrayList<ChatLine>(); - private ChatView chatView; - - public MultiChatSession(MultiUserChat muc) { - this.muc = muc; - this.name = "Multi User Chat (" - + Saros.getDefault().getMyJID().getName() + ")"; - muc.addMessageListener(this); - } - - public String getName() { - return name; - } - - public List<ChatLine> getHistory() { - return history; - } - - /** - * @return the participant associated to the chat object. - */ - public JID getParticipant() { - return participant; - } - - public void processPacket(Packet packet) { - log.debug("processPacket called"); - - final Message message = (Message) packet; - - // log.debug("Received Message from " + message.getFrom() + ": " + - // message.getBody()); - - // // TODO Don't work ! - // IWorkbench workbench = PlatformUI.getWorkbench(); - // IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); - // IWorkbenchPage page = window.getActivePage(); - // try { - // log.debug("open chat view"); - // page.showView("de.fu_berlin.inf.dpp.ui.ChatView"); - // - // } catch (PartInitException e) { - // // TODO Auto-generated catch block - // e.printStackTrace(); - // } - - // notify chat listener - log.debug("Notify Listener.."); - for (IChatListener l : chatListeners) { - l.chatMessageAdded(message.getFrom(), message.getBody()); - log.debug("Notified Listener"); - } - - } - - /* - * @see de.fu_berlin.inf.dpp.MessagingManager.SessionProvider - */ - public void sendMessage(String text) { - try { - if (muc != null) { - Message msg = muc.createMessage(); - msg.setBody(text); - log.debug("Sending Message.."); - muc.sendMessage(msg); - } - } catch (XMPPException e1) { - e1.printStackTrace(); - addChatLine("error", "Couldn't send message"); - } - } - - private void addChatLine(String sender, String text) { - ChatLine chatLine = new ChatLine(); - chatLine.sender = sender; - chatLine.text = text; - chatLine.date = new Date(); - - history.add(chatLine); - - for (IChatListener chatListener : chatListeners) { - chatListener.chatMessageAdded(sender, text); - } - } - - } - - /** - * Listener for incoming chat messages. - */ - public interface IChatListener { - public void chatMessageAdded(String sender, String message); - } - - public MessagingManager() { - Saros.getDefault().addListener(this); - - this.multitrans = new MultiUserChatManager(CHAT_ROOM); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.IConnectionListener - */ - public void connectionStateChanged(XMPPConnection connection, - ConnectionState newState) { - if (connection != null && newState == ConnectionState.NOT_CONNECTED) - // connection.removePacketListener(this); - System.out.println("unconnect"); - - if (newState == ConnectionState.CONNECTED) { - connection.addPacketListener(this, new MessageTypeFilter( - Message.Type.chat)); - // initMultiChatListener(); - } - } - - /** - * Since all sessions already handle their incoming messages, this method is - * only to handle incoming chat messages for which no sessions have been yet - * created. If it finds a chat message that belongs to no current session, - * it creates a new session. - * - * @see org.jivesoftware.smack.PacketListener - */ - public void processPacket(Packet packet) { - log.debug("messagePacket called"); - final Message message = (Message) packet; - final JID jid = new JID(message.getFrom()); - - if (message.getBody() == null) - return; - else { - // TODO handle Messages with no session - } - - } - - /** - * Adds the chat listener. - */ - public void addChatListener(IChatListener listener) { - chatListeners.add(listener); - log.debug("Registered Chat Listener"); - } - - public void connectMultiUserChat() throws XMPPException { - - if (!Saros.getDefault().isConnected()) - throw new XMPPException("No connection "); - String user = Saros.getDefault().getConnection().getUser(); - if (session == null) { - MultiUserChat muc = multitrans.getMUC(); - if (muc == null) { - multitrans.initMUC(Saros.getDefault().getConnection(), user); - muc = multitrans.getMUC(); - } - log.debug("Creating MUC session.."); - session = new MultiChatSession(muc); - } else { - multitrans.getMUC().join(user); - } - } - - public void disconnectMultiUserChat() throws XMPPException { - log.debug("Leaving MUC session.."); - multitrans.getMUC().leave(); - // session = null; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/PreferenceConstants.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/PreferenceConstants.java deleted file mode 100644 index 9bb4124cec24deb6707a5ce95c13a6ab902e46fb..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/PreferenceConstants.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp; - -/** - * Constant definitions for plug-in preferences - * - * @author rdjemili - * @author coezbek - */ -public class PreferenceConstants { - - public static final String SERVER = "server"; - - public static final String USERNAME = "username"; - - public static final String PASSWORD = "password"; - - public static final String AUTO_CONNECT = "autoconnect"; - - public static final String AUTO_FOLLOW_MODE = "autofollowmode"; - - public static final String SKYPE_USERNAME = "skypename"; - - public static final String DEBUG = "debug"; - - public static final String FILE_TRANSFER_PORT = "port"; - - public static final String FORCE_FILETRANSFER_BY_CHAT = "chatfiletransfer"; - - public static final String CHATFILETRANSFER_CHUNKSIZE = "chatfiletransfer_chunksize"; - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/PreferenceInitializer.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/PreferenceInitializer.java deleted file mode 100644 index 75fee65ee7ae077593d4c6d77dd839b98283c8b9..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/PreferenceInitializer.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp; - -import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; -import org.eclipse.jface.preference.IPreferenceStore; - -/** - * Class used to initialize default preference values. - * - * @author rdjemili - */ -public class PreferenceInitializer extends AbstractPreferenceInitializer { - - /* - * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer - */ - public void initializeDefaultPreferences() { - IPreferenceStore store = Saros.getDefault().getPreferenceStore(); - store.setDefault(PreferenceConstants.SERVER, "jabber.org"); - store.setDefault(PreferenceConstants.USERNAME, ""); - store.setDefault(PreferenceConstants.PASSWORD, ""); - - store.setDefault(PreferenceConstants.AUTO_CONNECT, false); - store.setDefault(PreferenceConstants.AUTO_FOLLOW_MODE, true); - store.setDefault(PreferenceConstants.SKYPE_USERNAME, ""); - store.setDefault(PreferenceConstants.DEBUG, false); - store.setDefault(PreferenceConstants.FILE_TRANSFER_PORT, 7777); - store.setDefault(PreferenceConstants.FORCE_FILETRANSFER_BY_CHAT, false); - store.setDefault(PreferenceConstants.CHATFILETRANSFER_CHUNKSIZE, 50000); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/Saros.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/Saros.java deleted file mode 100644 index de6e691f1ea56d13519cbd1ab3ecba54048b3528..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/Saros.java +++ /dev/null @@ -1,569 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp; - -import java.awt.Toolkit; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.jivesoftware.smack.ConnectionConfiguration; -import org.jivesoftware.smack.ConnectionListener; -import org.jivesoftware.smack.Roster; -import org.jivesoftware.smack.RosterEntry; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.Roster.SubscriptionMode; -import org.osgi.framework.BundleContext; - -import de.fu_berlin.inf.dpp.net.IConnectionListener; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.net.internal.PacketExtensions; -import de.fu_berlin.inf.dpp.project.ActivityRegistry; -import de.fu_berlin.inf.dpp.project.ISessionManager; -import de.fu_berlin.inf.dpp.project.SessionManager; -import de.fu_berlin.inf.dpp.ui.SarosUI; -import de.fu_berlin.inf.dpp.ui.wizards.ConfigurationWizard; - - -/** - * The main plug-in of Saros. - * - * @author rdjemili - * @author coezbek - */ -public class Saros extends AbstractUIPlugin { - - public static enum ConnectionState { - NOT_CONNECTED, CONNECTING, CONNECTED, DISCONNECTING, ERROR - }; - - // The shared instance. - private static Saros plugin; - - public static final String SAROS = "de.fu_berlin.inf.dpp"; //$NON-NLS-1$ - - private static SarosUI uiInstance; - - private XMPPConnection connection; - - private JID myjid; - - private ConnectionState connectionState = ConnectionState.NOT_CONNECTED; - - private String connectionError; - - private MessagingManager messagingManager; - - private ISessionManager sessionManager; - - // TODO use ListenerList instead - private List<IConnectionListener> listeners = new CopyOnWriteArrayList<IConnectionListener>(); - - // Smack (XMPP) connection listener - private ConnectionListener smackConnectionListener = new XMPPConnectionListener(); - - static { - PacketExtensions.hookExtensionProviders(); - Roster.setDefaultSubscriptionMode(SubscriptionMode.accept_all); - } - - /** - * Create the shared instance. - */ - public Saros() { - plugin = this; - } - - /** - * This method is called upon plug-in activation - */ - public void start(BundleContext context) throws Exception { - super.start(context); - XMPPConnection.DEBUG_ENABLED = getPreferenceStore().getBoolean(PreferenceConstants.DEBUG); - - setupLoggers(); - - messagingManager = new MessagingManager(); - sessionManager = new SessionManager(); - - ActivityRegistry.getDefault(); - SkypeManager.getDefault(); - - uiInstance = new SarosUI(sessionManager); - - boolean hasUserName = getPreferenceStore().getString(PreferenceConstants.USERNAME).length() > 0; - - if (getPreferenceStore().getBoolean(PreferenceConstants.AUTO_CONNECT) && hasUserName) { - asyncConnect(); - } - - if (!hasUserName){ - - Display.getDefault().asyncExec(new Runnable() { - public void run() { - try { - Shell shell = Display.getDefault().getActiveShell(); - new WizardDialog(shell, new ConfigurationWizard()).open(); - } catch (Exception e) { - Saros.getDefault().getLog().log( - new Status(IStatus.ERROR, Saros.SAROS, IStatus.ERROR, - "Error while running configuration wizard", e)); - } - } - }); - } - } - - /** - * This method is called when the plug-in is stopped - */ - public void stop(BundleContext context) throws Exception { - super.stop(context); - - sessionManager.leaveSession(); - disconnect(null); - - plugin = null; - } - - /** - * Returns the shared instance. - * - * @return the shared instance. - */ - public static Saros getDefault() { - return plugin; - } - - public JID getMyJID() { - return myjid; - } - - public SarosUI getUI() { // HACK - return uiInstance; - } - - public Roster getRoster() { - if (!isConnected()) - return null; - - return connection.getRoster(); - } - - /** - * @return the MessagingManager which is responsible for handling instant - * messaging. Is never <code>null</code>. - */ - public MessagingManager getMessagingManager() { - return messagingManager; - } - - /** - * @return the SessionManager. Is never <code>null</code>. - */ - public ISessionManager getSessionManager() { - return sessionManager; - } - - public void asyncConnect() { - new Thread(new Runnable() { - public void run() { - connect(false); - } - }).start(); - } - - /** - * Connects according to the preferences. This is a blocking method. - * - * If there is already a established connection when calling this method, it - * disconnects before connecting. - */ - public void connect(boolean reconnect) { - - IPreferenceStore prefStore = getPreferenceStore(); - final String server = prefStore.getString(PreferenceConstants.SERVER); - final String username = prefStore.getString(PreferenceConstants.USERNAME); - String password = prefStore.getString(PreferenceConstants.PASSWORD); - - try { - if (!reconnect) { - if (isConnected()) - disconnect(null); - //TODO:Debug -// setConnectionState(ConnectionState.CONNECTING, null); - } else if (isConnected()) { -// connection.close(); - connection.disconnect(); - connection.removeConnectionListener(smackConnectionListener); - } - - //TODO: for testing reconnection - ConnectionConfiguration conConfig = new ConnectionConfiguration(server); - conConfig.setReconnectionAllowed(true); - -// connection = new XMPPConnection(server); - connection = new XMPPConnection(conConfig); - connection.connect(); - connection.login(username, password); - - - - //TODO: ConnectionListener - connection.addConnectionListener(smackConnectionListener); - setConnectionState(ConnectionState.CONNECTED, null); - - myjid=new JID(connection.getUser()); - - - } catch (final Exception e) { - //disconnect(e.getMessage()); - - if (!reconnect){ - setConnectionState(ConnectionState.NOT_CONNECTED, null); - Display.getDefault().syncExec(new Runnable() { - public void run() { - MessageDialog.openError(Display.getDefault().getActiveShell(), - "Error Connecting", "Could not connect to server '" + server - + "' as user '" + username + "'.\nErrorMessage was: " + e.getMessage()); - } - }); - } - } - } - - - - /** - * Disconnects. This is a blocking method. - * - * @param reason - * the error why the connection was closed. If the connection was - * not closed due to an error <code>null</code> should be - * passed. - */ - public void disconnect(String error) { - setConnectionState(ConnectionState.DISCONNECTING, error); - - if (connection != null) { - // leave running session before disconnecting - getSessionManager().leaveSession(); - - connection.removeConnectionListener(smackConnectionListener); -// connection.close(); - //TODO: Änderung für Smack 3 - connection.disconnect(); - connection = null; - } - - setConnectionState(error == null ? ConnectionState.NOT_CONNECTED : ConnectionState.ERROR, - error); - - myjid=null; - - } - - /** - * Creates the given account on the given Jabber server. This is a blocking - * method. - * - * @param server - * the server on which to create the account. - * @param username - * the username for the new account. - * @param password - * the password for the new account. - * @param monitor - * the progressmonitor for the operation. - * @throws XMPPException - * exception that occcurs while registering. - */ - public void createAccount(String server, String username, String password, - IProgressMonitor monitor) throws XMPPException { - - monitor.beginTask("Registering account", 3); - - XMPPConnection connection = new XMPPConnection(server); - monitor.worked(1); - - connection.connect(); - monitor.worked(1); - - connection.getAccountManager().createAccount(username, password); - monitor.worked(1); - -// connection.close(); - //TODO: Änderung für Smack 3 - connection.disconnect(); - monitor.done(); - } - - /** - * Adds given contact to the roster. This is a blocking method. - * - * @param jid - * the Jabber ID of the contact. - * @param nickname - * the nickname under which the new contact should appear in the - * roster. - * @param groups - * the groups to which the new contact should belong to. This - * information will be saved on the server. - * @throws XMPPException - * is thrown if no connection is establised. - */ - public void addContact(JID jid, String nickname, String[] groups) throws XMPPException { - assertConnection(); - connection.getRoster().createEntry(jid.toString(), nickname, groups); - } - - /** - * Removes given contact from the roster. This is a blocking method. - * - * @param rosterEntry - * the contact that is to be removed - * @throws XMPPException - * is thrown if no connection is establised. - */ - public void removeContact(RosterEntry rosterEntry) throws XMPPException { - assertConnection(); - connection.getRoster().removeEntry(rosterEntry); - } - - public boolean isConnected() { -// -// new Thread(new Runnable() { -// public void run() { -// int counter = 0; -// while(counter < 30){ -// if(connection != null && connection.isConnected()){ -// System.out.println("."); -// } -// else{ -// System.out.println("-"); -// } -// try { -// Thread.sleep(1000); -// } catch (InterruptedException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// counter++; -// } -// } -// }).start(); -// -// System.out.println("reconnect enable: "+connection.isConnected()); -// connection.disconnect(); - return connection != null && connection.isConnected(); - } - - /** - * @return the current state of the connection. - */ - public ConnectionState getConnectionState() { - return connectionState; - } - - /** - * @return an error string that contains the error message for the current - * connection error if the state is {@link ConnectionState.ERROR} or - * <code>null</code> if there is another state set. - */ - public String getConnectionError() { - return connectionError; - } - - /** - * @return the currently established connection or <code>null</code> if - * there is none. - */ - public XMPPConnection getConnection() { - return connection; - } - - public void addListener(IConnectionListener listener) { - if (!listeners.contains(listener)) { - listeners.add(listener); - } - } - - public void removeListener(IConnectionListener listener) { - listeners.remove(listener); - } - - private void assertConnection() throws XMPPException { - if (!isConnected()) - throw new XMPPException("No connection"); - } - - /** - * Sets a new connection state and notifies all connection listeners. - */ - private void setConnectionState(ConnectionState state, String error) { - connectionState = state; - connectionError = error; - - for (IConnectionListener listener : listeners) { - listener.connectionStateChanged(connection, state); - } - } - - private void setupLoggers() { - try { - - PropertyConfigurator.configureAndWatch("log4j.properties", 60 * 1000); - Logger logger = Logger.getLogger("de.fu_berlin.inf.dpp"); - -// Logger sarosRootLogger = Logger.getLogger("de.fu_berlin.inf.dpp"); -// sarosRootLogger.setLevel(Level.ALL); - -// Handler handler = new FileHandler("saros.log", 10 * 1024 * 1024, 1, true); -// Handler handler = new ConsoleHandler(); -// handler.setFormatter(new SimpleFormatter()); -// sarosRootLogger.addHandler(handler); - -// handler = new ConsoleHandler(); -// sarosRootLogger.addHandler(handler); - - } catch (SecurityException e) { - e.printStackTrace(); - } -// catch (IOException e) { -// e.printStackTrace(); -// } - } - - /** - * Log a message to the Eclipse ErrorLog. This method should be used to log - * all errors that occur in the plugin that cannot be corrected by the user - * and seem to be errors within the plug-in or the used libraries. - * - * @param message - * A meaningful description of during which operation the error - * occurred - * @param e - * The exception associated with the error (may be null) - */ - public static void log(String message, Exception e) { - Saros.getDefault().getLog().log( - new Status(IStatus.ERROR, Saros.SAROS, IStatus.ERROR, message, e)); - } - - private class XMPPConnectionListener implements ConnectionListener { - - // Variables to support listener notifications verification - private boolean connectionClosed = false; - private boolean connectionClosedOnError = false; - private boolean reconnected = false; - private boolean reconnectionFailed = false; - private int remainingSeconds = 0; - private int attemptsNotifications = 0; - private boolean reconnectionCanceled = false; - - public void connectionClosed() { - - // self inflicted, controlled disconnect - connectionClosed = true; - } - - public void connectionClosedOnError(Exception e) { - - connectionClosedOnError = true; - - Toolkit.getDefaultToolkit().beep(); - System.out.println("XMPP Connection Error: "+e.toString()); - - if (connection != null) { - connection.removeConnectionListener(smackConnectionListener); - connection.disconnect(); - //TODO: Änderung -// connection.close(); - } - - if (getConnectionState()!=ConnectionState.ERROR) { - setConnectionState(ConnectionState.ERROR, "XMPP Connection Error"); - - new Thread(new Runnable() { - - public void run() { - - int offlineAtTS = 0; - if (sessionManager.getSharedProject()!=null) - offlineAtTS = sessionManager.getSharedProject().getSequencer().getTimestamp(); - - try { - do { - connect(true); - - if (!connection.isConnected()) - Thread.sleep(5000); - - } while (!connection.isConnected()); - - if (connection.isConnected()) { - sessionManager.OnReconnect(offlineAtTS); - System.out.println("XMPP reconnected"); - } - - } catch (InterruptedException e) { - - e.printStackTrace(); - } - } - }).start(); - - } - - } - - public void reconnectingIn(int seconds) { - // TODO Auto-generated method stub - System.out.println("saros reconnectingIn"); - attemptsNotifications = attemptsNotifications + 1; - remainingSeconds = seconds; - } - - public void reconnectionFailed(Exception e) { - // TODO Auto-generated method stub - System.out.println("saros reconnectionFailed"); - reconnectionFailed = true; - } - - public void reconnectionSuccessful() { - // TODO Auto-generated method stub - System.out.println("saros reconnectionSuccessful"); - reconnected = true; - } - } - - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/SkypeManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/SkypeManager.java deleted file mode 100644 index 74b3b3d6c305341f9ed6d9ca9dcb1d3bdb423d99..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/SkypeManager.java +++ /dev/null @@ -1,146 +0,0 @@ -package de.fu_berlin.inf.dpp; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.jivesoftware.smack.PacketCollector; -import org.jivesoftware.smack.PacketListener; -import org.jivesoftware.smack.RosterEntry; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.filter.IQTypeFilter; -import org.jivesoftware.smack.filter.PacketIDFilter; -import org.jivesoftware.smack.packet.IQ; -import org.jivesoftware.smack.packet.Packet; -import org.jivesoftware.smack.provider.ProviderManager; - -import de.fu_berlin.inf.dpp.Saros.ConnectionState; -import de.fu_berlin.inf.dpp.net.IConnectionListener; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.net.internal.SkypeIQ; - -/** - * A manager class that allows to discover if a given XMPP entity supports Skype - * and that allows to initiate Skype VOiP sessions with that entity. - * - * @author rdjemili - */ -public class SkypeManager implements IConnectionListener { - private static SkypeManager instance; - - private Map<JID, String> skypeNames = new HashMap<JID, String>(); - - private SkypeManager() { - Saros.getDefault().addListener(this); - //TODO: Änderung für Smack 3 - ProviderManager providermanager = ProviderManager.getInstance(); - providermanager.addIQProvider("query", "jabber:iq:skype", SkypeIQ.class); -// ProviderManager.addIQProvider("query", "jabber:iq:skype", SkypeIQ.class); - } - - public static SkypeManager getDefault() { - if (instance == null) - instance = new SkypeManager(); - - return instance; - } - - /** - * Returns the Skype-URL for given roster entry. - * - * @return the skype url for given roster entry or <code>null</code> if - * roster entry has no skype name. - */ - public String getSkypeURL(RosterEntry rosterEntry) { - XMPPConnection connection = Saros.getDefault().getConnection(); - JID jid = new JID(rosterEntry.getUser()); - - String name; - if (skypeNames.containsKey(jid)) { - name = skypeNames.get(jid); - - } else { - name = requestSkypeName(connection, jid); - skypeNames.put(jid, name); - } - - return name == null ? null : "skype:" + name; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.IConnectionListener - */ - public void connectionStateChanged(final XMPPConnection connection, ConnectionState newState) { - - if (newState == ConnectionState.CONNECTED) { - connection.addPacketListener(new PacketListener() { - - /* - * (non-Javadoc) - * - * @see org.jivesoftware.smack.PacketListener - */ - public void processPacket(Packet packet) { - if (packet instanceof SkypeIQ) { - SkypeIQ iq = (SkypeIQ) packet; - - SkypeIQ result = new SkypeIQ(); - result.setType(IQ.Type.RESULT); - result.setPacketID(iq.getPacketID()); - result.setTo(iq.getFrom()); // HACK - result.setName(getLocalSkypeName()); - - connection.sendPacket(result); - } - } - }, new IQTypeFilter(IQ.Type.GET)); - } - } - - /** - * @return the local skype name or <code>null</code> if none is set. - */ - private String getLocalSkypeName() { - IPreferenceStore prefs = Saros.getDefault().getPreferenceStore(); - return prefs.getString(PreferenceConstants.SKYPE_USERNAME); - } - - /** - * Requests the Skype user name of given user. This method blocks up to 5 - * seconds to receive the value. - * - * @param connection - * @param user - * the user for which the Skype name is requested. - * @return the Skype user name of given user or <code>null</code> if the - * user doesn't respond in time or has no Skype name. - */ - private static String requestSkypeName(XMPPConnection connection, JID user) { - if (connection == null || !connection.isConnected()) - return null; - - // Request the time from a remote user. - SkypeIQ request = new SkypeIQ(); - - request.setType(IQ.Type.GET); - request.setTo(user.toString() + "/Smack"); // HACK - - // Create a packet collector to listen for a response. - PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(request - .getPacketID())); - - connection.sendPacket(request); - - // Wait up to 5 seconds for a result. - IQ result = (IQ) collector.nextResult(5000); - if (result != null && result.getType() == IQ.Type.RESULT) { - SkypeIQ skypeResult = (SkypeIQ) result; - - return skypeResult.getName().length() == 0 ? null : skypeResult.getName(); - } - - return null; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/User.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/User.java deleted file mode 100644 index 1ad06e97e681b6d55e3d59ac925c2bf4d041428d..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/User.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp; - -import de.fu_berlin.inf.dpp.net.JID; - - -public class User { - public enum UserConnectionState {UNKNOWN,ONLINE,OFFLINE}; - public enum UserRole {DRIVER,OBSERVER}; - private UserConnectionState presence = UserConnectionState.UNKNOWN; - - private JID jid; - private int colorid=0; - private long offlineTime=0; - private UserRole role = UserRole.OBSERVER; - - public User(JID jid) { - this.jid = jid; - } - - public JID getJid() { - return jid; - } - - /** - * set the current user role of this user inside the - * current project. - * @param role (Driver, Observer) - */ - public void setUserRole(UserRole role){ - this.role = role; - } - - /** - * Gets current project role of this user. - * @return role (Driver, Observer) - */ - public UserRole getUserRole(){ - return this.role; - } - - @Override - public String toString() { - return jid.getName(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof User) { - User other = (User) obj; - return jid.equals(other.jid); - } - - return false; - } - - public int getColorID(){ - return colorid; - } - - public void setColorID(int c) { - colorid=c; - } - - - public UserConnectionState getPresence() { - return presence; - } - - public void setPresence(UserConnectionState p) { - presence=p; - if (presence==User.UserConnectionState.OFFLINE) - offlineTime = (new java.util.Date().getTime() ) ; - } - public int getOfflineSecs() { - return (int)(( (new java.util.Date().getTime() ) - offlineTime) / 1000) ; - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/EditorActivity.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/EditorActivity.java deleted file mode 100644 index 4aa4a0bb45c2fe8a1103becc0171950896f56b1e..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/EditorActivity.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.activities; - -import org.eclipse.core.runtime.IPath; - -/** - * A text load activity activates a new resource. If the path is - * <code>null</code> no resouce is currently active. - * - * @author rdjemili - */ -public class EditorActivity implements IActivity { - public static enum Type { - Activated, Closed, Saved - }; - - private Type type; - - private IPath path; - - private String source; - - private long checksum = -1; - - /** - * @param path - * a valid project-relative path or <code>null</code> if former - * resource should be deactivated. - */ - public EditorActivity(Type type, IPath path) { - if (type != Type.Activated && path == null) - throw new IllegalArgumentException( - "Null path for non-activation type editor activity given."); - - this.type = type; - this.path = path; - } - - /** - * @return the project-relative path to the resource that should be - * activated. - */ - public IPath getPath() { - return path; - } - - public Type getType() { - return type; - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof EditorActivity)) { - return false; - } - - EditorActivity other = (EditorActivity) obj; - return ((path == null && other.path == null) || path.equals(other.path)) - && type.equals(other.type); - } - - @Override - public String toString() { - return "EditorActivity(type:" + type + ", path:" + path + ")"; - } - - public String getSource() { - return this.source; - } - - public void setSource(String source) { - this.source = source; - } - - public long getChecksum(){ - return this.checksum; - } - - public void setChecksum(long checksum){ - this.checksum = checksum; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/FileActivity.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/FileActivity.java deleted file mode 100644 index 8219f689584fe627dd2402c19c4ba78ef6f299ce..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/FileActivity.java +++ /dev/null @@ -1,90 +0,0 @@ -package de.fu_berlin.inf.dpp.activities; - -import java.io.InputStream; - -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.net.JID; - -public class FileActivity implements IActivity { - public static enum Type { - Created, Removed, Error - }; - - private String source; - - private Type type; - - private IPath path; - - /* exclusive file recipient for error file. */ - private JID errorRecipient; - - private InputStream inputStream; - - public FileActivity(Type type, IPath path) { - this.type = type; - this.path = path; - } - - /** - * construtor to send file activity to an exclusive - * recipient. - * @param type - * @param path - * @param to - */ - public FileActivity(Type type, IPath path, JID to) { - this(type, path); - errorRecipient = to; - } - - public FileActivity(Type type, IPath path, InputStream in) { - this(type, path); - inputStream = in; - } - - public IPath getPath() { - return path; - } - - public Type getType() { - return type; - } - - public JID getRecipient(){ - return errorRecipient; - } - - /** - * @return the inputStream for the contents of this file for incoming file - * creation activities. <code>null</code> otherwise. - */ - public InputStream getContents() { - return inputStream; - } - - @Override - public String toString() { - return "FileActivity(type:" + type + ", path:" + path + ")"; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof FileActivity) { - FileActivity activity = (FileActivity) obj; - - return (getPath().equals(activity.getPath()) && getType().equals(activity.getType())); - } - - return false; - } - - public String getSource() { - return this.source; - } - - public void setSource(String source) { - this.source = source; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/FolderActivity.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/FolderActivity.java deleted file mode 100644 index edc2a2b0f467feccd04b18f587edf666f37970d1..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/FolderActivity.java +++ /dev/null @@ -1,42 +0,0 @@ -package de.fu_berlin.inf.dpp.activities; - -import org.eclipse.core.runtime.IPath; - -public class FolderActivity implements IActivity { - public static enum Type { - Created, Removed - }; - - private String source; - - private Type type; - - private IPath path; - - public FolderActivity(Type type, IPath path) { - this.type = type; - this.path = path; - } - - public IPath getPath() { - return path; - } - - public Type getType() { - return type; - } - - @Override - public String toString() { - return "FolderActivity(type:" + type + ", path:" + path + ")"; - } - - public String getSource() { - return this.source; - } - - public void setSource(String source) { - this.source = source; - - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/IActivity.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/IActivity.java deleted file mode 100644 index e600bcc5cfcd612e56b2e8876d197106221ae655..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/IActivity.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.activities; - -/** - * A generic interface for activities that happen in sessions. All activities - * should be implemented by the value patter, i.e. created activities are - * immutable- - * - * @author rdjemili - */ -public interface IActivity { - - /** - * set source jabber_id of producer of this IActivity. - * @param source jabber_id string - */ - public void setSource(String source); - - /** - * get jabber_id of remote producer - * @return jabber_id - */ - public String getSource(); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/RoleActivity.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/RoleActivity.java deleted file mode 100644 index 4a9d2c4b058f5d04f7cc8f047a5b56d7e97eed64..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/RoleActivity.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.activities; - -import de.fu_berlin.inf.dpp.net.JID; - -public class RoleActivity implements IActivity { - - private String source; - - private JID driver; - - public RoleActivity(JID newDriver) { - this.driver = newDriver; - } - - public JID getDriver() { - return driver; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof RoleActivity) { - RoleActivity driverChange = (RoleActivity) obj; - - return driverChange.getDriver().equals(driver); - } - - return false; - } - - @Override - public String toString() { - return "RoleActivity(driver:" + driver + ")"; - } - - public String getSource() { - return this.source; - } - - public void setSource(String source) { - this.source = source; - - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/TextEditActivity.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/TextEditActivity.java deleted file mode 100644 index b24fb547fa3042bcf6b33c061fac5fdcb3c88b61..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/TextEditActivity.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.activities; - -import org.eclipse.core.runtime.IPath; - -/** - * A simple immutable text activity. - * - * @author rdjemili - */ -public class TextEditActivity implements IActivity { - public final int offset; - - private String source; - - private IPath editor; - /** - * This string only uses \n as line delimiter. Keep this in mind when adding - * it to an IDocument with probably other line delimiters. - */ - public final String text; - - public final int replace; - - /** - * @param offset - * the offset inside the document where this activity happend. - * @param text - * the text that was inserted. - * @param replace - * the length of text that was replaced by this activity. - * @param source - * the source ID of this activity - */ - public TextEditActivity(int offset, String text, int replace) { - this.offset = offset; - this.text = text; - this.replace = replace; - this.source = null; - } - - - /** - * @param offset - * the offset inside the document where this activity happend. - * @param text - * the text that was inserted. - * @param replace - * the length of text that was replaced by this activity. - * @param source - * the source ID of this activity - */ - public TextEditActivity(int offset, String text, int replace, IPath editor) { - this.offset = offset; - this.text = text; - this.replace = replace; - this.source = null; - this.editor = editor; - } - - public String getSource() { - return source; - } - public void setSource(String source) { - this.source=source; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof TextEditActivity) { - TextEditActivity other = (TextEditActivity) obj; - return offset == other.offset && - text.equals(other.text) && - replace == other.replace && - source == other.source; - } - - return false; - } - - @Override - public String toString() { - return "TextEditActivity(offset:" + offset + ",text:" + text + ",replace:" + replace + ", path : "+editor.toString()+ ")"; - } - - /** - * Compare text edit information without source settings. - * @param obj TextEditActivity Object - * @return true if edit information equals. false otherwise. - */ - public boolean sameLike(Object obj){ - if(obj instanceof TextEditActivity){ - TextEditActivity other = (TextEditActivity) obj; - return offset == other.offset && - (editor != null && other.editor != null && editor.equals(other.editor)) && - text.equals(other.text) && - replace == other.replace ; - } - return false; - } - - public IPath getEditor(){ - return this.editor; - } - - public void setEditor(IPath editor){ - this.editor = editor; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/TextSelectionActivity.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/TextSelectionActivity.java deleted file mode 100644 index 8f1e67287c136db92934edad919f7d3cdd13dcab..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/TextSelectionActivity.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.activities; - -public class TextSelectionActivity implements IActivity { - private int offset; - - private int length; - - private String source; - - public TextSelectionActivity(int offset, int length) { - this.offset = offset; - this.length = length; - this.source = null; - } - - public int getLength() { - return length; - } - - public int getOffset() { - return offset; - } - - public String getSource() { - return source; - } - public void setSource(String source) { - this.source=source; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof TextSelectionActivity) { - TextSelectionActivity activity = (TextSelectionActivity) obj; - return offset == activity.offset && - length == activity.length && - source == activity.source; - } - - return false; - } - - @Override - public String toString() { - return "TextSelectionActivity(offset:" + offset + ", length:" + length + ")"; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/ViewportActivity.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/ViewportActivity.java deleted file mode 100644 index 6363e2dc9599c1770dd45d81a06dd7241dd4e8b4..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/ViewportActivity.java +++ /dev/null @@ -1,45 +0,0 @@ -package de.fu_berlin.inf.dpp.activities; - -public class ViewportActivity implements IActivity { - public final int topIndex; - - public final int bottomIndex; - - private String source; - - public ViewportActivity(int topIndex, int bottomIndex) { - this.topIndex = topIndex; - this.bottomIndex = bottomIndex; - } - - public int getBottomIndex() { - return bottomIndex; - } - - public int getTopIndex() { - return topIndex; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof ViewportActivity) { - ViewportActivity other = (ViewportActivity) obj; - return topIndex == other.topIndex && bottomIndex == other.bottomIndex; - } - - return false; - } - - @Override - public String toString() { - return "ViewportActivity(top:" + topIndex + ",bottom:" + bottomIndex + ")"; - } - - public String getSource() { - return this.source; - } - - public void setSource(String source) { - this.source = source; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/ConcurrentManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/ConcurrentManager.java deleted file mode 100644 index a194671dde45ae52756a1972d4f429f829a5f7cb..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/ConcurrentManager.java +++ /dev/null @@ -1,44 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent; - -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.concurrent.jupiter.RequestForwarder; -import de.fu_berlin.inf.dpp.net.IActivitySequencer; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; - -/** - * Interface for management controller class of all jupiter document server. - * @author orieger - * - */ -public interface ConcurrentManager extends IRequestManager, ISharedProjectListener { - - public static enum Side{ - CLIENT_SIDE, - HOST_SIDE - } - - public void setActivitySequencer(IActivitySequencer sequencer); - - public void setRequestForwarder(RequestForwarder f); - - public RequestForwarder getRequestForwarder(); - - public boolean isHostSide(); - - public boolean isHost(JID jid); - - public void setHost(JID jid); - - public IActivity activityCreated(IActivity activity); - - public IActivity exec(IActivity activity); - - /** - * reset jupter state vector an init with [0,0] - * @param path of document under jupiter control. - */ - public void resetJupiterDocument(IPath path); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/IDriverDocumentManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/IDriverDocumentManager.java deleted file mode 100644 index 113a57cf24e1592068d0a8841325a164cb364a70..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/IDriverDocumentManager.java +++ /dev/null @@ -1,23 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent; - -import java.util.List; - -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; - -public interface IDriverDocumentManager extends IDriverManager, ISharedProjectListener{ - - public void receiveActivity(IActivity activity); - - public void addDriverToDocument(IPath path, JID jid); - - /** - * get driver for the appropriate document. - * @param path to document - * @return list of active driver on document. - */ - public List<JID> getDriverForDocument(IPath path); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/IDriverManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/IDriverManager.java deleted file mode 100644 index 4d9e265d183e2bfb98637647ccb2150cbeaf40ed..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/IDriverManager.java +++ /dev/null @@ -1,32 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent; - -import java.util.List; - -import de.fu_berlin.inf.dpp.net.JID; - -/** - * This interface handles the driver event and the appropriate documents. - * @author orieger - * - */ -public interface IDriverManager { - - public void addDriver(JID jid); - - public void removeDriver(JID jid); - - public boolean isDriver(JID jid); - - /** - * only one active driver exists in the system. - * @return - */ - public boolean exclusiveDriver(); - - /** - * get all active driver - * @return list of active driver. - */ - public List<JID> getActiveDriver(); - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/IRequestManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/IRequestManager.java deleted file mode 100644 index ec93cdfa783efe5d81dc0aff04fcb6d9a9b9f22c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/IRequestManager.java +++ /dev/null @@ -1,13 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; - -/** - * received request from other clients over network. - * @author orieger - * - */ -public interface IRequestManager { - - public void receiveRequest(Request request); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Algorithm.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Algorithm.java deleted file mode 100644 index d653d190022cf10e8a51bb28e1ee7c1540a6fd00..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Algorithm.java +++ /dev/null @@ -1,66 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -public interface Algorithm { - - /** - * Gets the site id of this algorithm. - * - * @return the site id - */ - int getSiteId(); - - /** - * Gets the current timestamp at the local site. - * - * @return the current timestamp - */ - Timestamp getTimestamp(); - - /** - * Generates a request for the given operation. The operation is a locally - * generated operation. The returned request must be sent to the other - * sites. - * - * @param op the operation for which a request should be generated - * @return the generated request - * @see Request - */ - Request generateRequest(Operation op); - - /** - * Receives a request from a remote site. The request must be transformed - * and the resulting operation is returned. - * - * @param req the request to transform and apply - * @return the transformed Operation - */ - Operation receiveRequest(Request req) throws TransformationException; - - /** - * Notifies the algorithm that the site specified by the site id has - * processed the number of messages in the timestamp. - * - * @param siteId the site id of the sending site - * @param timestamp the timestamp at the other site - * @throws TransformationException - */ - void acknowledge(int siteId, Timestamp timestamp) throws TransformationException; - - /** - * Transform the array of indices from the state indicated by the timestamp - * to the current timestamp at the local site. The transformed indices - * are returned to the client. - * - * @param timestamp the timestamp at which the indices are valid - * @param indices the array of integer indices - * @return the transformed array of indices - */ - int[] transformIndices(Timestamp timestamp, int[] indices) throws TransformationException; - - /** - * - * @param timestamp - * @throws TransformationException - */ - void updateVectorTime(Timestamp timestamp) throws TransformationException; -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/InclusionTransformation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/InclusionTransformation.java deleted file mode 100644 index 44ecc94bca69d8d0f59c3b831df6c9e958f66fea..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/InclusionTransformation.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * $Id: InclusionTransformation.java 2430 2005-12-11 15:17:11Z sim $ - * - * ace - a collaborative editor - * Copyright (C) 2005 Mark Bigler, Simon Raess, Lukas Zbinden - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - - -/** - * Interface for inclusion transformation functions. - */ -public interface InclusionTransformation { - - /** - * Include operation <var>op2</var> into the context of operation - * <var>op1</var>. The transformed operation <var>op1'</var> is returned. - * - * @param op1 the operation into which another is to be contextually - * included. - * @param op2 the operation to be included. - * @param param an additional parameter depending on the implementation. - * @return the transformed operation <var>op1'</var> - */ - public Operation transform(Operation op1, Operation op2, Object param); - - /** - * Transforms an index against the given operation. - * - * @param index the index to be transformed - * @param op the Operation to be transformed - * @param param an additional implementation dependent parameter - * @return the transformed index - */ - public int transformIndex(int index, Operation op, Object param); - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/JupiterClient.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/JupiterClient.java deleted file mode 100644 index 360e93a371c72032c2a5e2c59aa9546945b195e5..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/JupiterClient.java +++ /dev/null @@ -1,24 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -import de.fu_berlin.inf.dpp.net.JID; - -public interface JupiterClient extends JupiterEditor{ - - public Request generateRequest(Operation op); - - public Operation receiveRequest(Request req) throws TransformationException; - - /** - * get the jid of the appropriate client. - * @return - */ - public JID getJID(); - - /** - * get the current vector time. - * @return - */ - public Timestamp getTimestamp(); - - public void updateVectorTime(Timestamp timestamp) throws TransformationException; -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/JupiterEditor.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/JupiterEditor.java deleted file mode 100644 index 8f2225ef9c954bd9e9bf325d0a0cac6e39af1972..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/JupiterEditor.java +++ /dev/null @@ -1,15 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -import org.eclipse.core.runtime.IPath; - -/** - * interface for jupiter editor settings. - * @author orieger - * - */ -public interface JupiterEditor { - - public void setEditor(IPath path); - - public IPath getEditor(); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/JupiterServer.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/JupiterServer.java deleted file mode 100644 index 1b3f642f9d6c2d0fd5e50d47fe51dc8f9fe429b8..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/JupiterServer.java +++ /dev/null @@ -1,32 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -import java.util.HashMap; - -import de.fu_berlin.inf.dpp.net.JID; - -public interface JupiterServer extends SynchronizedQueue, RequestForwarder, JupiterEditor{ - - public void addProxyClient(JID jid); - - public void removeProxyClient(JID jid); - - /** - * get current document proxies. - * @return - * @throws InterruptedException - */ - public HashMap<JID, JupiterClient> getProxies() throws InterruptedException; - - /** - * get exist state of proxy client for given jid. - * @param jid - * @return - */ - public boolean isExist(JID jid); - - - public void updateVectorTime(JID source, JID dest); - - public void transformationErrorOccured(); - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Operation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Operation.java deleted file mode 100644 index b76b5cc373396ffa6fa7f97f70ef6eb7172578f1..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Operation.java +++ /dev/null @@ -1,12 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -import java.io.Serializable; - -/** - * This interface must be implemented by all operations. An - * operation is application dependent and therefore this interface - * does not contain any specific methods at all. - */ -public interface Operation extends Serializable { - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/OperationSerializer.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/OperationSerializer.java deleted file mode 100644 index a809f1a616883ac66038df032508cb35a5af1505..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/OperationSerializer.java +++ /dev/null @@ -1,10 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -/** - * - * @author rieger - * - */ -public interface OperationSerializer { - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Request.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Request.java deleted file mode 100644 index 704f5bc16f46e9f35687bc056bf131d782754d0b..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Request.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * $Id: Request.java 2430 2005-12-11 15:17:11Z sim $ - * - * ace - a collaborative editor - * Copyright (C) 2005 Mark Bigler, Simon Raess, Lukas Zbinden - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -import java.io.Serializable; - -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.net.JID; - - -/** - * This interface represents a request. Requests are typically sent over the - * network to other sites. A request consists at least of the identifier of the - * sending site, an operation and a timestamp that specifies the definition - * context of the operation. - * - - */ -public interface Request extends Serializable { - - /** - * Gets the identifier of the sending site. - * - * @return the identifier of the sending site - */ - public int getSiteId(); - - /** - * Gets the operation to be propagated. - * - * @return the operation - */ - public Operation getOperation(); - - /** - * Gets the timestamp that specifies the definition context of the enclosed - * operation. - * - * @return the timestamp of the definition context - */ - public Timestamp getTimestamp(); - - /** - * Gets the jid of the appropriate client site. - * @return the jid of the client - */ - public JID getJID(); - - public void setJID(JID jid); - - public IPath getEditorPath(); - - public void setEditorPath(IPath editor); - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/RequestForwarder.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/RequestForwarder.java deleted file mode 100644 index 20353ffab7a89cf19bce8694a1dec1b2e915e920..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/RequestForwarder.java +++ /dev/null @@ -1,17 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -public interface RequestForwarder { - - /** - * Add generate request for transfering via network. - * @param req - */ - public void forwardOutgoingRequest(Request req); - - /** - * get next request for transfer. - * @return - * @throws InterruptedException - */ - public Request getNextOutgoingRequest() throws InterruptedException; -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/SynchronizedQueue.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/SynchronizedQueue.java deleted file mode 100644 index ecba465d632a15f2db6b6f279476196c4640fef5..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/SynchronizedQueue.java +++ /dev/null @@ -1,17 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -public interface SynchronizedQueue { - - /** - * add request to synchronized queue. - * @param request the new request. - */ - public void addRequest(Request request); - - /** - * Gets first request in queue. - * @return - * @throws InterruptedException - */ - public Request getNextRequestInSynchronizedQueue() throws InterruptedException; -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Timestamp.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Timestamp.java deleted file mode 100644 index 55844c107de32c0f8270c0a13ddcf4f8a1ea73b6..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Timestamp.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * $Id: Timestamp.java 747 2005-10-21 13:31:38Z sim $ - * - * ace - a collaborative editor - * Copyright (C) 2005 Mark Bigler, Simon Raess, Lukas Zbinden - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -import java.io.Serializable; - -/** - * This interface represents the concept of a timestamp. Timestamps is a general - * concept, so this interface remains empty. - * - * @see ch.iserver.ace.algorithm.VectorTime - */ -public interface Timestamp extends Serializable { - - /** - * Retrieves the components of the timestamp as an int array. The exact - * representation is up to the concrete Timestamp implementation. - * - * @return the components of the Timestamp implementation - */ - int[] getComponents(); - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/TimestampFactory.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/TimestampFactory.java deleted file mode 100644 index 42758c36b03243a2cdea702a438dde9adc8c059d..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/TimestampFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * $Id: TimestampFactory.java 749 2005-10-21 13:51:56Z sim $ - * - * ace - a collaborative editor - * Copyright (C) 2005 Mark Bigler, Simon Raess, Lukas Zbinden - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -/** - * TimestampFactory is a factory that can create Timestamp objects from - * an external representation of timestamps in the form of an int array. - */ -public interface TimestampFactory { - - /** - * Creates a Timestamp from the components in the int array. - * - * @param components the components of the timestamp as an int array - * @return a Timestamp instance created from the component array - * @throws IllegalArgumentException if the component array does not satisfy - * the expectations of the TimestampFactory - */ - Timestamp createTimestamp(int[] components); - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/TransformationException.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/TransformationException.java deleted file mode 100644 index 548481aaa30b95539e4b9cc54d8104a8374d1354..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/TransformationException.java +++ /dev/null @@ -1,44 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -/** - * Exception thrown by algorithm instances whenever transforming operations - * fails. - */ -public class TransformationException extends Exception { - - /** - * Creates a new TransformationException. - */ - public TransformationException() { - super(); - } - - /** - * Creates a new TransformationException. - * - * @param message the detail message - */ - public TransformationException(String message) { - super(message); - } - - /** - * Creates a new TransformationException. - * - * @param cause the cause of this exception - */ - public TransformationException(Throwable cause) { - super(cause); - } - - /** - * Creates a new TransformationException. - * - * @param message the detail message - * @param cause the cause of this exception - */ - public TransformationException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/VectorTime.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/VectorTime.java deleted file mode 100644 index 1b42b7dfbe535a581dcbd4771ffcd0a32378913c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/VectorTime.java +++ /dev/null @@ -1,25 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -/** - * Vector time is a concept used in almost all OT algorithms to determine - * causality relations of operations. - */ -public interface VectorTime extends Timestamp { - - /** - * Gets the length of the vector. - * - * @return the length of the vector time - */ - int getLength(); - - /** - * Gets the value at the given index. - * - * @param index the index into the vector - * @return the value at the given index - * @throws IndexOutOfBoundsException if index is invalid - */ - int getAt(int index); - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/Jupiter.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/Jupiter.java deleted file mode 100644 index caf9661a7a75b4e43a849854911f381f218f7846..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/Jupiter.java +++ /dev/null @@ -1,375 +0,0 @@ -/* - * $Id: Jupiter.java 2859 2006-04-01 09:39:19Z sim $ - * - * ace - a collaborative editor - * Copyright (C) 2005 Mark Bigler, Simon Raess, Lukas Zbinden - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import javax.swing.undo.CannotRedoException; -import javax.swing.undo.CannotUndoException; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm; -import de.fu_berlin.inf.dpp.concurrent.jupiter.InclusionTransformation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp; -import de.fu_berlin.inf.dpp.concurrent.jupiter.TransformationException; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.GOTOInclusionTransformation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.SplitOperation; - -/** - * This class implements the client-side core of the Jupiter control algorithm. - */ -public class Jupiter implements Algorithm { - - /** - * The inclusion transformation function used to transform operations. - */ - private InclusionTransformation inclusion; - - /** - * The vector time, representing the number of processed requests, of - * this algorithm. - */ - private JupiterVectorTime vectorTime; - - /** - * Flag indicating whether this algorithm is used on the client-side. - * In some situations, the requests from the server-side have a higher - * priority in transformations. - */ - private boolean isClientSide; - - /** - * A list that contains the requests sent to the server which are to be - * acknowledged by the server before they can be removed. This list - * corresponds to the 'outgoing' list in the Jupiter pseudo code - * description. - */ - private List<OperationWrapper> ackRequestList; - - /** - * Class constructor that creates a new Jupiter algorithm. - * @param isClientSide - * true if the algorithm resides on the client side - */ - public Jupiter(boolean isClientSide) { - this.inclusion = new GOTOInclusionTransformation(); - this.vectorTime = new JupiterVectorTime(0, 0); - this.isClientSide = isClientSide; - ackRequestList = new ArrayList<OperationWrapper>(); - } - - /** - * @see de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm#generateRequest( de.fu_berlin.inf.dpp.concurrent.jupiter.Operation) - */ - public Request generateRequest(Operation op) { - // send(op, myMsgs, otherMsgs); - Request req = new RequestImpl( - getSiteId(), - (Timestamp) vectorTime.clone(), - op); - - // add(op, myMsgs) to outgoing; - if (op instanceof SplitOperation) { - SplitOperation split = (SplitOperation) op; - ackRequestList.add(new OperationWrapper(split.getFirst(), - vectorTime.getLocalOperationCount())); - ackRequestList.add(new OperationWrapper(split.getSecond(), - vectorTime.getLocalOperationCount())); - } else { - ackRequestList.add(new OperationWrapper(op, vectorTime - .getLocalOperationCount())); - } - - // myMsgs = myMsgs + 1; - vectorTime.incrementLocalOperationCount(); - - return req; - } - - /** - * @see de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm#receiveRequest(de.fu_berlin.inf.dpp.concurrent.jupiter.Request) - */ - public Operation receiveRequest(Request req) throws TransformationException { - Timestamp timestamp = req.getTimestamp(); - if (!(timestamp instanceof JupiterVectorTime)) { - throw new IllegalArgumentException("Jupiter expects timestamps of type JupiterVectorTime"); - } - //TODO: check preconditions -// try{ - checkPreconditions((JupiterVectorTime) timestamp); -// }catch(TransformationException e){ -// logger.warn(e); -// } - discardAcknowledgedOperations((JupiterVectorTime) timestamp); - - Operation newOp = transform(req.getOperation()); - vectorTime.incrementRemoteRequestCount(); - - return newOp; - } - - /** - * @see de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm#acknowledge(int, de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp) - */ - public void acknowledge(int siteId, Timestamp timestamp) throws TransformationException { - discardAcknowledgedOperations((JupiterVectorTime) timestamp); - } - - /** - * @see de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm#transformIndices(de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp, int[]) - */ - public int[] transformIndices(Timestamp timestamp, int[] indices) throws TransformationException { - checkPreconditions((JupiterVectorTime) timestamp); - discardAcknowledgedOperations((JupiterVectorTime) timestamp); - int[] result = new int[indices.length]; - System.arraycopy(indices, 0, result, 0, indices.length); - for (int i = 0; i < ackRequestList.size(); i++) { - OperationWrapper wrap = ackRequestList.get(i); - Operation ack = wrap.getOperation(); - for (int k = 0; k < indices.length; k++) { - result[k] = transformIndex(result[k], ack); - } - } - return result; - } - - /** - * Transforms the given index against the operation. - * - * @param index the index to be transformed - * @param op the operation to be transformed - * @return the transformed index - */ - private int transformIndex(int index, Operation op) { - if (isClientSide()) { - return inclusion.transformIndex(index, op, Boolean.TRUE); - } else { - return inclusion.transformIndex(index, op, Boolean.FALSE); - } - } - - /** - * Discard from the other site (client/server) acknowledged operations. - * - * @param time the request to the remote operation count from - */ - private void discardAcknowledgedOperations(JupiterVectorTime time) { - Iterator<OperationWrapper> iter = ackRequestList.iterator(); - while (iter.hasNext()) { - OperationWrapper wrap = iter.next(); - if (wrap.getLocalOperationCount() < time.getRemoteOperationCount()) { - iter.remove(); - } - } - // ASSERT msg.myMsgs == otherMsgs - assert time.getLocalOperationCount() == vectorTime - .getRemoteOperationCount() : "msg.myMsgs != otherMsgs !!"; - } - - /** - * Transforms an operation with the operations in the outgoing queue - * {@link #ackRequestList}. - * - * @param newOp - * the operation to be transformed - * @return the transformed operation - * @see #ackRequestList - */ - private Operation transform(Operation newOp) { - for (int ackRequestListCnt = 0; ackRequestListCnt < ackRequestList - .size(); ackRequestListCnt++) { - OperationWrapper wrap = ackRequestList - .get(ackRequestListCnt); - Operation existingOp = wrap.getOperation(); - - Operation transformedOp; - if (newOp instanceof SplitOperation) { - SplitOperation split = (SplitOperation) newOp; - if (isClientSide()) { - split.setFirst(inclusion.transform(split.getFirst(), - existingOp, Boolean.TRUE)); - split.setSecond(inclusion.transform(split.getSecond(), - existingOp, Boolean.TRUE)); - existingOp = inclusion.transform(existingOp, split - .getFirst(), Boolean.FALSE); - existingOp = inclusion.transform(existingOp, split - .getSecond(), Boolean.FALSE); - } else { - split.setFirst(inclusion.transform(split.getFirst(), - existingOp, Boolean.FALSE)); - split.setSecond(inclusion.transform(split.getSecond(), - existingOp, Boolean.FALSE)); - existingOp = inclusion.transform(existingOp, split - .getFirst(), Boolean.TRUE); - existingOp = inclusion.transform(existingOp, split - .getSecond(), Boolean.TRUE); - } - transformedOp = split; - } else { - if (isClientSide()) { - transformedOp = inclusion.transform(newOp, existingOp, - Boolean.TRUE); - existingOp = inclusion.transform(existingOp, newOp, - Boolean.FALSE); - } else { - transformedOp = inclusion.transform(newOp, existingOp, - Boolean.FALSE); - existingOp = inclusion.transform(existingOp, newOp, - Boolean.TRUE); - } - } - ackRequestList.set(ackRequestListCnt, new OperationWrapper( - existingOp, wrap.getLocalOperationCount())); - - newOp = transformedOp; - } - return newOp; - } - - /** - * Test 3 preconditions that must be fulfilled before transforming. They are - * taken from the Jupiter paper. - * - * @param time the request to be tested. - */ - private void checkPreconditions(JupiterVectorTime time) throws TransformationException { - if (!ackRequestList.isEmpty() - && time.getRemoteOperationCount() < ackRequestList - .get(0).getLocalOperationCount()) { - throw new TransformationException("precondition #1 violated."); - } else if (time.getRemoteOperationCount() > vectorTime - .getLocalOperationCount()) { - throw new TransformationException("precondition #2 violated."); - } else if (time.getLocalOperationCount() != vectorTime - .getRemoteOperationCount()) { - throw new TransformationException("precondition #3 violated: " + time + " , " + vectorTime); - } - } - - /** - * This is a simple helper class used in the implementation of the Jupiter - * algorithm. A OperationWrapper instance is created with an operation and - * the current local operation count and inserted into the outgoing queue - * (see {@link Jupiter#ackRequestList}). - * - * @see Jupiter#generateRequest(Operation) - * @see Jupiter#receiveRequest(Request) - */ - private static class OperationWrapper { - - private Operation op; - - private int count; - - OperationWrapper(Operation op, int count) { - this.op = op; - this.count = count; - } - - Operation getOperation() { - return op; - } - - int getLocalOperationCount() { - return count; - } - - /** - * {@inheritDoc} - */ - public String toString() { - return ("OperationWrapper(" + op + ", " + count + ")"); - } - } - - /** - * Throws a CannotUndoException because undo is not supported by this - * implementation. - * - * @see de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm#undo() - */ - public Request undo() { - throw new CannotUndoException(); - } - - /** - * Throws a CannotRedoException because undo is not supported by this - * implementation. - * - * @see de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm#redo() - */ - public Request redo() { - throw new CannotRedoException(); - } - - /** - * Set an inclusion transformation function. - * - * @param it the inclusion transformation function to set. - */ - public void setInclusionTransformation(InclusionTransformation it) { - this.inclusion = it; - } - - /** - * @return the algorithms inclusion transformation - */ - public InclusionTransformation getInclusionTransformation() { - return inclusion; - } - - /** - * @see de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm#getSiteId() - */ - public int getSiteId() { - return isClientSide() ? 1 : 0; - } - - /** - * @see de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm#getTimestamp() - */ - public synchronized Timestamp getTimestamp() { - return (Timestamp) vectorTime.clone(); - } - - /** - * Checks if this algorithm locates client side. - * - * @return true if this algorithm locates client side - */ - public boolean isClientSide() { - return isClientSide; - } - - public void updateVectorTime(Timestamp timestamp) throws TransformationException{ - if(ackRequestList.size()> 0){ - throw new TransformationException("ackRequestList have entries. Update Vector time failed."); - } - int local = timestamp.getComponents()[0]; - int remote = timestamp.getComponents()[1]; - this.vectorTime = new JupiterVectorTime(local, remote); - - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterDocumentClient.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterDocumentClient.java deleted file mode 100644 index 1343293b78e8a0838df758c31497c22311c0fcc9..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterDocumentClient.java +++ /dev/null @@ -1,92 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal; - -import org.apache.log4j.Logger; -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm; -import de.fu_berlin.inf.dpp.concurrent.jupiter.JupiterClient; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.RequestForwarder; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp; -import de.fu_berlin.inf.dpp.concurrent.jupiter.TransformationException; -import de.fu_berlin.inf.dpp.net.JID; - -public class JupiterDocumentClient implements JupiterClient { - - /** - * 1. Outgoing queue - * 2. request forwarder - * - */ - - private static Logger logger = Logger.getLogger(JupiterDocumentClient.class.toString()); - - /** jid of remote client*/ - private JID jid; - /** jupiter sync algorithm. */ - private Algorithm jupiter; - - private IPath editor; - - /** forwarder send request to server. */ - private RequestForwarder forwarder; - - @Deprecated - public JupiterDocumentClient(JID jid, RequestForwarder forwarder){ - this.jid = jid; - this.jupiter = new Jupiter(true); - this.forwarder = forwarder; - } - - public JupiterDocumentClient(JID jid, RequestForwarder forwarder, IPath editor){ - this.jid = jid; - this.jupiter = new Jupiter(true); - this.forwarder = forwarder; - this.editor = editor; - } - - public Request generateRequest(Operation op) { - Request req = null; - logger.debug(jid.toString()+" client generate request for "+op); - req = jupiter.generateRequest(op); - req.setJID(this.jid); - req.setEditorPath(editor); - /* send request*/ - forwarder.forwardOutgoingRequest(req); - - return req; - } - - public Operation receiveRequest(Request req)throws TransformationException { - Operation op = null; - logger.debug(jid.toString()+" client receive request "+req.getOperation()); - /* receive request action */ - op = jupiter.receiveRequest(req); - logger.debug(jid.toString()+" client operation of IT: "+op); - return op; - } - - public JID getJID() { - return this.jid; - } - - public IPath getEditor() { - return editor; - } - - public void setEditor(IPath path) { - this.editor = path; - - } - - public Timestamp getTimestamp() { - return jupiter.getTimestamp(); - } - - public void updateVectorTime(Timestamp timestamp) throws TransformationException { - jupiter.updateVectorTime(timestamp); - } - - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterDocumentServer.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterDocumentServer.java deleted file mode 100644 index 1eff26da3704111f78814803dec8e07acf2e2f64..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterDocumentServer.java +++ /dev/null @@ -1,254 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal; - -import java.util.HashMap; -import java.util.List; -import java.util.Timer; -import java.util.TimerTask; -import java.util.Vector; - -import org.apache.log4j.Logger; -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.JupiterClient; -import de.fu_berlin.inf.dpp.concurrent.jupiter.JupiterServer; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.RequestForwarder; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp; -import de.fu_berlin.inf.dpp.concurrent.jupiter.TransformationException; -import de.fu_berlin.inf.dpp.net.JID; - -public class JupiterDocumentServer implements JupiterServer{ - - private static Logger logger = Logger.getLogger(JupiterDocumentServer.class); - - /** - * List of proxy clients. - */ - private HashMap<JID, JupiterClient> proxies; - - private List<Request> requestList; - -// /** outgoing queue to transfer request to appropriate clients. */ - private List<Request> outgoingQueue; - - private IPath editor; - /** - * forward outgoing request to activity sequencer; - */ - private RequestTransmitter transmitter; - -// /** for add and remove client synchronization. */ -// public boolean waitForSerializer = false; -// /** counter for remove client synchronization.*/ -// public int requestSyncCounter = 0; - - /** - * this forwarder reads request form the local outgoing queue and transmit - * the requests to the global outgoing queue. - */ - class RequestTransmitter extends Thread{ - - private final RequestForwarder rf; - private static final int MILLIS = 100; - - public RequestTransmitter(RequestForwarder forw){ - this.rf = forw; - } - - public Timer flushTimer = new Timer(true); - - public void run(){ - flushTimer.schedule(new TimerTask(){ - - @Override - public void run() { - /*forwarding */ - try { - logger.debug("Forwarding requests to activity sequencer. "); - rf.forwardOutgoingRequest(getNextOutgoingRequest()); - logger.debug("Forwarding is sended to activity sequencer. "); - } catch (InterruptedException e) { - logger.warn("Exception forwarding request.",e); - } - - } - - },0, MILLIS); - } - - } - - /** - * this constructor init an external request forwarder. - * The generate answer request of the proxy clients forwarding - * to this forwarder. - */ - public JupiterDocumentServer(RequestForwarder forwarder){ - proxies = new HashMap<JID, JupiterClient>(); - requestList = new Vector<Request>(); - this.outgoingQueue = new Vector<Request>(); - -new Serializer(this); - this.transmitter = new RequestTransmitter(forwarder); - transmitter.start(); - } - - /** - * default constructor. The server contains his own outgoing - * forwarding queue. - */ - public JupiterDocumentServer(){ - proxies = new HashMap<JID, JupiterClient>(); - requestList = new Vector<Request>(); - this.outgoingQueue = new Vector<Request>(); - -new Serializer(this); - } - - - - public synchronized void addProxyClient(JID jid) { - JupiterClient proxy = new ProxyJupiterDocument(jid,this); - proxy.setEditor(editor); -// /* add to serializer. */ -// waitForSerializer = true; - //TODO: Sync with serializer before add action. - logger.debug("add new proxy client : "+jid); - proxies.put(jid, proxy); - } - - public synchronized void removeProxyClient(JID jid) { - - /** - * TODO: sync with serializer. - * - * 1. save current action count - * 2. stop serializer after this cound and remove client. - */ - proxies.remove(jid); - notifyAll(); - } - - /** - * add request from transmitter to request queue. - */ - public synchronized void addRequest(Request request) { - - /*TODO: Sync with serializer. */ - - /** - * add request to serialized queue. - */ - logger.debug("add new Request: "+request.getJID()+" "+request.getOperation()); - requestList.add(request); - notify(); - } - - /** - * next message in request queue. - */ - public synchronized Request getNextRequestInSynchronizedQueue() throws InterruptedException { - /* if queue is empty or proxy managing action is running. */ - while(!(requestList.size() > 0)){ - wait(); - } - logger.debug("read out next request in queue! "+requestList.get(0).getJID()+requestList.get(0)); - /*get next request. */ - return requestList.remove(0); - } - - public synchronized HashMap<JID, JupiterClient> getProxies() throws InterruptedException { - /* Was Passiert, wenn während der Bearbeitung ein neuer proxy eingefügt wird */ - -// /* Synchronistation für das Client Management.*/ -// while(waitForSerializer && requestSyncCounter == 0){ -// wait(); -// } - logger.debug("Get jupiter proxies."); - return proxies; - } - - - /* start transfer section. */ - - /** - * proxies add generated request to outgoing queue. - */ - public synchronized void forwardOutgoingRequest(Request req) { - /* add request to outgoing queue. */ -// if(outgoing == null){ - outgoingQueue.add(req); -// }else{ -// /* forward request.*/ -// outgoing.forwardOutgoingRequest(req); -// } - logger.debug("add request to outgoing queue : "+req.getJID()+" "+req); - notify(); - } - - /** - * transmitter interface get next request for transfer. - */ - public synchronized Request getNextOutgoingRequest() throws InterruptedException { - Request req = null; -// if(outgoing == null){ - /* get next message and transfer to client.*/ - while(!(outgoingQueue.size() >0)){ - wait(200); - } - /* remove first queue element. */ - req = outgoingQueue.remove(0); -// } -// else{ -// req = outgoing.getNextOutgoingRequest(); -// -// } - logger.debug("read next request from outgoing queue: "+req.getJID()+" "+req); - return req; - -// return outgoing.getNextOutgoingRequest(); - } - - public IPath getEditor() { - return editor; - } - - public void setEditor(IPath path) { - this.editor = path; - - } - - public boolean isExist(JID jid) { - if(proxies.containsKey(jid)){ - return true; - } - return false; - } - - public void updateVectorTime(JID source, JID dest) { - JupiterClient proxy = proxies.get(source); - if(proxy != null){ - try { - Timestamp ts = proxy.getTimestamp(); - getProxies().get(dest).updateVectorTime(new JupiterVectorTime(ts.getComponents()[1],ts.getComponents()[0])); - } catch (TransformationException e) { - logger.error("Error during update vector time for "+dest,e); - } catch (InterruptedException e) { - logger.error("Error during update vector time for "+dest,e); - } - } - else{ - logger.error("No proxy found for given source jid: "+source); - } - - } - - public void transformationErrorOccured() { - forwardOutgoingRequest(new RequestError(editor)); - } - - /* end transfer section */ - - - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterTimestampFactory.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterTimestampFactory.java deleted file mode 100644 index 0fc54c0ae6e5d07b5ed6aabe53ba5f020f7cf87c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterTimestampFactory.java +++ /dev/null @@ -1,26 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp; -import de.fu_berlin.inf.dpp.concurrent.jupiter.TimestampFactory; - -/** - * TimestampFactory that creates Jupiter specific Timestamp objects. The - * encoding for Jupiter specific Timestamps is a component array of length 2 - * whereby the first index of the array contains the local operation count - * and the second index of the array contains the remote operation count. - */ -public class JupiterTimestampFactory implements TimestampFactory { - - /** - * - */ - public Timestamp createTimestamp(int[] components) { - if (components.length != 2) { - throw new IllegalArgumentException( - "JupiterTimestampFactory expects a component array" - + "of length 2"); - } - return new JupiterVectorTime(components[0], components[1]); - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterVectorTime.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterVectorTime.java deleted file mode 100644 index c2dad868d2ee27b9ed99a148ffd6efa03a17c8a0..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterVectorTime.java +++ /dev/null @@ -1,151 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.VectorTime; - - -/** - * This class models the vector time for the Jupiter control algorithm. - */ -public class JupiterVectorTime implements VectorTime, Cloneable { - - /** - * Counter for the number of local operations. - */ - private int localOperationCnt; - - /** - * Counter for the number of remote operations. - */ - private int remoteOperationCnt; - - /** - * Create a new JupiterVectorTime. - * - * @param localCnt - * the local operation count. - * @param remoteCnt - * the remote operation count. - */ - public JupiterVectorTime(int localCnt, int remoteCnt) { - if (localCnt < 0) { - throw new IllegalArgumentException("local operation count cannot be negative"); - } - if (remoteCnt < 0) { - throw new IllegalArgumentException("remote operation count cannot be negative"); - } - localOperationCnt = localCnt; - remoteOperationCnt = remoteCnt; - } - - /** - * @see ch.iserver.ace.algorithm.VectorTime#getAt(int) - */ - public int getAt(int index) { - if (index == 0) { - return getLocalOperationCount(); - } else if (index == 1) { - return getRemoteOperationCount(); - } else { - throw new IndexOutOfBoundsException("" + index); - } - } - - /** - * @see ch.iserver.ace.algorithm.VectorTime#getLength() - */ - public int getLength() { - return 2; - } - - /** - * @see Timestamp#getComponents() - */ - public int[] getComponents() { - return new int[] { getLocalOperationCount(), getRemoteOperationCount() }; - } - - /** - * @return Returns the local operation count. - */ - public int getLocalOperationCount() { - return localOperationCnt; - } - - /** - * @return Returns the remote operation count. - */ - public int getRemoteOperationCount() { - return remoteOperationCnt; - } - - /** - * Increment the local operation counter. - * - * @return the counter after increment. - */ - public int incrementLocalOperationCount() { - return ++localOperationCnt; - } - - /** - * Increment the remote operation counter. - * - * @return the counter after increment. - */ - public int incrementRemoteRequestCount() { - return ++remoteOperationCnt; - } - - /** - * @see java.lang.Object#toString() - */ - public String toString() { - StringBuffer buffer = new StringBuffer(); - buffer.append("["); - buffer.append(localOperationCnt); - buffer.append(","); - buffer.append(remoteOperationCnt); - buffer.append("]"); - return buffer.toString(); - } - - /** - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object obj) { - if (this == obj) { - return true; - } else if (obj == null) { - return false; - } else if (obj.getClass().equals(getClass())) { - JupiterVectorTime vector = (JupiterVectorTime) obj; - return vector.localOperationCnt == localOperationCnt - && vector.remoteOperationCnt == remoteOperationCnt; - } else { - return false; - } - } - - /** - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - int hashcode = 17; - hashcode = 37 * hashcode + localOperationCnt; - hashcode = 37 * hashcode + remoteOperationCnt; - return hashcode; - } - - /** - * @see java.lang.Object#clone() - */ - public Object clone() { - try { - return super.clone(); - } catch (CloneNotSupportedException e) { - // this shouldn't happen, since we are Cloneable - throw new InternalError(); - } - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/ProxyJupiterDocument.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/ProxyJupiterDocument.java deleted file mode 100644 index 9b2b4d8c0ee18f7fd21a6d0775ab638944d91071..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/ProxyJupiterDocument.java +++ /dev/null @@ -1,91 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal; - -import org.apache.log4j.Logger; -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm; -import de.fu_berlin.inf.dpp.concurrent.jupiter.JupiterClient; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.RequestForwarder; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp; -import de.fu_berlin.inf.dpp.concurrent.jupiter.TransformationException; -import de.fu_berlin.inf.dpp.net.JID; - -public class ProxyJupiterDocument implements JupiterClient{ - - /** - * 1. Outgoing queue - * 2. request forwarder - * - */ - - private static Logger logger = Logger.getLogger(ProxyJupiterDocument.class); - - /** jid of remote client*/ - private JID jid; - /** jupiter sync algorithm. */ - private Algorithm jupiter; - /** forwarder send request to client. */ - private RequestForwarder forwarder; - - private IPath editor; - - public ProxyJupiterDocument(JID jid, RequestForwarder forwarder){ - this.jid = jid; - jupiter = new Jupiter(false); - this.forwarder = forwarder; - } - - - public Request generateRequest(Operation op) { - Request req = null; - logger.debug(jid.toString()+" proxy client generate request for "+op); - req = jupiter.generateRequest(op); - req.setJID(this.jid); - req.setEditorPath(editor); - /* send request*/ - logger.debug(jid.toString()+" proxy client forward request: "+req); - forwarder.forwardOutgoingRequest(req); - - return req; - } - - public Operation receiveRequest(Request req) throws TransformationException { - Operation op = null; - logger.debug(jid.toString()+" proxy client receive request "+req.getOperation()); - /* receive request action */ - op = jupiter.receiveRequest(req); - logger.debug(jid.toString()+" proxy client operation of IT: "+op); - return op; - } - - /** - * @see de.fu_berlin.inf.dpp.concurrent.jupiter.JupiterClient#getJID() - */ - public JID getJID() { - return jid; - } - - - public IPath getEditor() { - return this.editor; - } - - - public void setEditor(IPath path) { - this.editor = path; - } - - - public Timestamp getTimestamp() { - return jupiter.getTimestamp(); - } - - - public void updateVectorTime(Timestamp timestamp) throws TransformationException{ - jupiter.updateVectorTime(timestamp); - } - - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/RequestError.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/RequestError.java deleted file mode 100644 index fd3b00fc53b5da7503b4ef0559c2843190ef1935..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/RequestError.java +++ /dev/null @@ -1,60 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal; - -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp; -import de.fu_berlin.inf.dpp.net.JID; -/** - * Error object of an transformation request. - * @author orieger - * - */ -public class RequestError implements Request{ - - private IPath path; - - public RequestError(IPath path){ - this.path = path; - } - - - /** - * - */ - private static final long serialVersionUID = 3111067620344018430L; - - public IPath getEditorPath() { - return path; - } - - public JID getJID() { - - return null; - } - - public Operation getOperation() { - - return null; - } - - public int getSiteId() { - - return 0; - } - - public Timestamp getTimestamp() { - - return null; - } - - public void setEditorPath(IPath editor) { - this.path = editor; - } - - public void setJID(JID jid) { - - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/RequestImpl.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/RequestImpl.java deleted file mode 100644 index d3425b667de74b48cac55ac4ea19f71d5e7d8040..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/RequestImpl.java +++ /dev/null @@ -1,167 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal; - -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp; -import de.fu_berlin.inf.dpp.net.JID; - - -/** - * Default implementation of the Request interface. - */ -public class RequestImpl implements Request { - - /** - * The site id of the request. - */ - private final int siteId; - - /** - * The timestamp of the request. - */ - private final Timestamp timestamp; - - /** - * The operation of the request. - */ - private final Operation operation; - - /** - * JID of appropriate client. - */ - private JID jid; - - /** - * Path of the appropriate edior. - */ - private IPath editor; - - /** - * Creates a new instance of the RequestImpl class. - * - * @param siteId the site id - * @param timestamp the timestamp - * @param operation the operation - */ - public RequestImpl(int siteId, Timestamp timestamp, Operation operation) { - this.siteId = siteId; - this.timestamp = timestamp; - this.operation = operation; - this.jid = null; - } - - /** - * Creates a new instance of the RequestImpl class. - * - * @param siteId the site id - * @param timestamp the timestamp - * @param operation the operation - */ - public RequestImpl(int siteId, Timestamp timestamp, Operation operation, JID jid) { - this.siteId = siteId; - this.timestamp = timestamp; - this.operation = operation; - this.jid = jid; - } - - /* - * (non-Javadoc) - * @see de.fu_berlin.inf.dpp.jupiter.Request#getSiteId() - */ - public int getSiteId() { - return siteId; - } - - /* - * (non-Javadoc) - * @see de.fu_berlin.inf.dpp.jupiter.Request#getOperation() - */ - public Operation getOperation() { - return operation; - } - - /* - * (non-Javadoc) - * @see de.fu_berlin.inf.dpp.jupiter.Request#getTimestamp() - */ - public Timestamp getTimestamp() { - return timestamp; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object obj) { - if (this == obj) { - return true; - } else if (obj instanceof Request) { - Request request = (Request) obj; - return siteId == request.getSiteId() - && nullSafeEquals(timestamp, request.getTimestamp()) - && nullSafeEquals(operation, request.getOperation()); - } else { - return false; - } - } - - private boolean nullSafeEquals(Object o1, Object o2) { - if (o1 == o2) { - return true; - } else if (o1 == null || o2 == null) { - return false; - } else { - return o1.equals(o2); - } - } - - /* - * (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - int hashCode = 13 * siteId; - hashCode += (timestamp != null) ? 17 * timestamp.hashCode() : 0; - hashCode += (operation != null) ? 29 * operation.hashCode() : 0; - return hashCode; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - public String toString() { - StringBuffer buffer = new StringBuffer(); - buffer.append("request("); - buffer.append(siteId); - buffer.append(","); - buffer.append(timestamp); - buffer.append(","); - buffer.append(operation); - buffer.append(")"); - return buffer.toString(); - } - - /* - * (non-Javadoc) - * @see de.fu_berlin.inf.dpp.jupiter.Request#getJID() - */ - public JID getJID() { - return jid; - } - - public void setJID(JID jid){ - this.jid = jid; - } - - public IPath getEditorPath() { - return this.editor; - } - - public void setEditorPath(IPath editor) { - this.editor = editor; - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/Serializer.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/Serializer.java deleted file mode 100644 index 6c9d43a91a9d4c9990c6f36c12fe8b9a9261eda1..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/Serializer.java +++ /dev/null @@ -1,63 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal; - -import java.util.HashMap; - -import org.apache.log4j.Logger; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.JupiterClient; -import de.fu_berlin.inf.dpp.concurrent.jupiter.JupiterServer; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.OperationSerializer; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.TransformationException; -import de.fu_berlin.inf.dpp.net.JID; - -public class Serializer extends Thread implements OperationSerializer{ - - private static Logger logger = Logger.getLogger(Serializer.class); - - JupiterServer server; - - private boolean run = true; - - public Serializer(JupiterServer server){ - this.server = server; - start(); - } - - public void run(){ - logger.debug("Start Serializer"); - - Request request = null; - HashMap<JID , JupiterClient> proxies = null; - JupiterClient proxy = null; - while(run){ - try { - /* get next request in queue. */ - request = server.getNextRequestInSynchronizedQueue(); - - proxies = server.getProxies(); - /* 1. execute receive action at appropriate proxy client. */ - proxy = proxies.get(request.getJID()); - Operation op = proxy.receiveRequest(request); - /* 2. execute generate action at other proxy clients. */ - for(JID j : proxies.keySet()){ - proxy = proxies.get(j); - - if(!j.toString().equals(request.getJID().toString())){ - /* create submit op as local proxy operation and send to client. */ - proxy.generateRequest(op); - } - - } - - } catch (InterruptedException e) { - logger.warn("Interrupt Exception",e); - } - catch (TransformationException e) { - logger.error("Transformation Exception ",e); - server.transformationErrorOccured(); - } - } - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/DeleteOperation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/DeleteOperation.java deleted file mode 100644 index 006fc1ef949ddb8d933d9efc367838c576b1fbad..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/DeleteOperation.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * $Id: DeleteOperation.java 2434 2005-12-12 07:49:51Z sim $ - * - * ace - a collaborative editor - * Copyright (C) 2005 Mark Bigler, Simon Raess, Lukas Zbinden - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; - -/** - * The DeleteOperation is used to hold a text together with its position that is - * to be deleted in the document model. - */ -public class DeleteOperation implements Operation { - - /** - * the text to be deleted. - */ - private String text; - - /** - * the position in the document where the text is to be deleted. - */ - private int position; - - /** - * Class constructor. - */ - public DeleteOperation() {} - - /** - * Class constructor. - * - * @param position - * the position into the document - * @param text - * the text to be deleted - */ - public DeleteOperation(int position, String text) { - setPosition(position); - setText(text); - } - - /** - * Class constructor. - * - * @param position - * the position into the document - * @param text - * the text to be deleted - * @param isUndo - * flag to indicate whether this operation is an undo - */ - public DeleteOperation(int position, String text, boolean isUndo) { - setPosition(position); - setText(text); - } - - /** - * Returns the position. - * - * @return the position - */ - public int getPosition() { - return position; - } - - /** - * Sets the position of this operation. - * - * @param position - * the position to set - */ - public void setPosition(int position) { - if (position < 0) { - throw new IllegalArgumentException("position index must be >= 0"); - } - this.position = position; - } - - /** - * Returns the text length. - * - * @return the length of the text - */ - public int getTextLength() { - return text.length(); - } - - /** - * Returns the text to be deleted. - * - * @return the text to be deleted - */ - public String getText() { - return text; - } - - /** - * Sets the text to be deleted. - * - * @param text - * the text to be deleted - */ - public void setText(String text) { - if (text == null) { - throw new IllegalArgumentException("text may not be null"); - } - this.text = text; - } - - /** - * {@inheritDoc} - */ - public String toString() { - return "Delete(" + position + ",'" + text + "')"; - } - - /** - * {@inheritDoc} - */ - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else if (obj == null) { - return false; - } else if (obj.getClass().equals(getClass())) { - DeleteOperation op = (DeleteOperation) obj; - return op.position == position && op.text.equals(text); - } else { - return false; - } - } - - /** - * {@inheritDoc} - */ - public int hashCode() { - int hashcode = position; - hashcode += 13 * text.hashCode(); - return hashcode; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/GOTOInclusionTransformation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/GOTOInclusionTransformation.java deleted file mode 100644 index 4dff27c78c4211e2bc3dc649ecb39f60b694dc9c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/GOTOInclusionTransformation.java +++ /dev/null @@ -1,333 +0,0 @@ -/* - * $Id: GOTOInclusionTransformation.java 2434 2005-12-12 07:49:51Z sim $ - * - * ace - a collaborative editor - * Copyright (C) 2005 Mark Bigler, Simon Raess, Lukas Zbinden - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text; - - -import java.security.InvalidParameterException; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.InclusionTransformation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; - - -/** - * Implementation of the GOTO operational transformation functions. The pseudo code - * can be found in the paper "Achieving Convergence, Causality-preservation, - * and Intention-preservation in Real-time cooperative Editing Systems" by - * Chengzheng Sun, Xiaohua Jia, Yanchun Zhang, Yun Yang, and David Chen. - */ -public class GOTOInclusionTransformation implements InclusionTransformation { - - /** - * Include operation <var>op2</var> into the context of operation - * <var>op1</var>. - * The transformed operation <var>op1'</var> is returned. - * - * @param op1 - * the operation into which another is to be contextually - * included. - * @param op2 - * the operation to be included. - * @param param - * a boolean flag to privilege the first operation <code>op1</code> - * (i.e. remains unchanged) when two insert operations are equivalent - * i.e. they have the same position and origin index. - * @return the transformed operation <var>op1'</var> - */ - public Operation transform(Operation op1, Operation op2, Object param) { - Operation transformedOp; - if (op1 instanceof SplitOperation) { - SplitOperation s = (SplitOperation)op1; - s.setFirst(transform(s.getFirst(), op2, param)); - s.setSecond(transform(s.getSecond(), op2, param)); - transformedOp = s; - } else if (op2 instanceof SplitOperation) { - SplitOperation s = (SplitOperation)op2; - op1 = transform(op1, s.getSecond(), param); - op1 = transform(op1, s.getFirst(), param); - transformedOp = op1; - } else if (op1 instanceof NoOperation) { - transformedOp = clone((NoOperation)op1); - } else if (op2 instanceof NoOperation) { - if (op1 instanceof InsertOperation) { - transformedOp = clone((InsertOperation)op1); - } else { - transformedOp = clone((DeleteOperation)op1); - } - } else if (op1 instanceof InsertOperation && op2 instanceof InsertOperation) { - transformedOp = transform((InsertOperation)op1, (InsertOperation)op2, - ((Boolean)param).booleanValue()); - } else if (op1 instanceof InsertOperation && op2 instanceof DeleteOperation) { - transformedOp = transform((InsertOperation)op1, (DeleteOperation)op2); - } else if (op1 instanceof DeleteOperation && op2 instanceof InsertOperation) { - transformedOp = transform((DeleteOperation)op1, (InsertOperation)op2); - } else if (op1 instanceof DeleteOperation && op2 instanceof DeleteOperation) { - transformedOp = transform((DeleteOperation)op1, (DeleteOperation)op2); - } else { - throw new InvalidParameterException(); - } - return transformedOp; - } - - public int transformIndex(int index, Operation op, Object param) { - if (op instanceof SplitOperation) { - SplitOperation s = (SplitOperation) op; - index = transformIndex(index, s.getSecond(), param); - index = transformIndex(index, s.getFirst(), param); - return index; - } else if (op instanceof NoOperation) { - return index; - } else if (op instanceof InsertOperation) { - int pos = ((InsertOperation) op).getPosition(); - if (index < pos) { - return index; - } else { - return index + ((InsertOperation) op).getTextLength(); - } - } else if (op instanceof DeleteOperation) { - int pos = ((DeleteOperation) op).getPosition(); - if (index <= pos) { - return index; - } else { - return index - ((DeleteOperation) op).getTextLength(); - } - } else { - throw new IllegalArgumentException("Unsupported Operation type: " + op); - } - } - - private Operation transform(InsertOperation insA, InsertOperation insB, - boolean isTransformPrivileged) { - InsertOperation transformedOperation = null; - int posA = insA.getPosition(); - int posB = insB.getPosition(); - int lenB = insB.getTextLength(); - if (posA < posB || posA == posB && insA.getOrigin() < insB.getOrigin() - || posA == posB && insA.getOrigin() == insB.getOrigin() - && isTransformPrivileged) { - /* - * Operation A starts before operation B. - * (B): "ABCD" - * (A): "12" - * (A'): "12" - */ - transformedOperation = clone(insA); - } else { - /* - * Operation A starts in or behind operation B. Index of operation A' must - * be increased by the length of the text of operation B. - * (B): "ABCD" | "ABCD" - * (A): "12" | "12" - * (A'): " 12" | "12" - */ - transformedOperation = new InsertOperation(posA + lenB, insA - .getText(), insA.getOrigin()); - } - return transformedOperation; - } - - private Operation transform(InsertOperation insA, DeleteOperation delB) { - InsertOperation transformedOperation = null; - int posA = insA.getPosition(); - int posB = delB.getPosition(); - int lenB = delB.getTextLength(); - - if (posA <= posB) { - /* - * Operation A starts before or at the same position like operation B. - * (B): "ABCD" | "ABCD" - * (A): "12" | "12" - * (A'): "12" | "12" - */ - transformedOperation = clone(insA); - } else if (posA > (posB + lenB)) { - /* - * Operation A starts after operation B. Index of operation A' must - * be reduced by the length of the text of operation B. - * (B): "ABCD" - * (A): "12" - * (A'): "12" - */ - transformedOperation = new InsertOperation(posA - lenB, insA - .getText(), insA.getOrigin()); - } else { - /* - * Operation A starts in operation B. Index of A' must be the index of - * operation B. - * (B): "ABCD" - * (A): "12" - * (A'): "12" - */ - transformedOperation = new InsertOperation(posB, insA.getText(), - insA.getOrigin()); - } - return transformedOperation; - } - - private Operation transform(DeleteOperation delA, InsertOperation insB) { - Operation transformedOperation = null; - int posA = delA.getPosition(); - int lenA = delA.getTextLength(); - int posB = insB.getPosition(); - int lenB = insB.getTextLength(); - - if (posB >= (posA + lenA)) { - /* - * Operation A is completly before operation B. - * (B): "ABCD" - * (A): "12" - * (A'): "12" - */ - transformedOperation = clone(delA); - } else if (posA >= posB) { - /* - * Operation A starts before or at the same position like operation B. - * (B): "ABCD" | "ABCD" - * (A): "12" | "12" - * (A'): "12" | "12" - */ - transformedOperation = new DeleteOperation(posA + lenB, delA - .getText()); - } else { - /* - * Operation B (insert) is in the range of operation A (delete). Operation A' - * must be splitted up into two delete operations. - * (B): "ABCD" - * (A): "123456" - * (A'): "1" "23456" - */ - DeleteOperation del1 = new DeleteOperation(posA, delA.getText() - .substring(0, posB - posA)); - DeleteOperation del2 = new DeleteOperation(posA + lenB - + (posB - posA), delA.getText() - .substring(posB - posA, lenA)); - transformedOperation = new SplitOperation(del1, del2); - } - return transformedOperation; - } - - private Operation transform(DeleteOperation delA, DeleteOperation delB) { - Operation transformedOperation; - int posA = delA.getPosition(); - int lenA = delA.getTextLength(); - int posB = delB.getPosition(); - int lenB = delB.getTextLength(); - - if (posB >= (posA + lenA)) { - /* - * Operation A is completly before operation B. - * (B): "ABCD" - * (A): "12" - * (A'): "12" - */ - transformedOperation = clone(delA); - } else if (posA >= (posB + lenB)) { - /* - * Operation A starts at the end or after operation B. Index of operation A' - * must be reduced by the length of the text of operation B. - * (B): "ABCD" - * (A): "12" - * (A'): "12" - */ - transformedOperation = new DeleteOperation(posA - lenB, delA - .getText()); - } else { - /* - * Operation A and operation B are overlapping. - */ - if ((posB <= posA) && ((posA + lenA) <= (posB + lenB))) { - /* - * Operation B starts before or at the same position like operation A - * and ends after or at the same position like operation A. - * (B): "ABCD" | "ABCD - * (A): "12" | "12" - * (A'): "" | "" - */ - NoOperation noop = new NoOperation(); - transformedOperation = noop; - } else if ((posB <= posA) && ((posA + lenA) > (posB + lenB))) { - /* - * Operation B starts before or at the same position like operation A - * and ends before operation A. - * (B): "ABCD" - * (A): "12345" - * (A'): "345" - */ - transformedOperation = new DeleteOperation(posB, delA.getText() - .substring(posB + lenB - posA, lenA)); - } else if ((posB > posA) && ((posB + lenB) >= (posA + lenA))) { - /* - * Operation B starts after operation A and ends after or at the - * same position like operation A. - * (B): "ABCD" - * (A): "12345" - * (A'): "12" - */ - transformedOperation = new DeleteOperation(posA, delA.getText() - .substring(0, posB - posA)); - } else { - /* - * Operation B is fully in operation A. - * (B): "ABCD" - * (A): "123456" - * (A'): "16" - */ - transformedOperation = new DeleteOperation(posA, delA.getText() - .substring(0, posB - posA) - + delA.getText().substring(posB + lenB - posA, lenA)); - } - } - return transformedOperation; - } - - /** - * Clone an insert operation and update its transformation history. - * - * @param insA - * @return InsertOperation - */ - private InsertOperation clone(InsertOperation insA) { - InsertOperation cloneOp = new InsertOperation(insA.getPosition(), insA.getText(), - insA.getOrigin()); - return cloneOp; - } - - /** - * Clone a delete operation and update its transformation history. - * - * @param delA - * @return DeleteOperation - */ - private DeleteOperation clone(DeleteOperation delA) { - DeleteOperation cloneOp = new DeleteOperation(delA.getPosition(), delA.getText()); - return cloneOp; - } - - /** - * Clones a no-operation and updates its transformation history. - * - * @param noop - * @return DeleteOperation - */ - private NoOperation clone(NoOperation noop) { - NoOperation cloneOp = new NoOperation(); - return cloneOp; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/InsertOperation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/InsertOperation.java deleted file mode 100644 index 48a4b98ca391be9afb89ce31b1c02f4c2d37aaff..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/InsertOperation.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * $Id: InsertOperation.java 2755 2006-03-06 09:29:34Z zbinl $ - * - * ace - a collaborative editor - * Copyright (C) 2005 Mark Bigler, Simon Raess, Lukas Zbinden - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; - - -/** - * The InsertOperation is used to hold a text together with its position index. - * The text is to be inserted in the document model. - */ -public class InsertOperation implements Operation { - - /** - * the text to be inserted. - */ - private String text; - - /** - * the position index in the document model. - */ - private int position; - - /** - * the origin position index where the insert operation was originally - * intended. This concept could be extended in such a way that two origin - * positions could be compared to each other based on the same context. - * Therefore, if the two positions do not relate on the same document - * context, a least synchronization point (LSP) would have to be determined. - */ - private int origin; - - /** - * Class constructor. - * - */ - public InsertOperation() { - } - - /** - * Class constructor. - * - * @param position - * the position in the document - * @param text - * the text to be inserted - */ - public InsertOperation(int position, String text) { - setPosition(position); - setText(text); - origin = getPosition(); - } - - /** - * Class constructor. - * - * @param position - * the position in the document - * @param text - * the text to be inserted - * @param isUndo - * flag to indicate an undo operation - */ - public InsertOperation(int position, String text, boolean isUndo) { - this(position, text); - origin = getPosition(); - } - - /** - * Class constructor. - * - * @param position - * the position in the document - * @param text - * the text to be inserted - * @param origin - * the origin position of this insert operation - */ - public InsertOperation(int position, String text, int origin) { - this(position, text); - this.origin = origin; - } - - /** - * @param position - * the position in the document - * @param text - * the text to be inserted - * @param origin - * the origin position of this insert operation - * @param isUndo - * flag to indicate an undo operation - */ - public InsertOperation(int position, String text, int origin, - boolean isUndo) { - this(position, text, origin); - } - - /** - * Returns the position. - * - * @return the position - */ - public int getPosition() { - return position; - } - - /** - * Sets the position of this operation. - * - * @param position - * the position to set - */ - public void setPosition(int position) { - if (position < 0) { - throw new IllegalArgumentException("position index must be >= 0"); - } - this.position = position; - } - - /** - * Returns the text to be deleted. - * - * @return the text to be deleted - */ - public String getText() { - return text; - } - - /** - * Returns the text length. - * - * @return the length of the text - */ - public int getTextLength() { - return text.length(); - } - - /** - * Returns the origin position. - * - * @return the origin position - */ - public int getOrigin() { - return origin; - } - - /** - * Sets the origin position. - * - * @param origin - * the origin position to set - */ - public void setOrigin(int origin) { - if (origin < 0) { - throw new IllegalArgumentException("origin index must be >= 0"); - } - this.origin = origin; - } - - /** - * Sets the text to be deleted. - * - * @param text - * the text to be deleted - */ - public void setText(String text) { - if (text == null) { - throw new IllegalArgumentException("text may not be null"); - } - this.text = text; - } - - /** - * {@inheritDoc} - */ - public String toString() { - return "Insert(" + position + ",'" + (text != null ? ((text.length() > 20) ? text.substring(0, 20) + "..." : text) : "") + "'," + origin + ")"; - } - - /** - * {@inheritDoc} - */ - public boolean equals(Object obj) { - if (this == obj) { - return true; - } else if (obj == null) { - return false; - } else if (obj.getClass().equals(getClass())) { - InsertOperation op = (InsertOperation) obj; - return op.position == position && op.text.equals(text) - && op.origin == origin; - } else { - return false; - } - } - - /** - * {@inheritDoc} - */ - public int hashCode() { - int hashcode = position; - hashcode += 13 * origin; - hashcode += 13 * text.hashCode(); - return hashcode; - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/NoOperation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/NoOperation.java deleted file mode 100644 index b863d5ce8df17e110b7dd698c6609f7fc4aa9145..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/NoOperation.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * $Id$ - * - * ace - a collaborative editor - * Copyright (C) 2005 Mark Bigler, Simon Raess, Lukas Zbinden - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; - -/** - * The NoOperation is used to hold a empty text together with the position zero. - */ -public class NoOperation implements Operation { - - /** - * Class constructor. - */ - public NoOperation() {} - - /** - * Returns the position. - * - * @return the position - */ - public int getPosition() { - return 0; - } - - /** - * Sets the position of this operation. - * - * @param position - * the position to set - */ - public void setPosition(int position) { - throw new UnsupportedOperationException(); - } - - /** - * Returns the text length. - * - * @return the length of the text - */ - public int getTextLength() { - return 0; - } - - /** - * Returns the text to be deleted. - * - * @return the text to be deleted - */ - public String getText() { - return ""; - } - - /** - * Sets the text to be deleted. - * - * @param text - * the text to be deleted - */ - public void setText(String text) { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - */ - public String toString() { - return "Noop(0,'')"; - } - - /** - * {@inheritDoc} - */ - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else if (obj == null) { - return false; - } else if (obj.getClass().equals(getClass())) { - return true; - } else { - return false; - } - } - - /** - * {@inheritDoc} - */ - public int hashCode() { - int hashcode = 37; - return hashcode; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/SplitOperation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/SplitOperation.java deleted file mode 100644 index eede344b2ee69f815af817945a7ad7e9780863b0..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/SplitOperation.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * $Id: SplitOperation.java 2434 2005-12-12 07:49:51Z sim $ - * - * ace - a collaborative editor - * Copyright (C) 2005 Mark Bigler, Simon Raess, Lukas Zbinden - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text; - - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; - -/** - * The SplitOperation contains two operations. It is used - * when an operation needs to be split up under certain - * transformation conditions. - * - * @see ch.iserver.ace.algorithm.Operation - */ -public class SplitOperation implements Operation { - - /** - * The first operation. - */ - private Operation op1; - - /** - * The second operation. - */ - private Operation op2; - - /** - * Class constructor. - */ - public SplitOperation() {} - - /** - * Class constructor. - * - * @param op1 the first operation - * @param op2 the second operation - */ - public SplitOperation(Operation op1, Operation op2) { - this.op1 = op1; - this.op2 = op2; - } - - /** - * Returns the first operation. - * - * @return the first operation - */ - public Operation getFirst() { - return op1; - } - - /** - * Sets the first operation. - * - * @param op1 the first operation - */ - public void setFirst(Operation op1) { - this.op1 = op1; - } - - /** - * Returns the second operation. - * - * @return the second operation - */ - public Operation getSecond() { - return op2; - } - - /** - * Sets the second operation. - * - * @param op2 the second operation - */ - public void setSecond(Operation op2) { - this.op2 = op2; - } - - /** - * {@inheritDoc} - */ - public String toString() { - return "Split(" + op1 + ", " + op2 + ")"; - } - - /** - * {@inheritDoc} - */ - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else if (obj == null) { - return false; - } else if (obj.getClass().equals(getClass())) { - SplitOperation op = (SplitOperation) obj; - return op.getFirst().equals(op1) && op.getSecond().equals(op2); - } else { - return false; - } - } - - /** - * {@inheritDoc} - */ - public int hashCode() { - int hashcode = op1.hashCode(); - hashcode += 17 * op2.hashCode(); - return hashcode; - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/TimestampOperation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/TimestampOperation.java deleted file mode 100644 index 47695dcc89bf236f0e21c81d2612d24a63890756..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/TimestampOperation.java +++ /dev/null @@ -1,95 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; - -/** - * This operation update have new vector time for the algorithm. - * @author orieger - * - */ - -public class TimestampOperation implements Operation{ - - /** - * - */ - private static final long serialVersionUID = 2756378905499193184L; - - - /** - * Returns the position. - * - * @return the position - */ - public int getPosition() { - return 0; - } - - /** - * Sets the position of this operation. - * - * @param position - * the position to set - */ - public void setPosition(int position) { - throw new UnsupportedOperationException(); - } - - /** - * Returns the text length. - * - * @return the length of the text - */ - public int getTextLength() { - return 0; - } - - /** - * Returns the text to be deleted. - * - * @return the text to be deleted - */ - public String getText() { - return ""; - } - - /** - * Sets the text to be deleted. - * - * @param text - * the text to be deleted - */ - public void setText(String text) { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - */ - public String toString() { - return "Timestamp(0,'')"; - } - - /** - * {@inheritDoc} - */ - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else if (obj == null) { - return false; - } else if (obj.getClass().equals(getClass())) { - return true; - } else { - return false; - } - } - - /** - * {@inheritDoc} - */ - public int hashCode() { - int hashcode = 38; - return hashcode; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/ConcurrentDocumentManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/ConcurrentDocumentManager.java deleted file mode 100644 index 2ab465c5cc50f30a898f1687debdc9100cd90dac..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/ConcurrentDocumentManager.java +++ /dev/null @@ -1,725 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.management; - -import java.util.HashMap; -import java.util.List; -import java.util.Vector; - -import org.apache.log4j.Logger; -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.activities.EditorActivity; -import de.fu_berlin.inf.dpp.activities.FileActivity; -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.activities.TextEditActivity; -import de.fu_berlin.inf.dpp.activities.EditorActivity.Type; -import de.fu_berlin.inf.dpp.concurrent.ConcurrentManager; -import de.fu_berlin.inf.dpp.concurrent.IDriverDocumentManager; -import de.fu_berlin.inf.dpp.concurrent.jupiter.JupiterClient; -import de.fu_berlin.inf.dpp.concurrent.jupiter.JupiterServer; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.RequestForwarder; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp; -import de.fu_berlin.inf.dpp.concurrent.jupiter.TransformationException; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.JupiterDocumentClient; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.JupiterDocumentServer; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.JupiterVectorTime; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.RequestImpl; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.DeleteOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.InsertOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.SplitOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.TimestampOperation; -import de.fu_berlin.inf.dpp.net.IActivitySequencer; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.util.FileUtil; - -public class ConcurrentDocumentManager implements ConcurrentManager { - - private static Logger logger = Logger.getLogger(Logger.class); - - /** Jupiter server instance documents */ - private HashMap<IPath, JupiterDocumentServer> concurrentDocuments; - - /** current open editor at client side. */ - private HashMap<IPath, JupiterClient> clientDocs; - - // private List<JID> drivers; - - private JID host; - - private JID myJID; - - private Side side; - - private RequestForwarder forwarder; - - private IActivitySequencer sequencer; - - private IDriverDocumentManager driverManager; - - private ISharedProject sharedProject; - - public ConcurrentDocumentManager(Side side, User host, JID myJID, - ISharedProject sharedProject) { - - if (side == Side.HOST_SIDE) { - concurrentDocuments = new HashMap<IPath, JupiterDocumentServer>(); - } - - this.sharedProject = sharedProject; - this.clientDocs = new HashMap<IPath, JupiterClient>(); - // drivers = new Vector<JID>(); - this.driverManager = DriverDocumentManager.getInstance(); - this.side = side; - this.host = host.getJid(); - this.myJID = myJID; - } - - public void setActivitySequencer(IActivitySequencer sequencer) { - this.sequencer = sequencer; - } - - public void setRequestForwarder(RequestForwarder f) { - this.forwarder = f; - } - - public RequestForwarder getRequestForwarder() { - return this.forwarder; - } - - /** - * - */ - public IActivity activityCreated(IActivity activity) { - - editorActivitiy(activity); - - if (createdTextEditActivity(activity)) { - /* handled by jupiter and is sended by request transmitting. */ - return null; - } - return activity; - } - - /** - * handled closed editor activity to remove the local jupiter clients. - * - * @param activity - */ - private void editorActivitiy(IActivity activity) { - if (activity instanceof EditorActivity) { - EditorActivity editor = (EditorActivity) activity; - -// if (isHostSide()) { - if (editor.getType() == Type.Saved) { - // calculate checksum for saved file - long checksum = FileUtil.checksum(sharedProject - .getProject().getFile(editor.getPath())); - editor.setChecksum(checksum); - logger.debug("Add checksumme to created editor save activity : " + checksum - + " for path : " + editor.getPath().toOSString()); - } -// } - // else{ - // if(editor.getType() == Type.Saved){ - // long checksum = - // FileUtil.checksum(sharedProject.getProject().getFile(editor.getPath())); - // System.out.println("Checksumme on client side : "+checksum+ " for - // path : "+editor.getPath().toOSString()); - // if(checksum != editor.getChecksum()){ - // System.out.println("Problem!"); - // } - // } - // } - - } - } - - private void fileActivity(IActivity activity) { - if (activity instanceof FileActivity) { - - FileActivity file = (FileActivity) activity; - if (file.getType() == FileActivity.Type.Created) { - if (isHostSide()) { - - } - } - if (file.getType() == FileActivity.Type.Removed) { - if (isHostSide()) { - /* remove jupiter document server */ - if (concurrentDocuments.containsKey(file.getPath())) { - concurrentDocuments.remove(file.getPath()); - } - } - - // Client Side - if (clientDocs.containsKey(file.getPath())) { - clientDocs.remove(file.getPath()); - } - } - } - } - - /** - * handles text edit activities with jupiter. - * - * @param activity - * @return true if activity is transformed with jupiter. - */ - private boolean createdTextEditActivity(IActivity activity) { - - if (activity instanceof TextEditActivity) { - TextEditActivity textEdit = (TextEditActivity) activity; - // if (!isHostSide()) { - /** - * lokal erzeugte operation beim client 1. Aufruf von - * generateRequest beim client. Änderungen wurden bereits im Editor - * geschrieben. 2. versenden der Änderungen an Server (später) - */ - JupiterClient jupClient = null; - /* no jupiter client already exists for this editor text edit */ - if (!clientDocs.containsKey(textEdit.getEditor())) { - jupClient = new JupiterDocumentClient(this.myJID, - this.forwarder, textEdit.getEditor()); -// jupClient.setEditor(textEdit.getEditor()); - clientDocs.put(textEdit.getEditor(), jupClient); - } - - /* generate request. */ - jupClient = clientDocs.get(textEdit.getEditor()); - if (jupClient != null) { - Operation op = getOperation(textEdit); - /* sync with local jupiter client */ - Request req = jupClient.generateRequest(op); - - /* already set and forward inside of jup client. */ - // /* add appropriate Editor path. */ - // req.setEditorPath(textEdit.getEditor()); - // /* transmit request */ - // forwarder.forwardOutgoingRequest(req); - return true; - } - // } - } - return false; - } - - private void execTextEditActivity(Request request) { - - // if (!isHostSide()) { - /** - * lokal erzeugte operation beim client 1. Aufruf von generateRequest - * beim client. Änderungen wurden bereits im Editor geschrieben. 2. - * versenden der Änderungen an Server (später) - */ - JupiterClient jupClient = null; - /* no jupiter client already exists for this editor text edit */ - if (!clientDocs.containsKey(request.getEditorPath())) { - jupClient = new JupiterDocumentClient(this.myJID, this.forwarder, request.getEditorPath()); -// jupClient.setEditor(request.getEditorPath()); - clientDocs.put(request.getEditorPath(), jupClient); - } - - /* generate request. */ - jupClient = clientDocs.get(request.getEditorPath()); - if (jupClient != null) { - /* operational transformation. */ - Operation op; - try { - op = jupClient.receiveRequest(request); - } catch (TransformationException e) { - logger.error("Error during transformation: ", e); - - /* create save activity. */ - IActivity activity = new EditorActivity(Type.Saved, request.getEditorPath()); - /* execute save activity and start consistency check. */ - sequencer.exec(activity); - return; - } - - for (TextEditActivity textEdit : getTextEditActivity(op)) { - textEdit.setEditor(request.getEditorPath()); - textEdit.setSource(request.getJID().toString()); - /* execute activity in activity sequencer. */ - sequencer.execTransformedActivity(textEdit); - } - // return textEdit; - } - // } - // return null; - } - - public IActivity exec(IActivity activity) { - - if (activity instanceof EditorActivity) { - EditorActivity editorAc = (EditorActivity) activity; - - if (isHostSide()) { - JID sourceJID = new JID(editorAc.getSource()); - - /* inform driver document manager */ - driverManager.receiveActivity(activity); - - /* if one driver activate a new editor. */ - // if (drivers.contains(sourceJID) - if (driverManager.isDriver(sourceJID) - && (editorAc.getType() == Type.Activated || editorAc - .getType() == Type.Closed)) { - /* start jupiter proxy for this driver. */ - if (concurrentDocuments.containsKey(editorAc.getPath())) { - JupiterServer server = concurrentDocuments.get(editorAc - .getPath()); - - /* client has no proxy for this editor. */ - if (!server.isExist(sourceJID)) { - if (editorAc.getType() == Type.Activated) { - server.addProxyClient(sourceJID); - /* update vector time for new proxy. */ - // TODO: stop serializer and after this update - // vector time. - server.updateVectorTime(myJID, sourceJID); - // TODO: forward vector time method. - - /* get vector time of host for this editor path. */ - try { - - JupiterClient jupC = clientDocs - .get(editorAc.getPath()); - if (jupC != null) { - Timestamp ts = jupC.getTimestamp(); - - /* create update vector time request. */ - Request updateRequest = new RequestImpl( - 0, new JupiterVectorTime(ts - .getComponents()[1], ts - .getComponents()[0]), - new TimestampOperation()); - updateRequest.setEditorPath(editorAc - .getPath()); - updateRequest.setJID(sourceJID); - - forwarder - .forwardOutgoingRequest(updateRequest); - } - } catch (Exception e) { - - logger.error( - "Error during get timestamp of host proxy for " - + editorAc.getPath(), e); - } - } - } else { - /* remove proxy for this jid. */ - if (editorAc.getType() == Type.Closed) { - server.removeProxyClient(sourceJID); - } - } - } else { - /* create new jupiter proxy client. */ - if (editorAc.getType() == Type.Activated) { - Request createRequest = new RequestImpl(0, - new JupiterVectorTime(0, 0), - new TimestampOperation()); - createRequest.setEditorPath(editorAc.getPath()); - createRequest.setJID(sourceJID); - - } - } - } - } - } - - if (activity instanceof TextEditActivity) { - // check for jupiter client documents - TextEditActivity text = (TextEditActivity) activity; - if (clientDocs.containsKey(text.getEditor())) { - /* activity have to be transformed with jupiter on this client. */ - return null; - } - } - - /* handles file activities. e.g. renamed files etc. */ - fileActivity(activity); - - return activity; - } - - public boolean isHostSide() { - if (side == Side.HOST_SIDE) { - return true; - } - return false; - } - - public boolean isHost(JID jid) { - if (jid.equals(host)) { - return true; - } - return false; - } - - public void setHost(JID host) { - this.host = host; - } - - /** - * convert TextEditActivity to Operation op - * - * @param text - * @return - */ - public Operation getOperation(TextEditActivity text) { - - Operation op = null; - // delete activity - if (text.replace > 0 && text.text.length() == 0) { - /* string placeholder in length of delete area. */ - String placeholder = ""; - for (int i = 0; i < text.replace; i++) { - placeholder += 1; - } - op = new DeleteOperation(text.offset, placeholder); - } - // insert activity - if (text.replace == 0 && text.text.length() > 0) { - op = new InsertOperation(text.offset, text.text); - } - // replace operation has to split into delete and insert operation - if (text.replace > 0 && text.text.length() > 0) { - /* string placeholder in length of delete area. */ - String placeholder = ""; - for (int i = 0; i < text.replace; i++) { - placeholder += 1; - } - op = new SplitOperation(new DeleteOperation(text.offset, - placeholder), new InsertOperation(text.offset, text.text)); - } - return op; - } - - /** - * Convert Operation op to text edit activity. NoOperation will ignore. - * - * @param op - * incoming transformed operation. - * @return List with executable text edit activities. - */ - public List<TextEditActivity> getTextEditActivity(Operation op) { - List<TextEditActivity> result = new Vector<TextEditActivity>(); - TextEditActivity textEdit = null; - if (op instanceof DeleteOperation) { - DeleteOperation del = (DeleteOperation) op; - textEdit = new TextEditActivity(del.getPosition(), "", del - .getTextLength()); - result.add(textEdit); - } - if (op instanceof InsertOperation) { - InsertOperation ins = (InsertOperation) op; - textEdit = new TextEditActivity(ins.getPosition(), ins.getText(), 0); - result.add(textEdit); - } - if (op instanceof SplitOperation) { - SplitOperation split = (SplitOperation) op; - TextEditActivity op1 = getTextEditActivity(split.getFirst()).get(0); - TextEditActivity op2 = getTextEditActivity(split.getSecond()) - .get(0); - - /* - * if operation one is delete operation the offset of second - * operation has to modified. - */ - if (op1.replace > 0 && op1.text.length() == 0 && op2.replace > 0 - && op2.text.length() == 0) { - op2 = new TextEditActivity(op2.offset - op1.replace, "", - op2.replace); - } - result.add(op1); - result.add(op2); - } - - return result; - } - - // private void editorActivitiy(IActivity activity, boolean local) { - // if (!isHostSide() || local) { - // if (activity instanceof EditorActivity) { - // EditorActivity editor = (EditorActivity) activity; - // /* if new editor opened */ - // if (editor.getType() == Type.Activated) { - // /* no jupiter client exists for this editor */ - // if (!clientDocs.containsKey(editor.getPath())) { - // // TODO: add Request forwarder - // JupiterClient jupiter = new JupiterDocumentClient( - // myJID, null); - // jupiter.setEditor(editor.getPath()); - // /* add to current docs */ - // clientDocs.put(editor.getPath(), jupiter); - // } - // // send EditorActivity to project host. - // - // } - // if (editor.getType() == Type.Closed) { - // /* remove editor form jupiter concurrent mechanism. */ - // if (clientDocs.containsKey(editor.getPath())) { - // clientDocs.remove(editor.getPath()); - // } - // } - // } - // } - // /* managing of jupiter server documents. */ - // if (isHostSide()) { - // /* Editor activities. */ - // if (activity instanceof EditorActivity) { - // EditorActivity editor = (EditorActivity) activity; - // /* if new editor opened */ - // if (editor.getType() == Type.Activated) { - // /* create new jupiter document server. */ - // if (!concurrentDocuments.containsKey(editor.getPath())) { - // JupiterDocumentServer jup = new JupiterDocumentServer( - // forwarder); - // jup.setEditor(editor.getPath()); - // - // /* create host proxy */ - // jup.addProxyClient(host.getJid()); - // /* create client proxy if remote activity. */ - // if (!local) { - // jup.addProxyClient(new JID(editor.getSource())); - // } - // /* add to server list. */ - // concurrentDocuments.put(editor.getPath(), jup); - // - // /* - // * create host jupiter client for local request - // * handling. - // */ - // if (!clientDocs.containsKey(editor.getPath())) { - // JupiterClient jupiter = new JupiterDocumentClient( - // myJID, null); - // jupiter.setEditor(editor.getPath()); - // } - // - // } - // } - // /* if document closed. */ - // if (editor.getType() == Type.Closed) { - // if (!local) { - // /* remove remote client from proxy list. */ - // JupiterDocumentServer serverDoc = concurrentDocuments - // .get(editor.getPath()); - // if (serverDoc != null) { - // /* remove remote client. */ - // serverDoc.removeProxyClient(new JID(editor - // .getSource())); - // /* TODO: if only host is exists. */ - // // if(serverDoc.getProxies().size() == 1){ - // // - // // } - // } - // } - // } - // } - // } - // } - - /* - * 1. hinzufügen und löschen von jupiter servern 2. list mit transmitter - * threads, die Nachrichten aus den outgoing queues versenden. 3. - * Schnittstelle vom Itransmitter zu den einzelnen jupiter document servern, - * um die Nachrichten vom Itransmitter weiterzuleiten. - * - * - */ - - private JupiterDocumentServer initDocumentServer(IPath path){ - JupiterDocumentServer docServer = null; - /* create new document server. */ - docServer = new JupiterDocumentServer(forwarder); - // docServer = new JupiterDocumentServer(); - docServer.setEditor(path); - /* create new local host document client. */ - docServer.addProxyClient(host); - return docServer; - } - - /** - * sync received request with right jupiter server document and local - * client. - * - */ - public void receiveRequest(Request request) { - - /* 1. Sync with jupiter server component. */ - if (isHostSide()) { - - /* if host side and server jupiter side of request */ - if (isHost(request.getJID()) && request.getSiteId() == 0) { - /* request already has transformed and have to be execute. */ - // return execTextEditActivity(request); - execTextEditActivity(request); - return; - } - - JupiterDocumentServer docServer = null; - /** - * if no jupiter document server exists. - */ - if (!concurrentDocuments.containsKey(request.getEditorPath())) { -// /* create new document server. */ -// docServer = new JupiterDocumentServer(forwarder); -// // docServer = new JupiterDocumentServer(); -// docServer.setEditor(request.getEditorPath()); -// /* create new local host document client. */ -// docServer.addProxyClient(host); - - docServer = initDocumentServer(request.getEditorPath()); - - if (!isHost(request.getJID())) { - // - driverManager.addDriverToDocument(request.getEditorPath(), - request.getJID()); - docServer.addProxyClient(request.getJID()); - } - concurrentDocuments.put(request.getEditorPath(), docServer); - } - docServer = concurrentDocuments.get(request.getEditorPath()); - try { - /* check if sender id exists in proxy list. */ - if (!docServer.getProxies().containsKey(request.getJID())) { - docServer.addProxyClient(request.getJID()); - } - } catch (InterruptedException ie) { - logger.error("Error during get proxy list of jupiter server.", - ie); - } - - /* sync request with jupiter document server. */ - docServer.addRequest(request); - - return; - } else { - /* update timestamp of local jupiter client. */ - if (request.getOperation() instanceof TimestampOperation) { - if (clientDocs.containsKey(request.getEditorPath())) { - logger.info("update vector time : " - + request.getEditorPath()); - JupiterClient jupClient = clientDocs.get(request - .getEditorPath()); - try { - jupClient.updateVectorTime(request.getTimestamp()); - } catch (TransformationException e) { - logger.error("Error during update jupiter client for " - + request.getEditorPath(), e); - } - } else { - /* if no jupiter client exists. */ - JupiterClient client = new JupiterDocumentClient( - this.myJID, this.forwarder, request.getEditorPath()); -// client.setEditor(request.getEditorPath()); - try { - client.updateVectorTime(request.getTimestamp()); - clientDocs.put(request.getEditorPath(), client); - } catch (TransformationException e) { - logger.error("Error during update jupiter client for " - + request.getEditorPath(), e); - } - - } - } else { - - /* - * 2. receive request in local client component and return the - * transformed operation as IActivity. - */ - execTextEditActivity(request); - // return execTextEditActivity(request); - } - } - } - - public void driverChanged(JID driver, boolean replicated) { - /* - * 1. check if driver exists. 2. add new driver or remove driver. 3. - */ - // HOST - if (isHostSide()) { - /* if driver changed to observer */ - // if (drivers.contains(driver)) { - if (driverManager.isDriver(driver)) { - userLeft(driver); - } - // /* new driver added to project. */ - // else { - // drivers.add(driver); - // //TODO: add driver to current open document proxy ? - // } - } - // CLIENT - else { - if (driver.equals(myJID)) { - clientDocs.clear(); - } - } - - } - - public void userJoined(JID user) { - // do nothing - - } - - public void userLeft(JID user) { - if (isHostSide()) { - /* remove user from driver list */ - // drivers.remove(user); - /* remove user proxies from jupiter server. */ - for (JupiterServer server : concurrentDocuments.values()) { - if (server.isExist(user)) { - server.removeProxyClient(user); - - /* if only host has an proxy */ - - } - } - } - } - - /** - * reset jupiter document server component. - */ - public void resetJupiterDocument(IPath path) { - //host side - if (isHostSide()) { - if (concurrentDocuments.containsKey(path)) { - /* remove document server.*/ - concurrentDocuments.remove(path); - /* init new server. */ - JupiterDocumentServer doc = initDocumentServer(path); - logger.debug("Reset jupiter server : "); - /* add proxy documents for active driver. */ - for(JID jid : driverManager.getDriverForDocument(path)){ - doc.addProxyClient(jid); - logger.debug("add driver proxy : "+jid); - } - - concurrentDocuments.put(path,doc); - - } else { - logger.error("No jupter document exists for " - + path.toOSString()); - } - } - - //reset client documents - if(clientDocs.containsKey(path)){ - clientDocs.remove(path); - clientDocs.put(path, new JupiterDocumentClient(this.myJID, this.forwarder,path)); - logger.debug("Reset jupiter client doc : "+this.myJID); - }else{ - logger.error("No jupter document exists for "+ path.toOSString()); - } - - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/DriverDocument.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/DriverDocument.java deleted file mode 100644 index 7c8bee2dc67c514701555b25b4dacdcef2df6440..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/DriverDocument.java +++ /dev/null @@ -1,73 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.management; - -import java.util.List; -import java.util.Vector; - -import org.apache.log4j.Logger; -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.concurrent.IDriverManager; -import de.fu_berlin.inf.dpp.net.JID; - -public class DriverDocument implements IDriverManager{ - - private static Logger logger = Logger.getLogger(DriverDocument.class); - - private IPath editor; - - private List<JID> currentDriver; - - public DriverDocument(IPath editor){ - this.editor = editor; - this.currentDriver = new Vector<JID>(); - } - - public IPath getEditor(){ - return this.editor; - } - - public void addDriver(JID jid) { - /* if driver not exists in list. */ - if(!isDriver(jid)){ - this.currentDriver.add(jid); - }else{ - logger.debug("Driver "+jid+" is already Driver for "+this.editor.lastSegment().toString()); - } - } - - public boolean isDriver(JID jid) { - return currentDriver.contains(jid); - } - - public boolean noDriver(){ - return currentDriver.isEmpty(); - } - - public void removeDriver(JID jid) { - if(isDriver(jid)){ - this.currentDriver.remove(jid); - }else{ - logger.warn("JID "+jid+" is not driver for this document "+this.editor.lastSegment().toString()); - } - - } - - /* - * (non-Javadoc) - * @see de.fu_berlin.inf.dpp.concurrent.IDriverManager#exclusiveDriver() - */ - public boolean exclusiveDriver() { - if(currentDriver.size() > 1){ - return false; - } - return true; - } - - /* - * (non-Javadoc) - * @see de.fu_berlin.inf.dpp.concurrent.IDriverManager#getActiveDriver() - */ - public List<JID> getActiveDriver() { - return currentDriver; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/DriverDocumentManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/DriverDocumentManager.java deleted file mode 100644 index 9ec8f6d92df176bf0fa5b80a14ef38ecbb00476e..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/DriverDocumentManager.java +++ /dev/null @@ -1,240 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.management; - -/** - * this manager class handles driver event and the appropriate documents. - * Additional this class is managing exclusive lock for temporary single driver - * actions. - */ -import java.util.HashMap; -import java.util.List; -import java.util.Vector; - -import org.apache.log4j.Logger; -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.activities.EditorActivity; -import de.fu_berlin.inf.dpp.activities.FileActivity; -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.activities.RoleActivity; -import de.fu_berlin.inf.dpp.concurrent.IDriverDocumentManager; -import de.fu_berlin.inf.dpp.net.JID; - -/** - * - * @author orieger - * - */ -public class DriverDocumentManager implements IDriverDocumentManager { - - private static Logger logger = Logger - .getLogger(DriverDocumentManager.class); - - /* list of all active driver. */ - private List<JID> activeDriver; - - /* list of documents with appropriate drivers. */ - private HashMap<IPath, DriverDocument> documents; - - private static DriverDocumentManager manager; - - /** - * private constructor for singleton pattern. - */ - private DriverDocumentManager() { - this.activeDriver = new Vector<JID>(); - this.documents = new HashMap<IPath, DriverDocument>(); - } - - /** - * get instance of this singleton object - * - * @return instance of DriverDocumentManager - */ - public static DriverDocumentManager getInstance() { - /* at first time, create new manager. */ - if (manager == null) { - manager = new DriverDocumentManager(); - } - return manager; - } - - /** - * @param jid - * JID of the driver - * @return true if driver exists in active driver list, false otherwise - */ - public boolean isDriver(JID jid) { - if(jid != null){ - return activeDriver.contains(jid); - } - else{ - System.out.println("jid null"); - } - return false; - } - - /* - * (non-Javadoc) - * @see de.fu_berlin.inf.dpp.concurrent.IDriverDocumentManager#getDriverForDocument(org.eclipse.core.runtime.IPath) - */ - public List<JID> getDriverForDocument(IPath path){ - if(documents.containsKey(path)){ - List<JID> drivers = documents.get(path).getActiveDriver(); - return drivers; - } - return new Vector<JID>(); - } - - /* - * (non-Javadoc) - * @see de.fu_berlin.inf.dpp.concurrent.IDriverManager#getActiveDriver() - */ - public List<JID> getActiveDriver(){ - return activeDriver; - } - - public void addDriver(JID jid) { -// if (user.getUserRole() == UserRole.OBSERVER) { -// logger.error("User " + user.getJid() + " has not driver status! "); -// } - logger.debug("add driver for jid: "+jid); - if(!this.activeDriver.contains(jid)){ - this.activeDriver.add( jid); - } - } - - public void addDriverToDocument(IPath path, JID jid){ - addDriver(jid); - - logger.debug("add activer driver "+jid+" to document "+path.lastSegment().toString()); - /* add driver to new document. */ - DriverDocument doc = documents.get(path); - if(doc == null || !documents.containsKey(path) ){ - logger.debug("New document creates for "+path.lastSegment().toString()); - /* create new instance of this documents. */ - doc = new DriverDocument(path); - documents.put(path, doc); - } - if(!doc.isDriver(jid)){ - doc.addDriver(jid); - } - } - - public void removeDriver(JID jid) { - logger.debug("remove driver "+jid); - - /* remove driver from all documents */ - for(IPath path : documents.keySet()){ - removeDriverFromDocument(path, jid); - } - - this.activeDriver.remove(jid); - - } - - /** - * remove driver from document and delete empty documents. - * @param path of the document - * @param jid removable driver - */ - private void removeDriverFromDocument(IPath path, JID jid){ - DriverDocument doc = documents.get(path); - if(doc.isDriver(jid)){ - doc.removeDriver(jid); - } - /* check for other driver or delete if no other driver exists. */ - if(doc.noDriver()){ - logger.debug("no driver exists for document "+path.lastSegment().toString()+". Document delete from driver manager."); - /* delete driver document. */ - documents.remove(doc.getEditor()); - } - } - - /** - * new driver activity received and has to be managed. - * - * @param activity - */ - public void receiveActivity(IActivity activity) { - JID jid = new JID(activity.getSource()); - - /* if user is an active driver */ - if (isDriver(jid)) { - - /* editor activities. */ - if (activity instanceof EditorActivity) { - EditorActivity edit = (EditorActivity) activity; - - logger.debug("receive activity of "+jid+" for editor "+edit.getPath().lastSegment()+" and action "+edit.getType()); - - /* editor has activated. */ - if(edit.getType() == EditorActivity.Type.Activated){ - /* add driver to new document. */ - addDriverToDocument(edit.getPath(), jid); - } - /* editor has closed. */ - if(edit.getType() == EditorActivity.Type.Closed){ - /* remove driver*/ - if(documents.containsKey(edit.getPath())){ - - removeDriverFromDocument(edit.getPath(), jid); - - }else{ - logger.warn("No driver document exists for "+edit.getPath()); - } - } - } - if (activity instanceof RoleActivity) { - - } - - if (activity instanceof FileActivity) { - FileActivity file = (FileActivity) activity; - /* if file has been removed, delete appropriate driver document. */ - if(file.getType() == FileActivity.Type.Removed){ - documents.remove(file.getPath()); - } - } - } - else{ - logger.debug("JID "+jid+" isn't an active driver."); - } - } - - public void driverChanged(JID driver, boolean replicated) { - if(isDriver(driver)){ - removeDriver(driver); - } - else{ - addDriver(driver); - } - - } - - public void userJoined(JID user) { - // nothing to do - - } - - public void userLeft(JID user) { - if(isDriver(user)){ - /* remove driver status. */ - removeDriver(user); - } - - } - - /* - * (non-Javadoc) - * @see de.fu_berlin.inf.dpp.concurrent.IDriverManager#exclusiveDriver() - */ - public boolean exclusiveDriver() { - boolean result = true; - if(activeDriver.size() > 1){ - result = false; - } - return result; - } - - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/OutgoingMessageForwarder.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/OutgoingMessageForwarder.java deleted file mode 100644 index bba4ca0018c8a065e11c7076699aacc734e0cfd8..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/OutgoingMessageForwarder.java +++ /dev/null @@ -1,43 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.management; - -import java.util.List; -import java.util.Vector; - -import org.apache.log4j.Logger; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.RequestForwarder; - -public class OutgoingMessageForwarder implements RequestForwarder { - - private static Logger logger = Logger.getLogger(OutgoingMessageForwarder.class); - - /** outgoing queue to transfer request to appropriate clients. */ - public List<Request> outgoingQueue; - - public OutgoingMessageForwarder(){ - this.outgoingQueue = new Vector<Request>(); - } - - public synchronized void forwardOutgoingRequest(Request req) { - /* add request to outgoing queue. */ - outgoingQueue.add(req); - - logger.debug("add request to outgoing queue : "+req.getJID()+" "+req.getOperation()); - notifyAll(); - } - - public synchronized Request getNextOutgoingRequest() throws InterruptedException { - Request req = null; - /* get next message and transfer to client.*/ - while(!(outgoingQueue.size() >0)){ - wait(); - } - /* remove first queue element. */ - req = outgoingQueue.remove(0); - - logger.debug("read next request from outgoing queue: "+req.getJID()+" "+req.getOperation()); - return req; - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/EditorManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/EditorManager.java deleted file mode 100644 index f9fa43d683f88e7d04dbcd6b57b53b3794531182..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/EditorManager.java +++ /dev/null @@ -1,1018 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.editor; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.DocumentEvent; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IDocumentExtension4; -import org.eclipse.jface.text.IDocumentListener; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.text.TextSelection; -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jface.text.source.IAnnotationModel; -import org.eclipse.jface.text.source.ILineRange; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.texteditor.IDocumentProvider; -import org.eclipse.ui.texteditor.IElementStateListener; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.activities.EditorActivity; -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.activities.TextEditActivity; -import de.fu_berlin.inf.dpp.activities.TextSelectionActivity; -import de.fu_berlin.inf.dpp.activities.ViewportActivity; -import de.fu_berlin.inf.dpp.activities.EditorActivity.Type; -import de.fu_berlin.inf.dpp.editor.annotations.AnnotationSaros; -import de.fu_berlin.inf.dpp.editor.annotations.ContributionAnnotation; -import de.fu_berlin.inf.dpp.editor.annotations.SelectionAnnotation; -import de.fu_berlin.inf.dpp.editor.annotations.ViewportAnnotation; -import de.fu_berlin.inf.dpp.editor.internal.ContributionHelper; -import de.fu_berlin.inf.dpp.editor.internal.EditorAPI; -import de.fu_berlin.inf.dpp.editor.internal.IEditorAPI; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.IActivityListener; -import de.fu_berlin.inf.dpp.project.IActivityProvider; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; - -/** - * The EditorManager is responsible for handling all editors in a DPP-session. - * This includes the functionality of listening for user inputs in an editor, - * locking the editors of the observer. - * - * The EditorManager contains the testable logic. All untestable logic should - * only appear in an class of the {@link IEditorAPI} type. - * - * @author rdjemili - */ -public class EditorManager implements IActivityProvider, ISharedProjectListener { - - private class ElementStateListener implements IElementStateListener { - public void elementDirtyStateChanged(Object element, boolean isDirty) { - if (!isDriver || isDirty || !(element instanceof FileEditorInput)) - return; - - FileEditorInput fileEditorInput = (FileEditorInput) element; - IFile file = fileEditorInput.getFile(); - - if (file.getProject() != sharedProject.getProject()) - return; - - IPath path = file.getProjectRelativePath(); - saveText(path, false); - } - - public void elementContentAboutToBeReplaced(Object element) { - // ignore - } - - public void elementContentReplaced(Object element) { - // ignore - } - - public void elementDeleted(Object element) { - // ignore - } - - public void elementMoved(Object originalElement, Object movedElement) { - // ignore - } - } - - private class EditorPool { - private Map<IPath, HashSet<IEditorPart>> editorParts = new HashMap<IPath, HashSet<IEditorPart>>(); - - public void add(IEditorPart editorPart) { - IResource resource = editorAPI.getEditorResource(editorPart); - IPath path = resource.getProjectRelativePath(); - - if (path == null) - return; - - HashSet<IEditorPart> editors = editorParts.get(path); - - editorAPI.addSharedEditorListener(editorPart); - editorAPI.setEditable(editorPart, isDriver); - - IDocumentProvider documentProvider = editorAPI.getDocumentProvider(editorPart - .getEditorInput()); - - documentProvider.addElementStateListener(elementStateListener); - - IDocument document = editorAPI.getDocument(editorPart); - document.addDocumentListener(documentListener); - - if (editors == null) { - editors = new HashSet<IEditorPart>(); - editorParts.put(path, editors); - } - - editors.add(editorPart); - } - - public void remove(IEditorPart editorPart) { - IResource resource = editorAPI.getEditorResource(editorPart); - IPath path = resource.getProjectRelativePath(); - - if (path == null) - return; - - HashSet<IEditorPart> editors = editorParts.get(path); - editors.remove(editorPart); - } - - public Set<IEditorPart> getEditors(IPath path) { - HashSet<IEditorPart> set = editorParts.get(path); - return set == null ? new HashSet<IEditorPart>() : set; // HACK - } - - public Set<IEditorPart> getAllEditors() { - Set<IEditorPart> all = new HashSet<IEditorPart>(); - - for (Set<IEditorPart> parts : editorParts.values()) { - for (IEditorPart part : parts) { - all.add(part); - } - } - - return all; - } - } - - private class DocumentListener implements IDocumentListener { - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocumentListener - */ - public void documentAboutToBeChanged(final DocumentEvent event) { - // don't give NULL string - String text = event.getText() == null ? "" : event.getText(); - textAboutToBeChanged(event.getOffset(), text, event.getLength()); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocumentListener - */ - public void documentChanged(final DocumentEvent event) { - } - } - - private static Logger log = Logger.getLogger(EditorManager.class.getName()); - - private static EditorManager instance; - - private IEditorAPI editorAPI; - - private ISharedProject sharedProject; - - private List<IActivityListener> activityListeners = new LinkedList<IActivityListener>(); - - private boolean isFollowing; - - private boolean isDriver; - - private EditorPool editorPool = new EditorPool(); - - private ElementStateListener elementStateListener = new ElementStateListener(); - - private DocumentListener documentListener = new DocumentListener(); - - private IPath activeDriverEditor; - - private Set<IPath> driverEditors = new HashSet<IPath>(); - - private ITextSelection driverTextSelection; - - /** all files that have connected document providers */ - private Set<IFile> connectedFiles = new HashSet<IFile>(); - - private List<ISharedEditorListener> editorListeners = new ArrayList<ISharedEditorListener>(); - - /* this activity has arrived and will be execute now. */ - private IActivity currentExecuteActivity; - - public static EditorManager getDefault() { - if (instance == null) - instance = new EditorManager(); - - return instance; - } - - public void setEditorAPI(IEditorAPI editorAPI) { - this.editorAPI = editorAPI; - editorAPI.setEditorManager(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - sharedProject = session; - isDriver = sharedProject.isDriver(); - sharedProject.addListener(this); - sharedProject.getActivityManager().addProvider(this); - - activateOpenEditors(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - setAllEditorsToEditable(); - removeAllAnnotations(null,null); - - sharedProject.removeListener(this); - sharedProject.getActivityManager().removeProvider(this); - sharedProject = null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess invitation) { - // ignore - } - - public void addSharedEditorListener(ISharedEditorListener editorListener) { - if (!editorListeners.contains(editorListener)) - editorListeners.add(editorListener); - } - - public void removeSharedEditorListener(ISharedEditorListener editorListener) { - editorListeners.remove(editorListener); - } - - /** - * @return the path to the resource that the driver is currently editting. - * Can be <code>null</code>. - */ - public IPath getActiveDriverEditor() { - return activeDriverEditor; - } - - /** - * Returns the resource paths of editors that the driver is currently using. - * - * @return all paths (in project-relative format) of files that the driver - * is currently editing by using an editor. Never returns - * <code>null</code>. A empty set is returned if there are no - * currently opened editors. - */ - public Set<IPath> getDriverEditors() { - return driverEditors; - } - - /** - * @return the text selection that the driver is currently using. - */ - public ITextSelection getDriverTextSelection() { - return driverTextSelection; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.ISharedEditorListener - */ - public void viewportChanged(int top, int bottom) { - if ( !sharedProject.isHost()) - return; - - fireActivity(new ViewportActivity(top, bottom)); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.ISharedEditorListener - */ - public void selectionChanged(ITextSelection selection) { - // Commented to allow selection to work for observer too. - // if (!isDriver) return; - - int offset = selection.getOffset(); - int length = selection.getLength(); - - fireActivity(new TextSelectionActivity(offset, length)); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.ISharedEditorListener - */ - public void textAboutToBeChanged(int offset, String text, int replace) { - if (!isDriver) - return; - - TextEditActivity activity = new TextEditActivity(offset, text, replace,activeDriverEditor); - /* check if text edit activity is executed by other driver activity recently. */ - //TODO: check scenario of concurrent edit in same position. - if(activity.sameLike(currentExecuteActivity)){ - /* if activity is execute from remote client activity, - * send this activity to all.*/ -// fireActivity(currentExecuteActivity); - return; - } - - /* if activity is create be this client. */ -// TextEditActivity activity = new TextEditActivity(offset, text, replace); -// activity.setEditor(this.activeDriverEditor); -// - fireActivity(activity); - - IEditorInput input = editorAPI.getActiveEditor().getEditorInput(); - IDocumentProvider provider = editorAPI.getDocumentProvider(input); - IAnnotationModel model = provider.getAnnotationModel(input); - - ContributionHelper.splitAnnotation(model, offset); - } - - /* ---------- ISharedProjectListener --------- */ - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void driverChanged(JID driver, boolean replicated) { - isDriver = sharedProject.isDriver(); - activateOpenEditors(); - - removeAllAnnotations(null, ContributionAnnotation.TYPE ); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void userJoined(JID user) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void userLeft(JID user) { - removeAllAnnotations(user.toString(), null); - } - - /* ---------- etc --------- */ - - /** - * Opens the editor that is currently used by the driver. This method needs - * to be called from an UI thread. Is ignored if caller is already driver. - */ - public void openDriverEditor() { - if (isDriver) - return; - - IPath path = getActiveDriverEditor(); - if (path == null) - return; - - editorAPI.openEditor(sharedProject.getProject().getFile(path)); - } - - public void setEnableFollowing(boolean enable) { - isFollowing = enable; - - for (ISharedEditorListener editorListener : editorListeners) { - editorListener.followModeChanged(enable); - } - - openDriverEditor(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityProvider - */ - public void addActivityListener(IActivityListener listener) { - activityListeners.add(listener); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityProvider - */ - public void removeActivityListener(IActivityListener listener) { - activityListeners.remove(listener); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityProvider - */ - public void exec(final IActivity activity) { - - /* set current execute activity to avoid cirle executions. */ - currentExecuteActivity = activity; - - if (activity instanceof EditorActivity) { - EditorActivity editorActivity = (EditorActivity) activity; - - if (editorActivity.getType().equals(Type.Activated)) { - setActiveDriverEditor(editorActivity.getPath(), true); - - } else if (editorActivity.getType().equals(Type.Closed)) { - removeDriverEditor(editorActivity.getPath(), true); - - } else if (editorActivity.getType().equals(Type.Saved)) { - saveText(editorActivity.getPath(), true); - } - } - - Display.getDefault().syncExec(new Runnable() { - public void run() { - if (activity instanceof TextEditActivity) - execTextEdit((TextEditActivity) activity); - - else if (activity instanceof TextSelectionActivity) - execTextSelection((TextSelectionActivity) activity); - - else if (activity instanceof ViewportActivity) - execViewport((ViewportActivity) activity); - } - - private void execTextEdit(TextEditActivity textEdit) { - if (getActiveDriverEditor() == null) { - log.severe("Received text edit but have no driver editor"); - return; - } - //TODO: change getActiveEditor to IActivity.getEditorPath() - IPath driverEditor = getActiveDriverEditor(); - IFile file = null; - /* if concurrent driver edited another document, get the right file. */ - if(textEdit.getEditor() != null && driverEditor.equals(textEdit.getEditor())){ - file = sharedProject.getProject().getFile(driverEditor); - }else{ - file = sharedProject.getProject().getFile(textEdit.getEditor()); - } - // TODO: This is a major HACK here. There should be a normalization - // happening much earlier to also avoid UTF-8 conversion errors and such. - String text = fixDelimiters(file, textEdit.text); - replaceText(file, textEdit.offset, textEdit.replace, text,textEdit.getSource()); - - Set<IEditorPart> editors = editorPool.getEditors(driverEditor); - for (IEditorPart editorPart : editors) { - editorAPI.setSelection(editorPart, - new TextSelection(textEdit.offset + text.length(), 0), - textEdit.getSource() ); - } - } - - private void execTextSelection(TextSelectionActivity cursor) { - IPath activeDriverEditor = getActiveDriverEditor(); - TextSelection textSelection = new TextSelection(cursor.getOffset(), cursor - .getLength()); - - setDriverTextSelection(textSelection); - - if (activeDriverEditor == null) { - log.severe("Received text selection but have no driver editor"); - return; - } - - Set<IEditorPart> editors = editorPool.getEditors(activeDriverEditor); - for (IEditorPart editorPart : editors) { - editorAPI.setSelection(editorPart, - textSelection, - cursor.getSource() ); - } - } - - private void execViewport(ViewportActivity viewport) { - if (getActiveDriverEditor() == null) { - log.severe("Received viewport but have no driver editor"); - return; - } - - int top = viewport.getTopIndex(); - int bottom = viewport.getBottomIndex(); - - IPath driverEditor = getActiveDriverEditor(); - Set<IEditorPart> editors = editorPool.getEditors(driverEditor); - for (IEditorPart editorPart : editors) { - editorAPI.setViewport(editorPart, isFollowing, top, bottom, - sharedProject.getDriver().getJid().toString()); - } - } - }); - } - - // TODO unify partActivated and partOpened - public void partOpened(IEditorPart editorPart) { - if (!isSharedEditor(editorPart)) - return; - - editorPool.add(editorPart); - sharedEditorActivated(editorPart); // HACK - } - - public void partActivated(IEditorPart editorPart) { - if (!isSharedEditor(editorPart)) - return; - - sharedEditorActivated(editorPart); - } - - public void partClosed(IEditorPart editorPart) { - if (!isSharedEditor(editorPart)) - return; - - IResource resource = editorAPI.getEditorResource(editorPart); - IPath path = resource.getProjectRelativePath(); - - editorPool.remove(editorPart); - - if (isDriver) - removeDriverEditor(path, false); - } - - /** - * Checks wether given resource is currently opened. - * - * @param path - * the project-relative path to the resource. - * @return <code>true</code> if the given resource is opened accoring to - * the editor pool. - */ - public boolean isOpened(IPath path) { - return editorPool.getEditors(path).size() > 0; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.IActivityProvider - */ - public IActivity fromXML(XmlPullParser parser) { - - try { - if (parser.getName().equals("editor")) { - return parseEditorActivity(parser); - - } else if (parser.getName().equals("edit")) { - return parseTextEditActivity(parser); - - } else if (parser.getName().equals("textSelection")) { - return parseTextSelection(parser); - - } else if (parser.getName().equals("viewport")) { - return parseViewport(parser); - } - - } catch (XmlPullParserException e) { - log.severe("Couldn't parse message"); - } catch (IOException e) { - log.severe("Couldn't parse message"); - } - - return null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.IActivityProvider - */ - public String toXML(IActivity activity) { - if (activity instanceof EditorActivity) { - EditorActivity editorActivity = (EditorActivity) activity; -// return "<editor " + "path=\"" + editorActivity.getPath() + "\" " + "type=\"" -// + editorActivity.getType() + "\" />"; - return "<editor " + "path=\"" + editorActivity.getPath() + "\" " + "type=\"" - + editorActivity.getType() + "\" " + "checksum=\"" + editorActivity.getChecksum() + "\" />"; - - } else if (activity instanceof TextEditActivity) { - TextEditActivity textEditActivity = (TextEditActivity) activity; - return "<edit " + "path=\"" + textEditActivity.getEditor() + "\" " +"offset=\"" + textEditActivity.offset + "\" " + "replace=\"" - + textEditActivity.replace + "\">" + "<![CDATA[" + textEditActivity.text + "]]>" - + "</edit>"; - - } else if (activity instanceof TextSelectionActivity) { - TextSelectionActivity textSelection = (TextSelectionActivity) activity; - return "<textSelection " + "offset=\"" + textSelection.getOffset() + "\" " - + "length=\"" + textSelection.getLength() + "\" />"; - - } else if (activity instanceof ViewportActivity) { - ViewportActivity viewportActvity = (ViewportActivity) activity; - return "<viewport " + "top=\"" + viewportActvity.getTopIndex() + "\" " + "bottom=\"" - + viewportActvity.getBottomIndex() + "\" />"; - } - - return null; - } - - private IActivity parseTextEditActivity(XmlPullParser parser) throws XmlPullParserException, - IOException { - - // extract current editor for text edit. - String pathString = parser.getAttributeValue(null, "path"); - Path path = pathString.equals("null") ? null : new Path(pathString); - - int offset = Integer.parseInt(parser.getAttributeValue(null, "offset")); - int replace = Integer.parseInt(parser.getAttributeValue(null, "replace")); - - String text = ""; - if (parser.next() == XmlPullParser.TEXT) { - text = parser.getText(); - } - - return new TextEditActivity(offset, text, replace,path); - } - - private IActivity parseEditorActivity(XmlPullParser parser) { - String pathString = parser.getAttributeValue(null, "path"); - String checksumString = parser.getAttributeValue(null, "checksum"); - - // TODO handle cases where the file is really named "null" - Path path = pathString.equals("null") ? null : new Path(pathString); - - Type type = EditorActivity.Type.valueOf(parser.getAttributeValue(null, "type")); - EditorActivity edit = new EditorActivity(type, path); - try{ - long checksum = Long.parseLong(checksumString); - edit.setChecksum(checksum); - }catch(Exception e){ - /* exception during parse process*/ - } - - return edit; - } - - private TextSelectionActivity parseTextSelection(XmlPullParser parser) { - // TODO extract constants - int offset = Integer.parseInt(parser.getAttributeValue(null, "offset")); - int length = Integer.parseInt(parser.getAttributeValue(null, "length")); - return new TextSelectionActivity(offset, length); - } - - private ViewportActivity parseViewport(XmlPullParser parser) { - int top = Integer.parseInt(parser.getAttributeValue(null, "top")); - int bottom = Integer.parseInt(parser.getAttributeValue(null, "bottom")); - return new ViewportActivity(top, bottom); - } - - private boolean isSharedEditor(IEditorPart editorPart) { - IResource resource = editorAPI.getEditorResource(editorPart); - return (sharedProject != null && resource.getProject() == sharedProject.getProject()); - } - - private void replaceText(IFile file, int offset, int replace, String text, String source) { - FileEditorInput input = new FileEditorInput(file); - IDocumentProvider provider = editorAPI.getDocumentProvider(input); - - try { - if (!connectedFiles.contains(file)) { - provider.connect(input); - connectedFiles.add(file); - } - - IDocument doc = provider.getDocument(input); - doc.replace(offset, replace, text); - - IAnnotationModel model = provider.getAnnotationModel(input); - ContributionHelper.insertAnnotation(model, offset, text.length(),source); - - // Don't disconnect from provider yet, because otherwise the text - // changes would be lost. We only disconnect when the document is - // reset or saved. - - } catch (BadLocationException e) { - // TODO If this happens a resend of the original text should be - // initiated. - Saros.log("Couldn't insert driver text because of bad location.", e); - } catch (CoreException e) { - Saros.log("Couldn't insert driver text.", e); - } - } - - /** - * Needs to be called from a UI thread. - */ - private void resetText(IFile file) { - if (!file.exists()) - return; - - FileEditorInput input = new FileEditorInput(file); - IDocumentProvider provider = editorAPI.getDocumentProvider(input); - - if (connectedFiles.contains(file)) { - provider.disconnect(input); - connectedFiles.remove(file); - } - } - - /** - * Saves the driver editor. - * - * @param path - * the path to the resource that the driver was editting. - * @param replicated - * <code>false</code> if this action originates on this client. - * <code>false</code> if it is an replication of an action from - * another participant of the shared project. - */ - private void saveText(IPath path, boolean replicated) { - for (ISharedEditorListener listener : editorListeners) { - listener.driverEditorSaved(path, replicated); - } - - if (replicated) { - IFile file = sharedProject.getProject().getFile(path); - FileEditorInput input = new FileEditorInput(file); - - try { - file.setReadOnly(false); - IDocumentProvider provider = editorAPI.getDocumentProvider(input); - - // save not necessary, if we have no modified document - if (!connectedFiles.contains(file)) - return; - - IDocument doc = provider.getDocument(input); - - IAnnotationModel model = provider.getAnnotationModel(input); - model.connect(doc); - - provider.saveDocument(new NullProgressMonitor(), input, doc, true); - log.fine("Saved document " + path); - - model.disconnect(doc); - - provider.disconnect(input); - connectedFiles.remove(file); - - } catch (CoreException e) { - log.log(Level.SEVERE, "Failed to save document.", e); - } - - } else { - IActivity activity = new EditorActivity(Type.Saved, path); - for (IActivityListener listener : activityListeners) { - listener.activityCreated(activity); - } - } - } - - /** - * Sends given activity to all registered activity listeners. - */ - private void fireActivity(IActivity activity) { - for (IActivityListener listener : activityListeners) { - listener.activityCreated(activity); - } - } - - /** - * Replaces the line delimiters in given text by the default line delimiters - * of given file. - * - * @return the string with replaced delimiters. - */ - private String fixDelimiters(IFile file, String text) { - FileEditorInput input = new FileEditorInput(file); - IDocumentProvider provider = editorAPI.getDocumentProvider(input); - IDocument doc = provider.getDocument(input); - - if (doc instanceof IDocumentExtension4) { - IDocumentExtension4 docExtension4 = (IDocumentExtension4) doc; - String delimiter = docExtension4.getDefaultLineDelimiter(); - - if (delimiter != null) - return text.replace("\n", delimiter); - } - - return text; - } - - private void activateOpenEditors() { - Display.getDefault().syncExec(new Runnable() { - public void run() { - for (IEditorPart editorPart : editorAPI.getOpenEditors()) { - partOpened(editorPart); - } - - IEditorPart activeEditor = editorAPI.getActiveEditor(); - if (activeEditor != null) { - sharedEditorActivated(activeEditor); - } - } - }); - } - - private void sharedEditorActivated(IEditorPart editorPart) { - if (!sharedProject.isHost()) - return; - - IResource resource = editorAPI.getEditorResource(editorPart); - IPath editorPath = resource.getProjectRelativePath(); - setActiveDriverEditor(editorPath, false); - - ITextSelection selection = editorAPI.getSelection(editorPart); - setDriverTextSelection(selection); - - ILineRange viewport = editorAPI.getViewport(editorPart); - int startLine = viewport.getStartLine(); - viewportChanged(startLine, startLine + viewport.getNumberOfLines()); - } - - private void setAllEditorsToEditable() { - for (IEditorPart editor : editorPool.getAllEditors()) { - editorAPI.setEditable(editor, true); - } - } - - /** - * Removes all contribution and viewport annotations. - */ - - private void removeAllAnnotations(String forUserID, String typeAnnotation) { - - for (IEditorPart editor : editorPool.getAllEditors()) { - IEditorInput input = editor.getEditorInput(); - IDocumentProvider provider = editorAPI.getDocumentProvider(input); - IAnnotationModel model = provider.getAnnotationModel(input); - - if (model == null) - continue; - - for ( - @SuppressWarnings("unchecked")Iterator it = model.getAnnotationIterator(); it.hasNext();) { - Annotation annotation = (Annotation) it.next(); - String type = annotation.getType(); - - boolean isContribution = type.equals(ContributionAnnotation.TYPE); - boolean isViewport = type.equals(ViewportAnnotation.TYPE); - boolean isTextSelection = type.startsWith(SelectionAnnotation.TYPE); - - if ( (typeAnnotation==null && !isContribution && !isViewport && !isTextSelection) || - (typeAnnotation!=null && typeAnnotation.equals(type)==false) ) - continue; - - AnnotationSaros anns=(AnnotationSaros)annotation; - boolean isfromuser=forUserID==null || - (forUserID!=null && anns.getSource().equals(forUserID) ) ; - - if (isfromuser ) - model.removeAnnotation(annotation); - } - } - } - - private EditorManager() { - setEditorAPI(new EditorAPI()); - if( Saros.getDefault() != null && Saros.getDefault().getSessionManager() != null){ - Saros.getDefault().getSessionManager().addSessionListener(this); - } - } - - /** - * Sets the currently active driver editor. - * - * @param path - * the project-relative path to the resource that the editor is - * currently editting. - * @param replicated - * <code>false</code> if this action originates on this client. - * <code>false</code> if it is an replication of an action from - * another participant of the shared project. - */ - private void setActiveDriverEditor(IPath path, boolean replicated) { - activeDriverEditor = path; - driverEditors.add(path); - - for (ISharedEditorListener listener : editorListeners) { - listener.activeDriverEditorChanged(activeDriverEditor, replicated); - } - - if (replicated) { - if (isFollowing) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - openDriverEditor(); - } - }); - } - - } else { - IActivity activity = new EditorActivity(Type.Activated, path); - for (IActivityListener listener : activityListeners) { - listener.activityCreated(activity); - } - } - } - - /** - * Removes the given editor from the list of editors that the driver is - * currently using. - * - * @param path - * the path to the resource that the driver was editting. - * @param replicated - * <code>false</code> if this action originates on this client. - * <code>false</code> if it is an replication of an action from - * another participant of the shared project. - */ - private void removeDriverEditor(final IPath path, boolean replicated) { - if (path.equals(activeDriverEditor)) - setActiveDriverEditor(null, replicated); - - driverEditors.remove(path); - - for (ISharedEditorListener listener : editorListeners) { - listener.driverEditorRemoved(path, replicated); - } - - if (replicated) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - IFile file = sharedProject.getProject().getFile(path); - resetText(file); - - if (!isFollowing) - return; - - Set<IEditorPart> editors = editorPool.getEditors(path); - for (IEditorPart part : editors) { - editorAPI.closeEditor(part); - } - } - }); - - } else { - IActivity activity = new EditorActivity(Type.Closed, path); - for (IActivityListener listener : activityListeners) { - listener.activityCreated(activity); - } - } - } - - /** - * @param selection - * sets the current text selection that is used by the driver. - */ - private void setDriverTextSelection(ITextSelection selection) { - driverTextSelection = selection; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/ISharedEditorListener.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/ISharedEditorListener.java deleted file mode 100644 index 04cac05180d77dfbd0ca29f4be2c7bfdac2e8ba8..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/ISharedEditorListener.java +++ /dev/null @@ -1,53 +0,0 @@ -package de.fu_berlin.inf.dpp.editor; - -import org.eclipse.core.runtime.IPath; - -public interface ISharedEditorListener { - /** - * The resource that the driver is currently editting has changed. - * - * @param path - * the project-relative path of the resource that is the new - * driver resource. - * - * @param replicated - * <code>false</code> if this event was created by this client. - * <code>true</code> if it was created by another client and - * only replicated to this client. - */ - public void activeDriverEditorChanged(IPath path, boolean replicated); - - /** - * Is fired when the given editor is removed from the list of editors that - * the driver is currently using. - * - * @param path - * the path to the resource that the driver was editting. - * @param replicated - * <code>false</code> if this action originates on this client. - * <code>false</code> if it is an replication of an action from - * another participant of the shared project. - */ - public void driverEditorRemoved(IPath path, boolean replicated); - - /** - * Is fired when the driver editor is saved. - * - * @param path - * the path to the resource that the driver was editting. - * @param replicated - * <code>false</code> if this action originates on this client. - * <code>false</code> if it is an replication of an action from - * another participant of the shared project. - */ - public void driverEditorSaved(IPath path, boolean replicated); - - /** - * Is fired when the follow mode is changed. - * - * @param enabled - * <code>true</code> if follow mode is enabled. - * <code>false</code> otherwise. - */ - public void followModeChanged(boolean enabled); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/AnnotationSaros.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/AnnotationSaros.java deleted file mode 100644 index 5ab66c69958105972794bf7160c33f932d6a88b4..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/AnnotationSaros.java +++ /dev/null @@ -1,55 +0,0 @@ -package de.fu_berlin.inf.dpp.editor.annotations; - -import org.eclipse.jface.text.source.Annotation; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.net.JID; - -public class AnnotationSaros extends Annotation { - - private String source; - - AnnotationSaros(String type, boolean isPersistent, String text, String source) { - super(type, isPersistent, text); - this.source=source; - - if( -// type.equals(ContributionAnnotation.TYPE) -// || - type.equals(SelectionAnnotation.TYPE)){ - - // TODO: improve color assingment and dynamic handling - int colorid=getColorIdForUser(source) +1; - String mytype=type + "." + new Integer(colorid).toString(); - - setType(mytype); - } - } - - AnnotationSaros(String type, boolean isPersistent, String text) { - super(type, isPersistent, text); - this.source=null; - } - - public String getSource() { - return source; - } - - public void setSource(String source) { - this.source = source; - } - - protected int getColorIdForUser(String username){ - User user= Saros.getDefault().getSessionManager().getSharedProject(). - getParticipant(new JID(username)); - - int colorid=1; - if (user!=null) { - colorid=user.getColorID(); - } - - return colorid; - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/ContributionAnnotation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/ContributionAnnotation.java deleted file mode 100644 index 5ea72ec92eb8e2f1fe5e294e35419eadb423d861..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/ContributionAnnotation.java +++ /dev/null @@ -1,19 +0,0 @@ -package de.fu_berlin.inf.dpp.editor.annotations; - -/** - * Marks text contributions done by the driver. - * - * @author rdjemili - */ -public class ContributionAnnotation extends AnnotationSaros { - public static final String TYPE = "de.fu_berlin.inf.dpp.annotations.contribution"; - - public ContributionAnnotation() { - this("",""); - } - - public ContributionAnnotation(String label, String source) { - super(TYPE, false, label, source); - - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/SelectionAnnotation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/SelectionAnnotation.java deleted file mode 100644 index 3757a81288158f1b0595d278b01e4defa0a59c20..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/SelectionAnnotation.java +++ /dev/null @@ -1,26 +0,0 @@ -package de.fu_berlin.inf.dpp.editor.annotations; - - -/** - * Marks text selected by both driver and observer. - * - * Configuration of this annotation is done in the plugin-xml - * - * @author coezbek - */ -public class SelectionAnnotation extends AnnotationSaros { - - // base TYPE name, will be extended for different remote users - public static final String TYPE = "de.fu_berlin.inf.dpp.annotations.selection"; - - public SelectionAnnotation() { - this(null,null); - } - - public SelectionAnnotation(String label, String username) { - super(TYPE, false, label,username); - - } - - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/ViewportAnnotation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/ViewportAnnotation.java deleted file mode 100644 index decd26b207644ad157a53aee82319406f94dd64f..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/ViewportAnnotation.java +++ /dev/null @@ -1,127 +0,0 @@ -package de.fu_berlin.inf.dpp.editor.annotations; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.jface.text.source.IAnnotationPresentation; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.editors.text.EditorsUI; -import org.eclipse.ui.texteditor.AnnotationPreference; -import org.eclipse.ui.texteditor.AnnotationPreferenceLookup; - -/** - * The annotation that shows were the driver currently is. - * - * Preferences are set in the plug-in XML - * - * @author rdjemili - */ -public class ViewportAnnotation extends AnnotationSaros implements IAnnotationPresentation, - IPropertyChangeListener { - - public static final String TYPE = "de.fu_berlin.inf.dpp.annotations.viewport"; - - public static final int LAYER = 6; - - private static final int INSET = 2; - - private static final double STROKE_SCALE = 0.5; - - private static final double FILL_SCALE = 0.9; - - private static Color strokeColor; - - private static Color fillColor; - - public ViewportAnnotation(String label, String source) { - super(TYPE, false, label, source ); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.source.IAnnotationPresentation - */ - public void paint(GC gc, Canvas canvas, Rectangle bounds) { - if (strokeColor == null) { - strokeColor = getColor(STROKE_SCALE); - fillColor = getColor(FILL_SCALE); - } - - Point canvasSize = canvas.getSize(); - - gc.setBackground(fillColor); - gc.setForeground(strokeColor); - gc.setLineWidth(1); - - int x = INSET; - int y = bounds.y; - int w = canvasSize.x - 2 * INSET; - int h = bounds.height; - - if (y < 0) { - h = h + y; - y = 0; - } - - if (h <= 0) - return; - - gc.fillRectangle(x, y, w, h); - gc.drawRectangle(x, y, w, h); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.source.IAnnotationPresentation - */ - public int getLayer() { - return IAnnotationPresentation.DEFAULT_LAYER; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.util.IPropertyChangeListener - */ - public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals(getColorPreferenceKey())) { - if (strokeColor != null) { - strokeColor.dispose(); - strokeColor = null; - - fillColor.dispose(); - fillColor = null; - } - } - } - - public static String getColorPreferenceKey() { - AnnotationPreferenceLookup lookup = EditorsUI.getAnnotationPreferenceLookup(); - - AnnotationPreference preference = lookup.getAnnotationPreference(ViewportAnnotation.TYPE); - - return preference.getColorPreferenceKey(); - } - - private Color getColor(double scale) { - IPreferenceStore store = EditorsUI.getPreferenceStore(); - store.addPropertyChangeListener(this); - - RGB rgb = PreferenceConverter.getColor(store, getColorPreferenceKey()); - int red = (int) ((1.0 - scale) * rgb.red + 255 * scale); - int green = (int) ((1.0 - scale) * rgb.green + 255 * scale); - int blue = (int) ((1.0 - scale) * rgb.blue + 255 * scale); - rgb = new RGB(red, green, blue); - - return new Color(Display.getDefault(), rgb); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/ContributionHelper.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/ContributionHelper.java deleted file mode 100644 index 5693f4ab9dfaf23bcb2b34b461ec8f47970633ab..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/ContributionHelper.java +++ /dev/null @@ -1,91 +0,0 @@ -package de.fu_berlin.inf.dpp.editor.internal; - -import java.util.Iterator; - -import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jface.text.source.IAnnotationModel; - -import de.fu_berlin.inf.dpp.editor.annotations.AnnotationSaros; -import de.fu_berlin.inf.dpp.editor.annotations.ContributionAnnotation; - -/** - * A helper class for handling the contribution annotation. - * - * @author rdjemili - */ -public class ContributionHelper { - - /** - * Inserts a contribution annotation to given model if there is not already - * a contribution annotation at given position. This method should be called - * after the text has changed. - */ - public static void insertAnnotation(IAnnotationModel model, int offset, int length) { - - for (@SuppressWarnings("unchecked")Iterator it = model.getAnnotationIterator(); it.hasNext();) { - Annotation annotation = (Annotation) it.next(); - - if (!annotation.getType().equals(ContributionAnnotation.TYPE)) - continue; - - if (model.getPosition(annotation).includes(offset)) - return; - } - - if (length > 0) { - Position position = new Position(offset, length); - AnnotationSaros annotation = new ContributionAnnotation(); - model.addAnnotation(annotation, position); - } - } - - /** - * Inserts a contribution annotation to given model if there is not already - * a contribution annotation at given position. This method should be called - * after the text has changed. - */ - public static void insertAnnotation(IAnnotationModel model, int offset, int length, String source) { - for (@SuppressWarnings("unchecked")Iterator it = model.getAnnotationIterator(); it.hasNext();) { - Annotation annotation = (Annotation) it.next(); - - if (!annotation.getType().equals(ContributionAnnotation.TYPE)) - continue; - - if (model.getPosition(annotation).includes(offset)) - return; - } - - if (length > 0) { - Position position = new Position(offset, length); - AnnotationSaros annotation = new ContributionAnnotation("",source); - model.addAnnotation(annotation, position); - } - } - - /** - * Splits the contribution annotation at given position, so that the - * following text change won't expand the annotation. This needs to be - * called before the text is changed. - */ - public static void splitAnnotation(IAnnotationModel model, int offset) { - for (@SuppressWarnings("unchecked")Iterator it = model.getAnnotationIterator(); it.hasNext();) { - Annotation annotation = (Annotation) it.next(); - - if (!annotation.getType().equals(ContributionAnnotation.TYPE)) - continue; - - Position pos = model.getPosition(annotation); - - if (offset > pos.offset && offset < pos.offset + pos.length) { - Position pos1 = new Position(pos.offset, offset - pos.offset); - Position pos2 = new Position(offset, pos.length - (offset - pos.offset)); - - model.removeAnnotation(annotation); - /* get source information and create an split annotation.*/ - model.addAnnotation(new ContributionAnnotation("",((ContributionAnnotation)annotation).getSource()), pos1); - model.addAnnotation(new ContributionAnnotation("",((ContributionAnnotation)annotation).getSource()), pos2); - } - } - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/EditorAPI.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/EditorAPI.java deleted file mode 100644 index 14bd836a95e8c6bb6e296b54e88d4d06675fac1f..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/EditorAPI.java +++ /dev/null @@ -1,598 +0,0 @@ -package de.fu_berlin.inf.dpp.editor.internal; - -import java.awt.Toolkit; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.logging.Logger; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.jdt.internal.ui.JavaPlugin; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextOperationTarget; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.ITextViewerExtension; -import org.eclipse.jface.text.IViewportListener; -import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.TextSelection; -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jface.text.source.IAnnotationModel; -import org.eclipse.jface.text.source.ILineRange; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.jface.text.source.LineRange; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.swt.custom.VerifyKeyListener; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.KeyListener; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseListener; -import org.eclipse.swt.events.VerifyEvent; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.IPartListener2; -import org.eclipse.ui.IPathEditorInput; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchPartReference; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.IDE; -import org.eclipse.ui.texteditor.AbstractTextEditor; -import org.eclipse.ui.texteditor.DocumentProviderRegistry; -import org.eclipse.ui.texteditor.IDocumentProvider; -import org.eclipse.ui.texteditor.IEditorStatusLine; -import org.eclipse.ui.texteditor.ITextEditor; - -import de.fu_berlin.inf.dpp.editor.EditorManager; -import de.fu_berlin.inf.dpp.editor.annotations.AnnotationSaros; -import de.fu_berlin.inf.dpp.editor.annotations.SelectionAnnotation; -import de.fu_berlin.inf.dpp.editor.annotations.ViewportAnnotation; -import de.fu_berlin.inf.dpp.net.JID; - - -/** - * The central implementation of the IEditorAPI which basically encapsulates the - * interaction with the TextEditor. - * - * @author rdjemili - * - */ -public class EditorAPI implements IEditorAPI { - - private class SharedProjectPartListener implements IPartListener2 { - public void partActivated(IWorkbenchPartReference partRef) { - IWorkbenchPart part = partRef.getPart(false); - - if (part != null && part instanceof IEditorPart) { - IEditorPart editor = (IEditorPart) part; - editorManager.partActivated(editor); - } - } - - public void partOpened(IWorkbenchPartReference partRef) { - IWorkbenchPart part = partRef.getPart(false); - - if (part != null && part instanceof IEditorPart) { - IEditorPart editor = (IEditorPart) part; - editorManager.partOpened(editor); - } - } - - public void partClosed(IWorkbenchPartReference partRef) { - IWorkbenchPart part = partRef.getPart(false); - - if (part != null && part instanceof IEditorPart) { - IEditorPart editor = (IEditorPart) part; - editorManager.partClosed(editor); - } - } - - public void partBroughtToTop(IWorkbenchPartReference partRef) { - } - - public void partDeactivated(IWorkbenchPartReference partRef) { - } - - public void partHidden(IWorkbenchPartReference partRef) { - } - - public void partVisible(IWorkbenchPartReference partRef) { - } - - public void partInputChanged(IWorkbenchPartReference partRef) { - } - } - - private class EditorListener implements IViewportListener, MouseListener, KeyListener, - ISelectionChangedListener { - - private ITextViewer viewer; - - private ITextSelection lastSelection = new TextSelection(-1, -1); - - private int lastViewportTop = -1; - - private int lastViewportBottom = -1; - - public EditorListener(ITextViewer viewer) { - this.viewer = viewer; - - viewer.getTextWidget().addMouseListener(this); - viewer.getTextWidget().addKeyListener(this); - viewer.getSelectionProvider().addSelectionChangedListener(this); - viewer.addViewportListener(this); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IViewportListener - */ - public void viewportChanged(int verticalOffset) { - // TODO why doesnt this react to window resizes? - checkViewport(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.MouseListener - */ - public void mouseDown(MouseEvent e) { - checkSelection(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.MouseListener - */ - public void mouseUp(MouseEvent e) { - checkSelection(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.MouseListener - */ - public void mouseDoubleClick(MouseEvent e) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.KeyListener - */ - public void keyReleased(KeyEvent e) { - checkSelection(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.KeyListener - */ - public void keyPressed(KeyEvent e) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionChangedListener - */ - public void selectionChanged(SelectionChangedEvent event) { - checkSelection(); - } - - private void checkSelection() { - ISelectionProvider sp = viewer.getSelectionProvider(); - ITextSelection selection = (ITextSelection) sp.getSelection(); - - if (!lastSelection.equals(selection)) { - editorManager.selectionChanged(selection); - lastSelection = selection; - } - } - - private void checkViewport() { - int top = viewer.getTopIndex(); - int bottom = viewer.getBottomIndex(); - - if (top != lastViewportTop || bottom != lastViewportBottom) { - lastViewportTop = top; - lastViewportBottom = bottom; - - editorManager.viewportChanged(viewer.getTopIndex(), viewer.getBottomIndex()); - } - } - } - - private static Logger log = Logger.getLogger(EditorAPI.class.getName()); - - private VerifyKeyListener keyVerifier = new VerifyKeyListener() { - public void verifyKey(VerifyEvent event) { - - // System.out.println(((int)event.character) + " - " + event.keyCode - // + " - " + event.stateMask); - if (event.character > 0) { - event.doit = false; - - Object adapter = getActiveEditor().getAdapter(IEditorStatusLine.class); - if (adapter != null) { - IEditorStatusLine statusLine = (IEditorStatusLine) adapter; - statusLine.setMessage(false, - "You're not allowed to perform modifications while not being the driver of the session.", - null); - Toolkit.getDefaultToolkit().beep(); - } - } - } - }; - - private EditorManager editorManager; - - /** Editors where the user isn't allowed to write */ - private List<IEditorPart> lockedEditors = new ArrayList<IEditorPart>(); - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public void setEditorManager(EditorManager editorManager) { - this.editorManager = editorManager; - - Display.getDefault().syncExec(new Runnable() { - public void run() { - IWorkbenchWindow window = getActiveWindow(); - window.getPartService().addPartListener(new SharedProjectPartListener()); - } - }); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public IEditorPart openEditor(IFile file) { - IWorkbenchWindow window = getActiveWindow(); - if (window != null) { - try { - IWorkbenchPage page = window.getActivePage(); - return IDE.openEditor(page, file); - - } catch (PartInitException e) { - e.printStackTrace(); - } - } - - - return null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public void closeEditor(IEditorPart part) { - IWorkbenchWindow window = getActiveWindow(); - if (window != null) { - IWorkbenchPage page = window.getActivePage(); - page.closeEditor(part, false); - } - } - - @SuppressWarnings("restriction") - public IDocumentProvider getDocumentProvider(IEditorInput input) { - Object adapter = input.getAdapter(IFile.class); - if (adapter != null) { - IFile file = (IFile) adapter; - - String fileExtension = file.getFileExtension(); - if (fileExtension != null && fileExtension.equals("java")) { - JavaPlugin javaPlugin = JavaPlugin.getDefault(); - return javaPlugin.getCompilationUnitDocumentProvider(); - } - } - - DocumentProviderRegistry registry = DocumentProviderRegistry.getDefault(); - return registry.getDocumentProvider(input); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public Set<IEditorPart> getOpenEditors() { - Set<IEditorPart> editorParts = new HashSet<IEditorPart>(); - - IWorkbenchWindow[] windows = getWindows(); - for (int i = 0; i < windows.length; i++) { - IWorkbenchPage[] pages = windows[i].getPages(); - - for (int j = 0; j < pages.length; j++) { - IEditorReference[] editorRefs = pages[j].getEditorReferences(); - - for (int k = 0; k < editorRefs.length; k++) { - IEditorReference reference = editorRefs[k]; - IEditorPart editorPart = reference.getEditor(true); - - if (editorPart != null) - editorParts.add(editorPart); - } - } - } - - return editorParts; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public IEditorPart getActiveEditor() { - IWorkbenchWindow window = getActiveWindow(); - if (window != null) { - IWorkbenchPage page = window.getActivePage(); - if (page != null) { - return page.getActiveEditor(); - } - } - - return null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public IResource getEditorResource(IEditorPart editorPart) { - IEditorInput input = editorPart.getEditorInput(); - - if (input instanceof IPathEditorInput) { - IResource resource = (IResource) input.getAdapter(IFile.class); - - if (resource == null) { - resource = (IResource) input.getAdapter(IResource.class); - } - - return resource; - } - - return null; - } - - /* - * This implementation does not really set the selection but rather adds an - * annotation. - * - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public void setSelection(IEditorPart editorPart, ITextSelection selection, String source) { - - if (!(editorPart instanceof ITextEditor)) - return; - - ITextEditor textEditor = (ITextEditor) editorPart; - IAnnotationModel model = textEditor.getDocumentProvider().getAnnotationModel( - textEditor.getEditorInput()); - - if (model != null) { - - for (@SuppressWarnings("unchecked")Iterator it = model.getAnnotationIterator(); it.hasNext();) { - Annotation annotation = (Annotation) it.next(); - - if ( annotation.getType().startsWith(SelectionAnnotation.TYPE)==false) - continue; - - AnnotationSaros anns=(AnnotationSaros)annotation; - if (anns.getSource().equals(source) ) - model.removeAnnotation(annotation); - } - - JID sourceJid=new JID(source); - String label="Selection of "+sourceJid.getName(); - - Position position = new Position(selection.getOffset(), selection.getLength()); - AnnotationSaros annotation = new SelectionAnnotation(label,source); // BG:was source - model.addAnnotation(annotation, position); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI#getSelection - */ - public ITextSelection getSelection(IEditorPart editorPart) { - if (!(editorPart instanceof ITextEditor)) - return null; - - ITextEditor textEditor = (ITextEditor) editorPart; - ISelectionProvider selectionProvider = textEditor.getSelectionProvider(); - if (selectionProvider != null) - return (ITextSelection) selectionProvider.getSelection(); - - return null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public void setEditable(final IEditorPart editorPart, final boolean editable) { - log.fine(editorPart + " set to editable:" + editable); - - Display.getDefault().syncExec(new Runnable() { - public void run() { - updateStatusLine(editorPart, editable); - - ITextViewerExtension textViewer = (ITextViewerExtension) getViewer(editorPart); - - if (textViewer == null) - return; - - if (editable && lockedEditors.contains(editorPart)) { - lockedEditors.remove(editorPart); - textViewer.removeVerifyKeyListener(keyVerifier); - } else if (!editable && !lockedEditors.contains(editorPart)) { - lockedEditors.add(editorPart); - textViewer.appendVerifyKeyListener(keyVerifier); - } - } - }); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public void addSharedEditorListener(IEditorPart editorPart) { - new EditorListener(getViewer(editorPart)); // HACK - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public IDocument getDocument(IEditorPart editorPart) { - AbstractTextEditor textEditor = (AbstractTextEditor) editorPart; - IEditorInput input = textEditor.getEditorInput(); - - return textEditor.getDocumentProvider().getDocument(input); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public void setViewport(IEditorPart editorPart, boolean jumpTo, int top, int bottom, String source) { - - ITextViewer viewer = getViewer(editorPart); - updateViewportAnnotation(viewer, top, bottom, source); - - if (jumpTo) - viewer.setTopIndex(top); - } - - public ILineRange getViewport(IEditorPart editorPart) { - ITextViewer viewer = getViewer(editorPart); - - int top = viewer.getTopIndex(); - int bottom = viewer.getBottomIndex(); - - return new LineRange(top, bottom - top); - } - - private void updateViewportAnnotation(ITextViewer viewer, int top, int bottom, String source) { - - if (!(viewer instanceof ISourceViewer)) - return; - - ISourceViewer sourceViewer = (ISourceViewer) viewer; - IAnnotationModel model = sourceViewer.getAnnotationModel(); - - try { - IDocument document = viewer.getDocument(); - for (@SuppressWarnings("unchecked")Iterator it = model.getAnnotationIterator(); it.hasNext();) { - Annotation ann = (Annotation) it.next(); - if (ann.getType().equals(ViewportAnnotation.TYPE)) - model.removeAnnotation(ann); - } - - int start = document.getLineOffset(top); - int end = document.getLineOffset(bottom); - - JID jid=new JID(source); - String text = "Visible scope of " + jid.getName(); - - AnnotationSaros annotation = new ViewportAnnotation(text, source); - Position position = new Position(start, end - start); - model.addAnnotation(annotation, position); - } catch (BadLocationException e) { - e.printStackTrace(); - } - } - - /** - * Needs UI-thread. - */ - private void updateStatusLine(IEditorPart editorPart, boolean editable) { - Object adapter = editorPart.getAdapter(IEditorStatusLine.class); - if (adapter != null) { - IEditorStatusLine statusLine = (IEditorStatusLine) adapter; - statusLine.setMessage(false, editable ? "" : "Not editable", null); - } - } - - private static ITextViewer getViewer(IEditorPart editorPart) { - return (ITextViewer) editorPart.getAdapter(ITextOperationTarget.class); - } - - /** - * Returns the active workbench window. Needs to be called from UI thread. - * - * @return the active workbench window or <code>null</code> if there is no - * window or method is called from non-UI thread. - * @see IWorkbench#getActiveWorkbenchWindow() - */ - private static IWorkbenchWindow getActiveWindow() { - return PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - } - - private static IWorkbenchWindow[] getWindows() { - return PlatformUI.getWorkbench().getWorkbenchWindows(); - } - -/* - private void makeAllProjectResourcesReadOnly(ISharedProject sharedProject) { - - try { - ResourceAttributes attributes = new ResourceAttributes(); - attributes.setReadOnly(!sharedProject.isDriver()); - attributes.setArchive(!sharedProject.isDriver()); - - IResource[] resources = sharedProject.getProject().members(); - for (int i = 0; i < resources.length; i++) { - if (resources[i] instanceof IFile) { - IFile file = (IFile) resources[i]; - - try { - file.setResourceAttributes(attributes); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } - } catch (CoreException e) { - e.printStackTrace(); - } - } -*/ -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/IEditorAPI.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/IEditorAPI.java deleted file mode 100644 index 3fc02e7f0924bdbeb2399065c6cc1dbfbceff5ad..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/IEditorAPI.java +++ /dev/null @@ -1,110 +0,0 @@ -package de.fu_berlin.inf.dpp.editor.internal; - -import java.util.Set; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.text.TextSelection; -import org.eclipse.jface.text.source.ILineRange; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.texteditor.IDocumentProvider; - -import de.fu_berlin.inf.dpp.editor.EditorManager; - -/** - * An humble interface that is responsible for editor functionality. The idea - * behind this interface is to only capsulates the least possible amount of - * functionality - the one that can't be easily tested. All higher logic can be - * found in {@link EditorManager}. - * - * @author rdjemili - */ -public interface IEditorAPI { - /** - * Sets the editor manager that uses this IEditorAPI. The given editor - * manager will receive the callbacks. - */ - public void setEditorManager(EditorManager editorManager); - - /** - * Opens the editor with given file. Needs to be called from an UI thread. - * - * @return the opened editor or <code>null</code> if the editor couldn't - * be opened. - */ - public IEditorPart openEditor(IFile file); - - /** - * Closes the given editorpart. - * - * Needs to be called from an UI thread. - */ - public void closeEditor(IEditorPart part); - - /** - * @return the editor that is currently activated. - */ - public IEditorPart getActiveEditor(); - - /** - * @return all editors that are currently opened. - */ - public Set<IEditorPart> getOpenEditors(); - - /** - * Sets the text selection in given editor. - */ - public void setSelection(IEditorPart editorPart, ITextSelection selection, String source); - - /** - * Returns the current text selection for given editor. - * - * @param editorPart - * the editorPart for which to get the text selection. - * @return the current text selection. Returns - * {@link TextSelection#emptySelection()} if no text selection - * exists. - * - */ - public ITextSelection getSelection(IEditorPart editorPart); - - /** - * @return the file path that given editor is displaying. - */ - public IResource getEditorResource(IEditorPart editorPart); - - public void setViewport(IEditorPart editorPart, boolean jumpTo, int top, int bottom, String source); - - /** - * Return the viewport for given editor. - * - * @param editorPart - * the editor for which to get the viewport - * @return the viewport. Never <code>null</code>. - */ - public ILineRange getViewport(IEditorPart editorPart); - - /** - * Enables/disables the ability to edit the document in given editor. - */ - public void setEditable(IEditorPart editorPart, boolean editable); - - /** - * Attaches listeners to the given editor that will fire the - * {@link IEditorListener} methods on the editor manager set with - * {@link #setEditorManager(EditorManager)}. - * - * Connecting to an editorPart multiple times, will result in multiple - * events. The caller is responsible for organizing connections. - * - * Needs to be called from a UI thread. - */ - public void addSharedEditorListener(IEditorPart editorPart); - - public IDocument getDocument(IEditorPart editorPart); - - public IDocumentProvider getDocumentProvider(IEditorInput editorInput); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/SharedDocumentProvider.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/SharedDocumentProvider.java deleted file mode 100644 index ff4805a97285dddf95769c7f5a4351233fc4b973..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/SharedDocumentProvider.java +++ /dev/null @@ -1,125 +0,0 @@ -package de.fu_berlin.inf.dpp.editor.internal; - -import org.eclipse.core.resources.IProject; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.editors.text.TextFileDocumentProvider; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISessionManager; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; - -public class SharedDocumentProvider extends TextFileDocumentProvider implements ISessionListener, - ISharedProjectListener { - - private ISharedProject sharedProject; - - private boolean isDriver; - - public SharedDocumentProvider() { - ISessionManager sm = Saros.getDefault().getSessionManager(); - if (sm.getSharedProject() != null) - sessionStarted(sm.getSharedProject()); - - sm.addSessionListener(this); - } - - @Override - public boolean isReadOnly(Object element) { - if (sharedProject == null || !isInSharedProject(element)) - return super.isReadOnly(element); - - return !isDriver || super.isReadOnly(element); - } - - @Override - public boolean isModifiable(Object element) { - if (sharedProject == null || !isInSharedProject(element)) - return super.isModifiable(element); - - return isDriver && super.isModifiable(element); - } - - @Override - public boolean canSaveDocument(Object element) { - if (sharedProject == null || !isInSharedProject(element)) - return super.canSaveDocument(element); - - return isDriver && super.canSaveDocument(element); - } - - @Override - public boolean mustSaveDocument(Object element) { - if (sharedProject == null || !isInSharedProject(element)) - return super.mustSaveDocument(element); - - return isDriver && super.mustSaveDocument(element); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess process) { - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - sharedProject = session; - isDriver = sharedProject.isDriver(); - - sharedProject.addListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - sharedProject = null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProjectListener - */ - public void driverChanged(JID driver, boolean replicated) { - if (sharedProject!=null) - isDriver = sharedProject.isDriver(); // HACK - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProjectListener - */ - public void userJoined(JID user) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProjectListener - */ - public void userLeft(JID user) { - // ignore - } - - private boolean isInSharedProject(Object element) { - IFileEditorInput fileEditorInput = (IFileEditorInput) element; - IProject project = fileEditorInput.getFile().getProject(); - - return project.equals(sharedProject.getProject()); - } -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/IIncomingInvitationProcess.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/IIncomingInvitationProcess.java deleted file mode 100644 index dafde88968b5b861efcfefb84f5e796ec7443586..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/IIncomingInvitationProcess.java +++ /dev/null @@ -1,56 +0,0 @@ -package de.fu_berlin.inf.dpp.invitation; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; - -import de.fu_berlin.inf.dpp.FileList; - -/** - * An incoming invitation process. Is created when we receive an invitation to a - * shared project on a remote system. - * - * @author rdjemili - */ -public interface IIncomingInvitationProcess extends IInvitationProcess { - - /** - * Requests the file list of the remotly shared project. This methods blocks - * until the file list is retrieved. - * - * This method can be called while in INVITATION_SENT state. - */ - public FileList requestRemoteFileList(IProgressMonitor monitor); - - /** - * @return the file list of the remotly shared project or <code>null</code> - * if it hasn't been requested and retrieved yet. Make a call to - * {@link #requestRemoteFileList(IProgressMonitor)} before using - * this method. - */ - public FileList getRemoteFileList(); - - /** - * Accepts the incoming invitation and creates the shared project. This - * method blocks until the synchronization is done. - * - * This method can be called by the user while in HOST_FILELIST_SENT state. - * - * @param baseProject - * the local project that is used as file base for the following - * replication. If this is <code>null</code> no project will be - * used as file base. - * @param newProjectName - * the project name of the new project that is to be generated. - * If this is <code>null</code> the <code>baseProject</code> - * will be overwritten. - * @param monitor - * a progressmonitor that monitors the whole process. Can not be - * <code>null</code>. - * - * @throws InvitationException - - */ - public void accept(IProject baseProject, String newProjectName, IProgressMonitor monitor); - - public void setInvitationUI(IInvitationUI inviteUI); - -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/IInvitationProcess.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/IInvitationProcess.java deleted file mode 100644 index e3d0f374bba6712b4193a54427f96a25d324e135..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/IInvitationProcess.java +++ /dev/null @@ -1,115 +0,0 @@ -package de.fu_berlin.inf.dpp.invitation; - -import java.io.InputStream; - -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.FileList; -import de.fu_berlin.inf.dpp.net.IFileTransferCallback; -import de.fu_berlin.inf.dpp.net.JID; - -/** - * By contract calls to this invitiation process that are not expected, will - * throw a IllegalStateException. Use {@link #getPeer()} to decide wether a - * incoming message is destined for this process. - * - * TODO add special invitation process ID which can be used to specificly - * address certain invitations - * - * @author rdjemili - */ -public interface IInvitationProcess extends IFileTransferCallback { - - /** - * This class contains UI code which is needed by the invitation - * process. - * - * Both the outgoing and incoming invitation UIs need to implement this. - */ - public interface IInvitationUI { - - /** - * - * @param errorMsg Is null if the cancelation was due to a user action. - * @param replicated Is true if this message originated on the remote side or false if the message originated on the local side. - */ - public void cancel(String errorMsg, boolean replicated); - public void updateInvitationProgress(final JID jid); - public void runGUIAsynch(final Runnable runnable) ; - } - - /** - * All states that an invitiation process can possibly have. - */ - public static enum State { - INITIALIZED, INVITATION_SENT, HOST_FILELIST_REQUESTED, HOST_FILELIST_SENT, GUEST_FILELIST_SENT, SYNCHRONIZING, SYNCHRONIZING_DONE, DONE, CANCELED - } - - public static enum TransferMode { - JINGLE, IBB, DEFAULT - } - - /** - * @return the exception that occured while executing the process or - * <code>null</code> if no exception was thrown. - */ - public Exception getException(); - - /** - * @return the current state of the process. - */ - public State getState(); - - /** - * @return the current transfer mode. - */ - public TransferMode getTransferMode(); - - /** - * @return the peer that is participating with us in this process. For an - * incoming invitation this is the inviter. For an outgoing - * invitation this is the invitee. - */ - public JID getPeer(); - - /** - * @return the user-provided informal description that can be provided with - * an invitiation. - */ - public String getDescription(); - - /** - * - * @return the name of the project that is shared by the peer. - */ - public String getProjectName(); - - /** - * Cancels the invitation process. Is ignored if invitation was already - * cancelled. - * - * @param errorMsg - * the error that caused the cancellation. This should be some - * user-friendly text as it might be presented to the user. - * <code>null</code> if the cancellation was caused by the - * users request and not by some error. - * @param replicated - * <code>true</code> if this cancellation is caused by an - * remote system. <code>false</code> if it originates on our - * system. If <code>false</code> we send an cancellation - * message to our peer. - */ - public void cancel(String errorMsg, boolean replicated); - - /** - * @return <code>true</code> if this invitation process has consumed the - * input stream. <code>false</code> otherwise. - */ - public void resourceReceived(JID from, IPath path, InputStream input); - - public void fileListReceived(JID from, FileList fileList); - - public void invitationAccepted(JID from); - - public void joinReceived(JID from); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/IOutgoingInvitationProcess.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/IOutgoingInvitationProcess.java deleted file mode 100644 index 750963c3debb1b5b1faa676db479dfab61faa595..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/IOutgoingInvitationProcess.java +++ /dev/null @@ -1,22 +0,0 @@ -package de.fu_berlin.inf.dpp.invitation; - - -/** - * An outgoing invitation process, which is used to invite new users to the - * shared project. - * - * @author rdjemili - */ -public interface IOutgoingInvitationProcess extends IInvitationProcess { - /** - * Synchronizing is the state right before completing the invitation - * process, where the files of the shared project are - * replicated/synchronized with the local project of the invitee. - */ - public void startSynchronization(); - - public int getProgressCurrent(); - public int getProgressMax(); - public String getProgressInfo(); - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/internal/IncomingInvitationProcess.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/internal/IncomingInvitationProcess.java deleted file mode 100644 index ec6f50d26e0e00e66a9bb051bf9d0b683de4f7c9..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/internal/IncomingInvitationProcess.java +++ /dev/null @@ -1,493 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.invitation.internal; - -import java.io.File; -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.widgets.Display; - -import de.fu_berlin.inf.dpp.FileList; -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.ITransmitter; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISessionManager; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.ui.ErrorMessageDialog; - -/** - * An incoming invitation process. - * - * @author rdjemili - */ -public class IncomingInvitationProcess extends InvitationProcess implements - IIncomingInvitationProcess { - - private static Logger logger = Logger.getLogger(IncomingInvitationProcess.class); - - private FileList remoteFileList; - - private IProject localProject; - - private int filesLeftToSynchronize; - - /** size of current transfered part of archive file. */ - private int transferedFileSize = 0; - - - private IProgressMonitor progressMonitor; - - protected String projectName; - - public IncomingInvitationProcess(ITransmitter transmitter, JID from, String projectName, - String description) { - - super(transmitter, from, description); - - this.projectName = projectName; - this.setState(State.INVITATION_SENT); - - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IInvitationProcess - */ - public void fileListReceived(JID from, FileList fileList) { - assertState(State.HOST_FILELIST_REQUESTED); - - if (fileList == null) - cancel("Failed to receive remote file list.", false); - else { - remoteFileList = fileList; - setState(State.HOST_FILELIST_SENT); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IIncomingInvitationProcess - */ - public FileList requestRemoteFileList(IProgressMonitor monitor) { - assertState(State.INVITATION_SENT); - - monitor.beginTask("Requesting remote file list", IProgressMonitor.UNKNOWN); - - transmitter.sendRequestForFileListMessage(peer); - setState(State.HOST_FILELIST_REQUESTED); - - while (remoteFileList == null && state != State.CANCELED) { - if (monitor.isCanceled()) { - cancel(null, false); - } - - try { - Thread.sleep(500); - monitor.worked(1); - } catch (InterruptedException e) { - } - } - - monitor.done(); - - //TODO: for testing -// tmode = TransferMode.IBB; - - return remoteFileList; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IIncomingInvitationProcess - */ - public void accept(IProject baseProject, String newProjectName, IProgressMonitor monitor) { - - if (newProjectName == null && baseProject == null) - throw new IllegalArgumentException( - "At least newProjectName or baseProject have to be not null."); - - try { - assertState(State.HOST_FILELIST_SENT); - - if (newProjectName != null) { - localProject = createNewProject(newProjectName, baseProject); - } else { - localProject = baseProject; - } - - filesLeftToSynchronize = handleDiff(localProject, remoteFileList); - - progressMonitor = monitor; - if(tmode == TransferMode.IBB){ - progressMonitor.beginTask("Transfer archive file ...", 100); - }else{ - progressMonitor.beginTask("Synchronizing...", filesLeftToSynchronize); - } - setState(State.SYNCHRONIZING); - - transmitter.sendFileList(peer, new FileList(localProject)); - - if (blockUntilAllFilesSynchronized(monitor)) - done(); - else - cancel(null, false); - - } catch (Exception e) { - ErrorMessageDialog.showErrorMessage(new Exception("Exception during create project.")); - failed(e); - - } finally { - monitor.done(); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.InvitationProcess - */ - public void invitationAccepted(JID from) { - failState(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.InvitationProcess - */ - public void joinReceived(JID from) { - failState(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.InvitationProcess - */ - public void resourceReceived(JID from, IPath path, InputStream in) { - logger.debug("new file received: "+path); - if (localProject==null) - return; // we dont have started the new project yet, so received ressources are not welcomed - - try { - IFile file = localProject.getFile(path); - if (file.exists()) { - file.setReadOnly(false); - file.setContents(in, IResource.FORCE, new NullProgressMonitor()); - } else { - file.create(in, true, new NullProgressMonitor()); - logger.debug("New File created: "+file.getName()); - } - } catch (Exception e) { - failed(e); - } - - /* archive file for transfering data finished. - * Unzip separate files. - * */ - if(tmode == TransferMode.IBB){ - tmode = TransferMode.DEFAULT; - progressMonitor.beginTask("Files left: ",filesLeftToSynchronize); - } - - progressMonitor.worked(1); - progressMonitor.subTask("Files left: " + filesLeftToSynchronize); - - filesLeftToSynchronize--; - logger.debug("file counter: "+filesLeftToSynchronize); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IIncomingInvitationProcess - */ - public FileList getRemoteFileList() { - return remoteFileList; - } - - /** - * Blocks until all files have been synchronized or cancel has been - * selected. - * - * @return <code>true</code> if all files were synchronized. - * <code>false</code> if operation was canceled by user. - */ - private boolean blockUntilAllFilesSynchronized(IProgressMonitor monitor) { - //TODO: deadlock abfangen. - while (filesLeftToSynchronize > 0) { - if (monitor.isCanceled() || getState() == State.CANCELED) { - return false; - } - - try { - Thread.sleep(500); - } catch (InterruptedException e) { - } - } - - return true; - } - - /** - * Creates a new project. - * - * @param newProjectName - * the project name of the new project. - * @param baseProject - * if not <code>null</code> all files of the baseProject will - * be copied into the new project after having created it. - * @return the new project. - * @throws CoreException - * if something goes wrong while creating the new project. - */ - private IProject createNewProject(String newProjectName, final IProject baseProject) - throws CoreException { - - IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); - final IProject project = workspaceRoot.getProject(newProjectName); - - final File projectDir = new File(workspaceRoot.getLocation().toString() + File.separator +newProjectName); - if(projectDir.exists()){ - projectDir.delete(); - } - - /* run project read only settings in progress monitor thread. */ - Display.getDefault().syncExec(new Runnable() { - public void run() { - ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getDefault().getActiveShell()); - try { - dialog.run(true, false, new IRunnableWithProgress(){ - public void run(IProgressMonitor monitor){ - - - try { - - monitor.beginTask("Copy local resources ... ",IProgressMonitor.UNKNOWN); - - project.clearHistory(null); - project.refreshLocal(IProject.DEPTH_INFINITE, null); - - if (baseProject == null) { - project.create(new NullProgressMonitor()); - project.open(new NullProgressMonitor()); - } else { - baseProject.copy(project.getFullPath(), true, new NullProgressMonitor()); - } - - } catch (CoreException e) { - logger.warn( "Exception during copy local ressources",e); - monitor.done(); - } - - monitor.done(); - - } - - }); - } catch (InvocationTargetException e) { - logger.warn( "",e); - e.printStackTrace(); - } catch (InterruptedException e) { - logger.warn( "",e); - e.printStackTrace(); - } - - } - }); - - // TODO CO: What is this??? -// project.clearHistory(null); -// project.refreshLocal(IProject.DEPTH_INFINITE, null); - - return project; - } - - /** - * Prepares for receiving the missing resources. - * - * @param localProject - * the project that is used for the base of the replication. - * @param remoteFileList - * the file list of the remote project. - * @return the number of files that we need to receive to end the - * synchronization. - * @throws CoreException - * is thrown when getting all files of the local project. - */ - private int handleDiff(IProject localProject, FileList remoteFileList) throws CoreException { - - //TODO: Thread - FileList diff = new FileList(localProject).diff(remoteFileList); - - removeUnneededResources(localProject, diff); - int addedPaths = addAllFolders(localProject, diff); - - return diff.getAddedPaths().size() - addedPaths + diff.getAlteredPaths().size(); - } - - /** - * Removes all local resources that aren't part of the shared project we're - * currently joining. This includes files and folders. - * - * @param localProject - * the local project were the shared project will be replicated. - * @param diff - * the fileList which contains the diff information. - * @throws CoreException - */ - private void removeUnneededResources(IProject localProject, FileList diff) throws CoreException { - - // TODO dont throw CoreException - // TODO check if this triggers the resource listener - for (IPath path : diff.getRemovedPaths()) { - if (path.hasTrailingSeparator()) { - IFolder folder = localProject.getFolder(path); - - if (folder.exists()) - folder.delete(true, new NullProgressMonitor()); - - } else { - IFile file = localProject.getFile(path); - - // check if file exists because it might have already been - // deleted when deleting its folder - if (file.exists()) - file.delete(true, new NullProgressMonitor()); - } - } - } - - private int addAllFolders(IProject localProject, FileList diff) throws CoreException { - - int addedFolders = 0; - - for (IPath path : diff.getAddedPaths()) { - if (path.hasTrailingSeparator()) { - IFolder folder = localProject.getFolder(path); - if (!folder.exists()) - folder.create(true, true, new NullProgressMonitor()); - - addedFolders++; - } - } - - return addedFolders; - } - - /** - * Ends the incoming invitiation process. - */ - private void done() { - JID host = peer; - JID driver = peer; - - // TODO: HACK - List<JID> users = new ArrayList<JID>(); - users.add(host); - users.add(Saros.getDefault().getMyJID()); - - ISessionManager sessionManager = Saros.getDefault().getSessionManager(); - ISharedProject sharedProject = sessionManager - .joinSession(localProject, host, driver, users); - - transmitter.sendJoinMessage(sharedProject); - transmitter.removeInvitationProcess(this); // HACK - - sharedProject.setProjectReadonly(true); - - setState(State.DONE); - } - - public String getProjectName() { - return this.projectName; - } - - public void updateInvitationProgress(JID jid) { - // ignored, not needed atm - } - - /* - * (non-Javadoc) - * @see de.fu_berlin.inf.dpp.invitation.IInvitationProcess#getTransferMode() - */ - public TransferMode getTransferMode() { - return tmode; - } - - /* - * (non-Javadoc) - * @see de.fu_berlin.inf.dpp.invitation.IInvitationProcess#jingleFallback() - */ - public void jingleFallback() { - logger.warn("jingle fallback"); - tmode = TransferMode.IBB; - /* if send file list failed. */ - if(getState() == State.SYNCHRONIZING){ - logger.debug("send file list another one."); - try { - transmitter.sendFileList(peer, new FileList(localProject)); - } catch (Exception e) { - ErrorMessageDialog.showErrorMessage(new Exception("Exception during create project.")); - failed(e); - } - } - } - - public void fileSent(IPath path) { - // do nothing - - } - - public void fileTransferFailed(IPath path, Exception e) { - failed(e); - - } - - public void transferProgress(int transfered) { - progressMonitor.worked(transfered - transferedFileSize); - transferedFileSize = transfered; - } - - public void setTransferMode(TransferMode mode) { - tmode = mode; - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/internal/InvitationProcess.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/internal/InvitationProcess.java deleted file mode 100644 index c6ad08500803d28b56b02a84ff12192683a8abf9..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/internal/InvitationProcess.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.invitation.internal; - -import org.apache.log4j.Logger; - -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess; -import de.fu_berlin.inf.dpp.net.ITransmitter; -import de.fu_berlin.inf.dpp.net.JID; - -/** - * @author rdjemili - */ -public abstract class InvitationProcess implements IInvitationProcess { - - private static Logger logger = Logger.getLogger(InvitationProcess.class); - - protected final ITransmitter transmitter; - - protected State state; - - /** mode of file transfer.*/ - protected TransferMode tmode; - - private Exception exception; - - protected JID peer; - - protected IInvitationUI invitationUI = null; - - protected String description; - - public InvitationProcess(ITransmitter transmitter, JID peer, String description) { - this.transmitter = transmitter; - this.peer = peer; - this.description = description; - - tmode = TransferMode.JINGLE; - - transmitter.addInvitationProcess(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IInvitationProcess - */ - public Exception getException() { - return exception; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IInvitationProcess - */ - public State getState() { - return state; - } - - public void setState(State newstate) { - state = newstate; - - if (invitationUI!=null) - invitationUI.updateInvitationProgress(peer); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IInvitationProcess - */ - public JID getPeer() { - return peer; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IInvitationProcess - */ - public String getDescription() { - return description; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.invitation.IInvitationProcess - */ - public void cancel(String errorMsg, boolean replicated) { - if (state == State.CANCELED) - return; - - setState(State.CANCELED); - - logger.error("Invitation was canceled. " + errorMsg); - - if (!replicated) { - transmitter.sendCancelInvitationMessage(peer, errorMsg); - } - - invitationUI.cancel(errorMsg, replicated); - - transmitter.removeInvitationProcess(this); - } - - @Override - public String toString() { - return "InvitationProcess(peer:" + peer + ", state:" + state + ")"; - } - - /** - * Should be called if an exception occured. This saves the exception and - * sets the invitation to cancelled. - */ - protected void failed(Exception e) { - exception = e; - e.printStackTrace(); // HACK - cancel(e.getMessage(), false); - } - - /** - * Asssert that the process is in given state or throw an exception - * otherwise. - * - * @param expected - * the state that the process should currently have. - */ - protected void assertState(State expected) { - if (state != expected){ - cancel("Unexpected state(" + state + ")", false); - } - } - - protected void failState() { - throw new IllegalStateException("Bad input while in state " + state); - } - - public void setInvitationUI(IInvitationUI inviteUI){ - this.invitationUI = inviteUI; - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/internal/OutgoingInvitationProcess.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/internal/OutgoingInvitationProcess.java deleted file mode 100644 index 3a9074f22fb624d7b4837bc5186909f1823f9546..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/internal/OutgoingInvitationProcess.java +++ /dev/null @@ -1,442 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.invitation.internal; - -import java.io.File; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.apache.log4j.Logger; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; - -import de.fu_berlin.inf.dpp.FileList; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.activities.EditorActivity; -import de.fu_berlin.inf.dpp.editor.EditorManager; -import de.fu_berlin.inf.dpp.invitation.IOutgoingInvitationProcess; -import de.fu_berlin.inf.dpp.net.ITransmitter; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.util.FileZipper; - -/** - * An outgoing invitation process. - * - * @author rdjemili - */ -public class OutgoingInvitationProcess extends InvitationProcess implements - IOutgoingInvitationProcess { - - private static Logger logger = Logger - .getLogger(OutgoingInvitationProcess.class); - - private ISharedProject sharedProject; - - private int progress_done; - private int progress_max; - private String progress_info; - - private FileList remoteFileList; - - private List<IPath> toSend; - - /** size of project archive file */ - private long fileSize = 100; - private File archive; - /** size of current transfered part of archive file. */ - private long transferedFileSize = 0; - - public int getProgressCurrent() { - if (tmode == TransferMode.IBB) { - //TODO Änderung - return (int) (transferedFileSize); - } else { - return progress_done + 1; - } - } - - public int getProgressMax() { - if (tmode == TransferMode.IBB) { - //TODO Änderung - return (int) (fileSize); - } else { - return progress_max; - } - - } - - public String getProgressInfo() { - return progress_info; - } - - /** - * A simple runnable that calls - * {@link IOutgoingInvitationProcess#startSynchronization(IProgressMonitor)} - */ - private class SynchronizationRunnable implements Runnable { - private final OutgoingInvitationProcess process; - - public SynchronizationRunnable(OutgoingInvitationProcess process) { - this.process = process; - } - - public void run() { - process.startSynchronization(); - } - } - - public OutgoingInvitationProcess(ITransmitter transmitter, JID to, - ISharedProject sharedProject, String description, boolean startNow, - IInvitationUI inviteUI) { - - super(transmitter, to, description); - - this.invitationUI = inviteUI; - this.sharedProject = sharedProject; - - if (startNow) { - transmitter.sendInviteMessage(sharedProject, to, description); - setState(State.INVITATION_SENT); - } else - setState(State.INITIALIZED); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IOutgoingInvitationProcess - */ - public void startSynchronization() { - assertState(State.GUEST_FILELIST_SENT); - - setState(State.SYNCHRONIZING); - - if (tmode == TransferMode.JINGLE || tmode == TransferMode.DEFAULT - || tmode == TransferMode.IBB) { - try { - FileList local = new FileList(sharedProject.getProject()); - FileList diff = remoteFileList.diff(local); - - List<IPath> added = diff.getAddedPaths(); - List<IPath> altered = diff.getAlteredPaths(); - toSend = new ArrayList<IPath>(added.size() + altered.size()); - toSend.addAll(added); - toSend.addAll(altered); - - progress_max = toSend.size(); - progress_done = 0; - - /* transfer all data with archive. */ - if (tmode == TransferMode.IBB) { - sendArchive(); - } else { - /* send separate files. */ - sendNext(); - } - - if (!blockUntilFilesSent() || !blockUntilJoinReceived()) - cancel(null, false); - - } catch (CoreException e) { - failed(e); - - } - } - - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.InvitationProcess - */ - public void invitationAccepted(JID from) { - assertState(State.INVITATION_SENT); - - // HACK add resource specifier to jid - if (peer.equals(from)) - peer = from; - - try { - transmitter.sendFileList(peer, sharedProject.getFileList()); - setState(State.HOST_FILELIST_SENT); - } catch (Exception e) { - failed(e); - } - - //TODO: For testing only -// tmode = TransferMode.IBB; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.InvitationProcess - */ - public void fileListReceived(JID from, FileList fileList) { - assertState(State.HOST_FILELIST_SENT); - - remoteFileList = fileList; - setState(State.GUEST_FILELIST_SENT); - - invitationUI.runGUIAsynch(new SynchronizationRunnable(this)); - - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.InvitationProcess - */ - public void joinReceived(JID from) { - assertState(State.SYNCHRONIZING_DONE); - - sharedProject.addUser(new User(from)); - setState(State.DONE); - - sendDriverEditors(); - - transmitter.removeInvitationProcess(this); // HACK - - transmitter.sendUserListTo(from, sharedProject.getParticipants()); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.InvitationProcess - */ - public void resourceReceived(JID from, IPath path, InputStream in) { - failState(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.IFileTransferCallback - */ - public void fileTransferFailed(IPath path, Exception e) { - failed(e); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.IFileTrafnsferCallback - */ - public void fileSent(IPath path) { - if (tmode == TransferMode.IBB) { - //TODO Änderung - - setState(State.SYNCHRONIZING_DONE); - } else { - progress_done++; - sendNext(); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.IFileTransferCallback#transferProgress(int) - */ - public void transferProgress(int transfered) { - //TODO Änderung - transferedFileSize = transfered; - /* update ui */ - invitationUI.updateInvitationProgress(peer); - } - - private void sendNext() { - - if (getState() == State.CANCELED) { - toSend.clear(); - return; - } - - if (toSend.size() == 0) { - setState(State.SYNCHRONIZING_DONE); - return; - } - - IPath path = toSend.remove(0); - progress_info = path.toFile().getName(); - - invitationUI.updateInvitationProgress(peer); - - transmitter.sendFile(peer, sharedProject.getProject(), path, this); - } - - /** - * send all project data with archive file. - */ - private void sendArchive() { - //TODO Änderung - if (getState() == State.CANCELED) { - toSend.clear(); - return; - } - - if (toSend.size() == 0) { - setState(State.SYNCHRONIZING_DONE); - return; - } - - archive = new File("./"+getPeer().getName()+"_Project.zip"); - logger.debug("Project archive file has to be send. " - + archive.getAbsolutePath() + " length: " + archive.length()); - try { - /* create project zip archive. */ - FileZipper.createProjectZipArchive(toSend, archive.getAbsolutePath(), sharedProject.getProject()); - /* send data. */ - transmitter.sendProjectArchive(peer, sharedProject.getProject(), - archive, this); - } catch (Exception e) { - failed(e); - } - - progress_info = "Transfer project tar file"; - - // fileSize = archive.length(); - } - - /** - * Blocks until all files have been sent or the operation was canceled by - * the user. - * - * @param monitor - * the progress monitor for the file synchronization. - * @return <code>true</code> if all files have been synchronized. - * <code>false</code> if the user chose to cancel. - */ - private boolean blockUntilFilesSent() { - while (state != State.SYNCHRONIZING_DONE && state != State.DONE) { - if (getState() == State.CANCELED) - return false; - - try { - Thread.sleep(500); - } catch (InterruptedException e) { - } - } - - return true; - } - - /** - * Blocks until the join message has been received or the user cancelled. - * - * @return <code>true</code> if the join message has been received. - * <code>false</code> if the user chose to cancel. - */ - private boolean blockUntilJoinReceived() { - progress_info = "Waiting for confirmation"; - - while (state != State.DONE) { - if (getState() == State.CANCELED) - return false; - - try { - Thread.sleep(500); - } catch (InterruptedException e) { - } - } - progress_info = ""; - - return true; - } - - /** - * Send activities which set the active editors. - */ - private void sendDriverEditors() { - EditorManager editorManager = EditorManager.getDefault(); - Set<IPath> driverEditors = editorManager.getDriverEditors(); - IPath activeDriverEditor = editorManager.getActiveDriverEditor(); - driverEditors.remove(activeDriverEditor); - - FileList filelist; - try { - filelist = sharedProject.getFileList(); - } catch (CoreException e) { - filelist = null; - } - // HACK - for (IPath path : driverEditors) { - if (filelist != null && filelist.getPaths().contains(path) == false) - continue; - - sharedProject.getSequencer().activityCreated( - new EditorActivity(EditorActivity.Type.Activated, path)); - } - - if (filelist != null - && filelist.getPaths().contains(activeDriverEditor) == true) - sharedProject.getSequencer().activityCreated( - new EditorActivity(EditorActivity.Type.Activated, - activeDriverEditor)); - } - - public String getProjectName() { - return sharedProject.getProject().getName(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.IFileTransferCallback#jingleFallback() - */ - public void jingleFallback() { -// System.out.println("Fallback"); - logger.info("Jingle Fallback to IBB."); - tmode = TransferMode.IBB; - try { - if(getState() == State.HOST_FILELIST_SENT){ - /* TODO: send file list another one. */ - transmitter.sendFileList(peer, sharedProject.getFileList()); - } - /* error during send single project file with jingle*/ - if(getState() == State.SYNCHRONIZING){ - sendArchive(); - } - } catch (Exception e) { - failed(e); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.invitation.IInvitationProcess#getTransferMode() - */ - public TransferMode getTransferMode() { - return tmode; - } - - public void setTransferMode(TransferMode mode) { - tmode = mode; - - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IActivitySequencer.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IActivitySequencer.java deleted file mode 100644 index ee050615730b796ca5112b9ae5d71134180f1ad6..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IActivitySequencer.java +++ /dev/null @@ -1,57 +0,0 @@ -package de.fu_berlin.inf.dpp.net; - -import java.util.List; - -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.concurrent.IRequestManager; -import de.fu_berlin.inf.dpp.project.IActivityListener; -import de.fu_berlin.inf.dpp.project.IActivityManager; - -/** - * The IActivitySequencer is responsible for making sure that activities are - * sent and received in the right order. - * - * @author rdjemili - * - */ -public interface IActivitySequencer extends IActivityListener,IRequestManager, IActivityManager { - /** - * Gets all activities since last flush. - * - * @return the activities that have accumulated since the last flush or - * <code>null</code> if no activities are are available. - */ - public List<TimedActivity> flushTimed(); - - /** - * Executes the list of timed activities in the right order. - * - * @param activities - */ - public void exec(List<TimedActivity> activities); - - /** - * Executes given timed activity. - * - * @param activity - */ - public void exec(TimedActivity activity); - - public void execTransformedActivity(IActivity activity); - - /** - * @return the log of flushed activities. - */ - public List<IActivity> getLog(); - - /** - * @return the current timestamp. - */ - public int getTimestamp(); - - public List<TimedActivity> getActivityHistory(); - - public int getQueuedActivities(); - -// public IActivity receiveRequest(Request request); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IChatManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IChatManager.java deleted file mode 100644 index 8083ff9324c850f826e7851b98506648dd7bfcd4..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IChatManager.java +++ /dev/null @@ -1,29 +0,0 @@ -package de.fu_berlin.inf.dpp.net; - -import org.jivesoftware.smack.PacketListener; -import org.jivesoftware.smack.XMPPConnection; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; - -/** - * The IChatManager contains the logic for appropriate chat transfer. - * - * @author orieger - * - * TODO Interface really needed? - */ -public interface IChatManager extends PacketListener { - - public void setConnection(XMPPConnection connection, IReceiver receiver); - - public void setReceiver(IReceiver receiver); - - /** - * status of chat connection. - * - * @return - */ - public boolean isConnected(); - - public void sendRequest(Request request); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IConnectionListener.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IConnectionListener.java deleted file mode 100644 index 1612959e2be14675e1b58a6726495e285239c435..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IConnectionListener.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.net; - -import org.jivesoftware.smack.XMPPConnection; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.Saros.ConnectionState; - -/** - * A listener for changes to the current connection state. Use - * {@link Saros#addListener(IConnectionListener)} to attach it. - * - * @author rdjemili - */ -public interface IConnectionListener { - - /** - * Is fired when the state of the connection changes. - * - * @param connection - * The affected XMPP-connection tht changed its state - * @param newState - * the new state of the connection. If the new state is - * <code>ERROR</code>, you can use - * {@link Saros#getConnectionError()} to get the error message. - */ - public void connectionStateChanged(XMPPConnection connection, ConnectionState newState); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IFileTransferCallback.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IFileTransferCallback.java deleted file mode 100644 index 2f6ced1960823b9a41f7c5deb4a938553af73f4c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IFileTransferCallback.java +++ /dev/null @@ -1,52 +0,0 @@ -package de.fu_berlin.inf.dpp.net; - -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess.TransferMode; - -/** - * This is an simple callback listener for non-blocking file transfers. - * - * @author rdjemili - */ -public interface IFileTransferCallback { - - /** - * Is fired when the file was successfully transfered. - * - * @param path - * the project-relative path to the file. - */ - public void fileSent(IPath path); - - /** - * Is fired when the file transfer failed. - * - * @param path - * the project-relative path to the file. - * @param e - * the exception that caused the fail or <code>null</code>. - */ - public void fileTransferFailed(IPath path, Exception e); - - /** - * Is fired part of file has transfered.. - * - * @param transfered - * current transfered size. - */ - public void transferProgress(int transfered); - - /** - * set transfer mode. - * TransferMode.Jingle for Jingle transfer or TransferMode.IBB - * for XMPP transfer. - * @param mode - */ - public void setTransferMode(TransferMode mode); - - /** - * Is fired if jingle connection couldn't be established. - */ - public void jingleFallback(); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IOptimizer.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IOptimizer.java deleted file mode 100644 index 3ac53d8dea36e7f8915ad8cc5fcb8ce6191b7876..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IOptimizer.java +++ /dev/null @@ -1,9 +0,0 @@ -package de.fu_berlin.inf.dpp.net; - -import java.util.List; - -import de.fu_berlin.inf.dpp.activities.IActivity; - -public interface IOptimizer { - public List<IActivity> optimze(List<IActivity> activities); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IReceiver.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IReceiver.java deleted file mode 100644 index 905910806537865a6eba3ccb1c65b5a811511b73..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IReceiver.java +++ /dev/null @@ -1,19 +0,0 @@ -package de.fu_berlin.inf.dpp.net; - -import org.jivesoftware.smack.PacketListener; -import org.jivesoftware.smack.packet.Packet; - -/** - * The IReceiver contains methods to process incoming packets. - * - * @author orieger - * - */ -public interface IReceiver extends PacketListener { - - /** - * process jupiter request. - * @param packet - */ - public void processRequest(Packet packet); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/ITransmitter.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/ITransmitter.java deleted file mode 100644 index f4be1b3f589162fe02679d681497bfe942214db5..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/ITransmitter.java +++ /dev/null @@ -1,262 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming (c) Freie Universitaet Berlin - - * Fachbereich Mathematik und Informatik - 2006 (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass - * Ave, Cambridge, MA 02139, USA. - */ - -package de.fu_berlin.inf.dpp.net; - -import java.io.File; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; - -import de.fu_berlin.inf.dpp.FileList; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess; -import de.fu_berlin.inf.dpp.project.ISharedProject; - -/** - * An humble interface that is responsible for network functionality. The idea - * behind this interface is to only capsulates the least possible amount of - * functionality - the one that can't be easily tested. - * - * @author rdjemili - */ -public interface ITransmitter { - - /* ---------- invitations --------- */ - - // TODO move aggregation of pending invitation to sessionManager - /** - * Adds given invitation to the list of pending invitations. - * - * @param invitation - * the invitation that to be added. - */ - public void addInvitationProcess(IInvitationProcess invitation); - - /** - * Removes given invitation from the list of pending invitations. - * - * @param invitation - * the invitation that is to be removed. - */ - public void removeInvitationProcess(IInvitationProcess invitation); - - /** - * Sends an invitation message for given shared project to given user. - * - * @param sharedProject - * the shared project to which the user should be invitited to. - * @param jid - * the Jabber ID of the user that is to be invited. - * @param description - * a informal description text that can be provided with the - * invitation. Can not be <code>null</code>. - */ - public void sendInviteMessage(ISharedProject sharedProject, JID jid, String description); - - /** - * Sends an cancellation message that tells the receiver that the invitation - * is canceled. - * - * @param jid - * the Jabber ID of the receipient. - * @param errorMsg - * the reason why the invitation was canceled or - * <code>null</code>. - */ - public void sendCancelInvitationMessage(JID jid, String errorMsg); - - /* ---------- files --------- */ - - /** - * Sends given file list to given Jabber user. This methods blocks until the - * file transfer is done or failed. - * - * @param jid - * the Jabber ID of the user to which the file list is to be - * sent. - * @param fileList - * the file list that is to be sent. - * @throws XMPPException - * is thrown if there is some problem with the XMPP file - * transfer. - */ - public void sendFileList(JID jid, FileList fileList) throws XMPPException; - - /** - * Sends a request-for-file-list-message to given user. - * - * @param recipient - * the Jabber ID of the recipient. - */ - public void sendRequestForFileListMessage(JID recipient); - - /** - * Sends given file to given recipient. - * - * @param recipient - * the Jabber ID of the recipient. - * @param project TODO - * @param path - * the project-relative path of the resource that is to be sent. - * @param callback - * an callback for the file transfer state. Can be - * <code>null</code>. - */ - public void sendFile(JID recipient, IProject project, IPath path, IFileTransferCallback callback); - - /** - * Sends given file to given recipient with given timestamp. - * - * @param recipient - * the Jabber ID of the recipient. - * @param project TODO - * @param path - * the project-relative path of the resource that is to be sent. - * @param timestamp - * the time that will be associated with this activity. - * @param callback - * an callback for the file transfer state. Can be - * <code>null</code>. - */ - public void sendFile(JID recipient, IProject project, IPath path, int timestamp, IFileTransferCallback callback); - - /** - * Sends given archive file to given recipient. - * (Fallback of jingle file transfer to achieve better transfer - * with IBB.) - * - * @param recipient - * the Jabber ID of the recipient. - * @param project TODO - * @param archive - * the project-relative path of the resource that is to be sent. - * @param callback - * an callback for the file transfer state. Can be - * <code>null</code>. - */ - public void sendProjectArchive(JID recipient, IProject project, File archive, IFileTransferCallback callback); - - /** - * Sends queued file transfers. - */ - public void sendRemainingFiles(); - - /** - * Sends queued messages. - */ - public void sendRemainingMessages(); - - /** - * Sends a list of users to given recipient - * @param to - * Receipient of this list - * @param participants - * List of Users, of current shared project participants - */ - public void sendUserListTo(JID to, List<User> participants); - - /** - * Sets my XMPP connection to the given connection - for changing the current connection (like after reconnect). - * - * @param connection - * the new XMPPConnection - */ - public void setXMPPConnection(XMPPConnection connection); - - /** - * Sends a request for activities to all users. - * - * @param sharedProject - * the shared project - * @param timestamp - * the timestamp of the requested activity - * @param andup - * boolean, if all activities after the requested one are requested too - */ - public void sendRequestForActivity(ISharedProject sharedProject, int timestamp, boolean andup); - - - /* ---------- etc --------- */ - - /** - * Sends a join message to the participants of given shared project. See - * {@link IInvitationProcess} for more information when this is supposed be - * sent. - * - * @param sharedProject - * the shared project that this join message refers to. - */ - public void sendJoinMessage(ISharedProject sharedProject); - - /** - * Sends a leave message to the participants of given shared project. See - * {@link IInvitationProcess} for more information when this is supposed be - * sent. - * - * @param sharedProject - * the shared project that this join message refers to. - */ - public void sendLeaveMessage(ISharedProject sharedProject); - - /** - * Sends given list of activities with given timestamp to the participants - * of given shared project. - * - * @param sharedProject - * the shared project the activities refer to. - * @param activities - * a list of timed activities. - */ - public void sendActivities(ISharedProject sharedProject, List<TimedActivity> activities); - - /** - * Sends given list of activities with given timestamp to given participant - * of given shared project. - * - * @param sharedProject - * the shared project the activities refer to. - * @param activity - * activity. - * @param jid - * the recipient - */ - public void sendJupiterRequest(ISharedProject sharedProject, Request request, JID jid); - - /** - * Sends error message of checksum error. - * @param to - * the recipient - * @param path - * appropriate file for checksum error - */ - public void sendFileChecksumError(JID to, IPath path); - - /** - * Sends error messge of transformation error. - * @param to - * the recipient - * @param path - * appropriate file for jupiter transformtion error - */ - public void sendJupiterTransformationError(JID to, IPath path); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/JID.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/JID.java deleted file mode 100644 index 215675d890970fde16144d95411b15a4d9aa6d4c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/JID.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.net; - -import java.io.Serializable; - -import org.jivesoftware.smack.util.StringUtils; - -/** - * A Jabber ID which is used to identify the users of the Jabber network. - * - * @author rdjemili - */ -public class JID implements Serializable{ - private final String jid; - - /** - * Construct a new Jabber-ID - * - * @param jid - * the Jabber ID in the format of user@host[/resource]. Resource - * is optional. - */ - public JID(String jid) { - // TODO check for malformated string - this.jid = jid; - } - - /** - * @return the name segment of this Jabber ID. - * @see StringUtils#parseName(String)) - */ - public String getName() { - return StringUtils.parseName(jid); - } - - /** - * @return the Jabber ID without resource qualifier. - * @see StringUtils#parseBareAddress(String) - */ - public String getBase() { - return StringUtils.parseBareAddress(jid); - } - - /** - * @return the domain segment of this Jabber ID. - * @see StringUtils#parseServer(String) - */ - public String getDomain() { - return StringUtils.parseServer(jid); - } - - /** - * @return the resource segment of this Jabber ID or the empty string if - * there is none. - * @see StringUtils#parseResource(String) - */ - public String getResource() { - return StringUtils.parseResource(jid); - } - - /** - * @return <code>true</code> if the IDs have the same user and domain. - * Resource is ignored. - */ - @Override - public boolean equals(Object obj) { - if (obj instanceof JID) { - JID other = (JID) obj; - return getBase().equals(other.getBase()); - } - - return false; - } - - @Override - public int hashCode() { - return getBase().hashCode(); - } - - /** - * @return the complete string that was used to construct this object. - * - * @see java.lang.Object#toString() - */ - public String toString() { - return jid; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/MUCForbiddenException.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/MUCForbiddenException.java deleted file mode 100644 index 08b8c633c72bb9ababebb9d25582781e5d37efdf..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/MUCForbiddenException.java +++ /dev/null @@ -1,15 +0,0 @@ -package de.fu_berlin.inf.dpp.net; - -public class MUCForbiddenException extends Exception{ - - /** - * - */ - private static final long serialVersionUID = -2264079295534627973L; - - public static final String FORBIDDEN_ERROR_MESSAGE ="forbidden(403) Owner privileges required"; - - public MUCForbiddenException(String message){ - super(message); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/RoomNotExistException.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/RoomNotExistException.java deleted file mode 100644 index f778d961f570229fc3c64c762ad9c7e871752ef9..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/RoomNotExistException.java +++ /dev/null @@ -1,22 +0,0 @@ -package de.fu_berlin.inf.dpp.net; - -/** - * - * An Exception that is thrown when an error occurs performing an room operation with non - * existing room. - * @author rieger - * - */ -public class RoomNotExistException extends Exception{ - - public static final String MUC_ERROR_MESSAGE = "item-not-found(404) Conference room does not exist"; - - /** - * - */ - private static final long serialVersionUID = -7470837131463504604L; - - public RoomNotExistException(String message){ - super(message); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/TimedActivity.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/TimedActivity.java deleted file mode 100644 index 41957c0c07a9c83b4f038bf72eb081d7c87411d6..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/TimedActivity.java +++ /dev/null @@ -1,55 +0,0 @@ -package de.fu_berlin.inf.dpp.net; - -import de.fu_berlin.inf.dpp.activities.IActivity; - -/** - * A simple {@link IActivity} wrapper that add an time stamp. - * - * @author rdjemili - */ -public class TimedActivity { - private IActivity activity; - - private int timestamp; - - /** - * Constructs a new TimedActivity. - * - * @param activity - * the activity. - * @param timestamp - * the timestamp that belongs to the activity. - */ - public TimedActivity(IActivity activity, int timestamp) { - this.activity = activity; - this.timestamp = timestamp; - } - - /** - * @return the activity. - */ - public IActivity getActivity() { - return activity; - } - - /** - * @return the timestamp of the activiy. - */ - public int getTimestamp() { - return timestamp; - } - - @Override - public String toString() { - return "[" + timestamp + ":" + activity + "]"; - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof TimedActivity)) - return false; - - TimedActivity other = (TimedActivity) obj; - return other.activity.equals(activity) && other.timestamp == timestamp; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/ActivitiesPacketExtension.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/ActivitiesPacketExtension.java deleted file mode 100644 index 090dec236c6e18e2ad31872a52dc09a30b392f35..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/ActivitiesPacketExtension.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.net.internal; - -import java.text.MessageFormat; -import java.util.List; - -import org.jivesoftware.smack.packet.PacketExtension; - -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.net.TimedActivity; -import de.fu_berlin.inf.dpp.project.ActivityRegistry; - -public class ActivitiesPacketExtension implements PacketExtension { - public static final String NAMESPACE = "de.fu_berlin.inf.dpp"; - - public static final String ELEMENT = "activities"; - - public static final String TEXT_CHANGE_TAG = "edit"; - - private List<TimedActivity> activities; - - MessageFormat textChangeFormat = new MessageFormat( - "<{0} offset=\"{1}\" replace=\"{2}\">{3}</{4}>"); // TODO extract into - - // consts - - public ActivitiesPacketExtension() { - } - - public ActivitiesPacketExtension(List<TimedActivity> activities) { - setActivities(activities); - } - - /* - * (non-Javadoc) - * - * @see org.jivesoftware.smack.packet.PacketExtension#getElementName() - */ - public String getElementName() { - return ELEMENT; - } - - /* - * (non-Javadoc) - * - * @see org.jivesoftware.smack.packet.PacketExtension#getNamespace() - */ - public String getNamespace() { - return NAMESPACE; - } - - public void setActivities(List<TimedActivity> activities) { - this.activities = activities; - } - - public List<TimedActivity> getActivities() { - return activities; - } - - /* - * (non-Javadoc) - * - * @see org.jivesoftware.smack.packet.PacketExtension#toXML() - */ - public String toXML() { - if (activities.size() == 0) - return ""; - - StringBuffer buf = new StringBuffer(); - buf.append("<").append(getElementName()); - buf.append(" xmlns=\"").append(getNamespace()).append("\">"); - - int firstTimestamp = activities.get(0).getTimestamp(); - buf.append("<timestamp>").append(firstTimestamp).append("</timestamp>"); - - ActivityRegistry activityRegistry = ActivityRegistry.getDefault(); - for (TimedActivity timedActivity : activities) { - IActivity activity = timedActivity.getActivity(); - buf.append(activityRegistry.toXML(activity)); - } - - buf.append("</").append(getElementName()).append(">"); - return buf.toString(); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (obj instanceof ActivitiesPacketExtension) { - ActivitiesPacketExtension other = (ActivitiesPacketExtension) obj; - - return activities.equals(other.getActivities()); - } - - return false; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/ActivitiesProvider.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/ActivitiesProvider.java deleted file mode 100644 index 76b2dd004507b24f854a7db53902916fb2b652fc..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/ActivitiesProvider.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.net.internal; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.jivesoftware.smack.provider.PacketExtensionProvider; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.net.TimedActivity; -import de.fu_berlin.inf.dpp.project.ActivityRegistry; - -// TODO rename to ActivitiesExtensionProvider -public class ActivitiesProvider implements PacketExtensionProvider { - - public ActivitiesPacketExtension parseExtension(XmlPullParser parser) - throws XmlPullParserException, IOException { - - List<TimedActivity> timedActivities = new ArrayList<TimedActivity>(); - int time = -1; - - boolean done = false; - while (!done) { - int eventType = parser.next(); - if (eventType == XmlPullParser.START_TAG) { - - if (parser.getName().equals("timestamp")) { - time = parseTime(parser); - } - - ActivityRegistry activityRegistry = ActivityRegistry.getDefault(); - IActivity activity = activityRegistry.parseActivity(parser); - if (activity != null) { - timedActivities.add(new TimedActivity(activity, time)); - time++; - } - - } else if (eventType == XmlPullParser.END_TAG) { - if (parser.getName().equals("activities")) { - done = true; - } - } - } - - return new ActivitiesPacketExtension(timedActivities); - } - - private int parseTime(XmlPullParser parser) throws XmlPullParserException, IOException { - parser.next(); // read text - int time = Integer.parseInt(parser.getText()); - parser.next(); // read end tag - - return time; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/ActivitySequencer.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/ActivitySequencer.java deleted file mode 100644 index 341a15fc0763f63fc3c3ca2afab5e576709e21d1..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/ActivitySequencer.java +++ /dev/null @@ -1,614 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.net.internal; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Vector; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.apache.log4j.Logger; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.text.TextSelection; - -import de.fu_berlin.inf.dpp.activities.EditorActivity; -import de.fu_berlin.inf.dpp.activities.FileActivity; -import de.fu_berlin.inf.dpp.activities.FolderActivity; -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.activities.TextEditActivity; -import de.fu_berlin.inf.dpp.activities.TextSelectionActivity; -import de.fu_berlin.inf.dpp.activities.EditorActivity.Type; -import de.fu_berlin.inf.dpp.concurrent.ConcurrentManager; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.RequestForwarder; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.RequestError; -import de.fu_berlin.inf.dpp.concurrent.management.ConcurrentDocumentManager; -import de.fu_berlin.inf.dpp.net.IActivitySequencer; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.net.TimedActivity; -import de.fu_berlin.inf.dpp.project.IActivityManager; -import de.fu_berlin.inf.dpp.project.IActivityProvider; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.util.FileUtil; - -/** - * Implements {@link IActivitySequencer} and {@link IActivityManager}. - * - * @author rdjemili - */ -public class ActivitySequencer implements RequestForwarder, IActivitySequencer { - - private static Logger logger = Logger.getLogger(ExecuterQueue.class); - /**/ - public class ExecuterQueue { - - - /** Queue with IActivity Elements */ - private List<TextEditActivity> executerQueue; - - private TextEditActivity currentExecutedActivity; - - private boolean executed = true; - - public ExecuterQueue() { - this.executerQueue = new Vector<TextEditActivity>(); - } - - /** - * check status of created activity. After execution in ActivitySequencer - * activity has created new call of activityCreated. - * @param activity - */ - public synchronized boolean checkCreatedActivity(IActivity activity){ - if(currentExecutedActivity != null){ - if(activity instanceof TextEditActivity && currentExecutedActivity.sameLike(activity)){ - logger.debug("TextEditActivity "+activity+ " is executed."); - executed = true; - notify(); - } - } - return executed; - } - - public synchronized void addActivity(IActivity activity) { - if(activity instanceof TextEditActivity){ - logger.debug("Add new Activity "+activity+ " to executer queue."); - executerQueue.add((TextEditActivity)activity); - notify(); - } - } - - public synchronized IActivity getNextActivity() { - try { - while (executerQueue.size() < 1 && !executed) { - wait(); - } - currentExecutedActivity = executerQueue.remove(0); - executed = false; - logger.debug("Remove "+currentExecutedActivity+" form executer queue."); - /* get next activity in queue. */ - return currentExecutedActivity; - } catch (InterruptedException e) { - e.printStackTrace(); - return null; - } - - } - } - - private static final int UNDEFINED_TIME = -1; - - private static Logger log = Logger.getLogger(ActivitySequencer.class - .getName()); - - private List<IActivity> activities = new LinkedList<IActivity>(); - - private List<IActivity> flushedLog = new LinkedList<IActivity>(); - - private List<IActivityProvider> providers = new LinkedList<IActivityProvider>(); - - private List<TimedActivity> queue = new CopyOnWriteArrayList<TimedActivity>(); - - private List<TimedActivity> activityHistory = new LinkedList<TimedActivity>(); - - private int timestamp = UNDEFINED_TIME; - - private ConcurrentManager concurrentManager; - - /** outgoing queue for direct client sync messages for all driver. */ - private List<Request> outgoingSyncActivities = new Vector<Request>(); - - private IActivity executedJupiterActivity; - - private ExecuterQueue executer; - - private ISharedProject sharedProject; - - public ActivitySequencer(){ - executer = new ExecuterQueue(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.IActivityManager - */ - public void exec(IActivity activity) { - try { - - if(activity instanceof EditorActivity){ - concurrentManager.exec(activity); - } - if(activity instanceof FileActivity){ - concurrentManager.exec(activity); - } - if(activity instanceof FolderActivity){ - - } - if (activity instanceof TextEditActivity) { - /* check if document is already managed by jupiter mechanism. */ - if (!concurrentManager.isHostSide() - && concurrentManager.exec(activity) != null) { - // CLIENT SIDE - logger.debug("Execute received activity (without jupiter): "+activity); - for (IActivityProvider executor : providers) { - executor.exec(activity); - } - } - } else { - - // Execute all other activities - for (IActivityProvider executor : providers) { - executor.exec(activity); - } - - //Check for file checksum after incoming save file activity. - if (activity instanceof EditorActivity && ((EditorActivity)activity).getType() == EditorActivity.Type.Saved) { - checkSavedFile((EditorActivity) activity); - } - - } - - } catch (Exception e) { - log.error("Error while executing activity.", e); - } - } - - /** - * this class check the match of local and remote file checksum. - * @param editor incoming editor activity with type saved - */ - private void checkSavedFile(EditorActivity editor){ - /* 1. reset appropriate jupiter document. */ - if(isHostSide() || sharedProject.isDriver()){ - logger.debug("reset jupiter server for "+editor.getPath()); - concurrentManager.resetJupiterDocument(editor.getPath()); - } - - /* check match of file checksums. */ - - if( !isHostSide() && editor.getType() == Type.Saved){ - long checksum = FileUtil.checksum(sharedProject.getProject().getFile(editor.getPath())); - logger.debug("Checksumme on client side : "+checksum+ " for path : "+editor.getPath().toOSString()); - if(checksum != editor.getChecksum()){ - logger.error("Checksum error of file "+editor.getPath()); - } - } - if(isHostSide()){ - /* create local checksum. */ - long checksum = FileUtil.checksum(sharedProject.getProject().getFile(editor.getPath())); - - if(checksum != editor.getChecksum()){ - /* send checksum error*/ - logger.error("Checksum error for file "+editor.getPath()+" of "+editor.getSource()+ " ( "+checksum+" != "+editor.getChecksum()+" )"); - - /* send checksum error*/ - FileActivity fileError = new FileActivity(FileActivity.Type.Error, editor.getPath(), new JID(editor.getSource())); - activityCreated(fileError); - /* send sync file. */ - FileActivity file = new FileActivity(FileActivity.Type.Created, editor.getPath(), new JID(editor.getSource())); - activityCreated(file); - } - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.IActivitySequencer - */ - public void exec(TimedActivity timedActivity) { - queue.add(timedActivity); - execQueue(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivitySequencer - */ - public void exec(List<TimedActivity> activities) { - queue.addAll(activities); - execQueue(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityManager - */ - public List<IActivity> flush() { - List<IActivity> out = new ArrayList<IActivity>(activities); - activities.clear(); - out = optimize(out); - flushedLog.addAll(out); - return out.size() > 0 ? out : null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.IActivitySequencer - */ - public List<TimedActivity> flushTimed() { - List<IActivity> activities = flush(); - - if (activities == null) - return null; - - if (timestamp == UNDEFINED_TIME) - timestamp = 0; - - List<TimedActivity> timedActivities = new ArrayList<TimedActivity>(); - for (IActivity activity : activities) { - timedActivities.add(new TimedActivity(activity, timestamp++)); - } - - return timedActivities; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityManager - */ - public void addProvider(IActivityProvider provider) { - providers.add(provider); - provider.addActivityListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityManager - */ - public void removeProvider(IActivityProvider provider) { - providers.remove(provider); - provider.removeActivityListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivitySequencer - */ - public List<IActivity> getLog() { - return flushedLog; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityListener - */ - public void activityCreated(IActivity activity) { - - if(activity instanceof EditorActivity || activity instanceof FileActivity){ - /* Host: start and stop jupiter server process depending on editor activities - * of remote clients. - * Client: start and stop local jupiter clients depending on editor activities. - * */ - concurrentManager.activityCreated(activity); - } - - if (activity instanceof TextEditActivity){ - - /* - * 1. if activity received from remote client and just executed, - * then send to all observer. - */ - // TextEditActivity ac = (TextEditActivity) activity; - // if(concurrentManager.isHostSide() && ac.getSource() != null){ - // activities.add(activity); - // return; - // } - - /* check for execute next activity in queue.*/ - log.debug("activity created : "+activity); - executer.checkCreatedActivity(activity); - - /* activity is already managed by jupiter and executed now. */ - if (executedJupiterActivity != null - && isHostSide() - && ((TextEditActivity) activity) - .sameLike(executedJupiterActivity)) { - /* Send message to all. */ - activities.add(activity); - return; - } else { - /* - * new text edit activity has created and has to sync with - * jupiter logic. - */ - IActivity resultAC = concurrentManager - .activityCreated(activity); - /** - * host activity: put into outgoing queue and send to all if - * activity is generated by host. otherwise: send request to - * host. - */ - if (resultAC != null || concurrentManager.isHostSide()) { - activities.add(activity); - } - } - - } else { - - activities.add(activity); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.IActivitySequencer - */ - public int getTimestamp() { - return timestamp; - } - - public int getQueuedActivities() { - return queue.size(); - } - - public List<TimedActivity> getActivityHistory() { - return activityHistory; - } - - /** - * Executes as much activities as possible from the current queue regarding - * to their individual time stamps. - */ - private void execQueue() { - boolean executed; - - do { - executed = false; - - for (TimedActivity timedActivity : queue) { - if (timestamp == UNDEFINED_TIME) - timestamp = timedActivity.getTimestamp(); - - if (timedActivity.getTimestamp() <= timestamp) { - queue.remove(timedActivity); - - timestamp++; - exec(timedActivity.getActivity()); - executed = true; - } - } - - } while (executed); - - } - - // TODO extract this into the activities themselves - private List<IActivity> optimize(List<IActivity> activities) { - List<IActivity> result = new ArrayList<IActivity>(activities.size()); - - ITextSelection selection = null; - String source = null; - - for (IActivity activity : activities) { - source = null; - if (activity instanceof TextEditActivity) { - TextEditActivity textEdit = (TextEditActivity) activity; - - textEdit = joinTextEdits(result, textEdit); - - selection = new TextSelection(textEdit.offset - + textEdit.text.length(), 0); - source = textEdit.getSource(); - result.add(textEdit); - - } else if (activity instanceof TextSelectionActivity) { - TextSelectionActivity textSelection = (TextSelectionActivity) activity; - - selection = new TextSelection(textSelection.getOffset(), - textSelection.getLength()); - source = textSelection.getSource(); - - } else { - selection = addSelection(result, selection, null); - result.add(activity); - } - - selection = addSelection(result, selection, source); - } - - return result; - } - - private TextEditActivity joinTextEdits(List<IActivity> result, - TextEditActivity textEdit) { - if (result.size() == 0) - return textEdit; - - IActivity lastActivity = result.get(result.size() - 1); - if (lastActivity instanceof TextEditActivity) { - TextEditActivity lastTextEdit = (TextEditActivity) lastActivity; - - if ((lastTextEdit.getSource() == null || lastTextEdit.getSource() - .equals(textEdit.getSource())) - && textEdit.offset == lastTextEdit.offset - + lastTextEdit.text.length()) { - result.remove(lastTextEdit); - textEdit = new TextEditActivity(lastTextEdit.offset, - lastTextEdit.text + textEdit.text, lastTextEdit.replace - + textEdit.replace); - textEdit.setSource(lastTextEdit.getSource()); - textEdit.setEditor(lastTextEdit.getEditor()); - } - } - - return textEdit; - } - - private ITextSelection addSelection(List<IActivity> result, - ITextSelection selection, String source) { - if (selection == null) - return null; - - if (result.size() > 0) { - IActivity lastActivity = result.get(result.size() - 1); - if (lastActivity instanceof TextEditActivity) { - TextEditActivity lastTextEdit = (TextEditActivity) lastActivity; - - if (selection.getOffset() == lastTextEdit.offset - + lastTextEdit.text.length() - && selection.getLength() == 0) { - - return selection; - } - } - } - - TextSelectionActivity newSel = new TextSelectionActivity(selection - .getOffset(), selection.getLength()); - newSel.setSource(source); - result.add(newSel); - - selection = null; - return selection; - } - - public void initConcurrentManager( - de.fu_berlin.inf.dpp.concurrent.ConcurrentManager.Side side, - de.fu_berlin.inf.dpp.User host, JID myJID, - ISharedProject sharedProject) { - concurrentManager = new ConcurrentDocumentManager(side, host, myJID, sharedProject); - this.sharedProject = sharedProject; - sharedProject.addListener(concurrentManager); - concurrentManager.setRequestForwarder(this); - concurrentManager.setActivitySequencer(this); - } - - public ConcurrentManager getConcurrentManager() { - return concurrentManager; - } - - public synchronized void forwardOutgoingRequest(Request req) { - - /* check for errors. */ - if(req instanceof RequestError){ - /* create save activity. */ - IActivity activity = new EditorActivity(Type.Saved, req.getEditorPath()); - /* execute save activity and start consistency check. */ - exec(activity); - return; - } - - /* put request into outgoing queue. */ - outgoingSyncActivities.add(req); - - notify(); - } - - public synchronized Request getNextOutgoingRequest() - throws InterruptedException { - Request request = null; - /* get next message and transfer to client. */ - while (!(outgoingSyncActivities.size() > 0)) { - wait(); - } - /* remove first queue element. */ - request = outgoingSyncActivities.remove(0); - - return request; - } - - /** - * Receive request from ITransmitter and transfer to concurrent control. - */ - public void receiveRequest(Request request) { - /* - * sync with jupiter server on host side and transform operation with - * jupiter client side. - */ - log.debug("Receive request : " + request + " from " + request.getJID()); - concurrentManager.receiveRequest(request); - - // return null; - // IActivity activity = concurrentManager.receiveRequest(request); - // if (activity != null) { - // /* execute transformed activity */ - // execTransformedActivity(activity); - // } - // return activity; - } - - private boolean isHostSide(){ - return concurrentManager.isHostSide(); - } - - /** - * Execute activity after jupiter transforming process. - * - * @param activity - */ - public void execTransformedActivity(IActivity activity) { - try { - log.debug("execute transformed activity: " + activity); - - /* add new activity to executer queue. */ - executer.addActivity(activity); - - /* get next activity from queue or waiting for finishing of - * current execute activity.*/ - IActivity queueActivity = executer.getNextActivity(); - - // mark current execute activity -// executedJupiterActivity = activity; - executedJupiterActivity = queueActivity; - - for (IActivityProvider exec : providers) { - exec.exec(activity); - } - /* send activity to all observer. */ - if (concurrentManager.isHostSide()) { - log.debug("send transformed activity: " + activity); - activities.add(activity); - } - } catch (Exception e) { - log.error("Error while executing activity.", e); - } - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/FileTransferProcessMonitor.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/FileTransferProcessMonitor.java deleted file mode 100644 index 96840383a02fafa2467c3d9d31241f921a9e6c33..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/FileTransferProcessMonitor.java +++ /dev/null @@ -1,84 +0,0 @@ -package de.fu_berlin.inf.dpp.net.internal; - -import org.apache.log4j.Logger; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smackx.filetransfer.FileTransfer; - -import de.fu_berlin.inf.dpp.net.IFileTransferCallback; - -/** - * for information on monitoring the process of a file tranfer - * - * @author troll - * - */ -public class FileTransferProcessMonitor extends Thread { - - private static Logger logger = Logger.getLogger(FileTransferProcessMonitor.class); - - FileTransfer transfer; - private int TIMEOUT = 10000; - - private boolean running = true; - - private boolean closeMonitor = false; - - private IFileTransferCallback callback; - - public FileTransferProcessMonitor(FileTransfer transfer) { - this.transfer = transfer; - start(); - } - - public FileTransferProcessMonitor(FileTransfer transfer, IFileTransferCallback callback) { - this.transfer = transfer; - this.callback = callback; - start(); - } - - public boolean isRunning() throws XMPPException { - return this.running; - } - - public String getException() { - return null; - } - - public void closeMonitor(boolean close) { - this.closeMonitor = close; - } - - public void run() { - int time = 0; - - while (!closeMonitor ) { - try { - while (!transfer.isDone() && (transfer.getProgress()<1.0)) { - - /* check negotiator process */ - logger.debug("Status: " + transfer.getStatus() - + " Progress : " + transfer.getProgress()); - if(callback != null){ - callback.transferProgress((int)(transfer.getProgress()*100)); - } - if(closeMonitor){ - return; - } - Thread.sleep(500); - } - this.running = false; - time = time + 500; - - if(time>TIMEOUT){ - closeMonitor = true; - return; - } - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/JingleFileTransferData.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/JingleFileTransferData.java deleted file mode 100644 index 2e3de2619c40d805f3ee5487e9372d7252d38768..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/JingleFileTransferData.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * - */ -package de.fu_berlin.inf.dpp.net.internal; - -import java.io.File; -import java.io.Serializable; - -import de.fu_berlin.inf.dpp.net.JID; - -public class JingleFileTransferData implements Serializable{ - private static final long serialVersionUID = -4063208452619555716L; - - public static enum FileTransferType{ - /* file list information is transfer. */ - FILELIST_TRANSFER, - /* single resource is transfer. */ - RESOURCE_TRANSFER, - } - - public FileTransferType type; - - public String file_list_content; - public JID recipient; - public JID sender; - public String project_name; - public String file_project_path; - public int timestamp; - public long filesize; - public byte[] content; - - /*for testing only */ - public File file; - public String filePath; -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/MultiUserChatManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/MultiUserChatManager.java deleted file mode 100644 index 0c02cc3a447b5071c024dd25bddedfba7a3f2207..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/MultiUserChatManager.java +++ /dev/null @@ -1,192 +0,0 @@ -package de.fu_berlin.inf.dpp.net.internal; - -import java.util.Iterator; -import java.util.List; - -import org.apache.log4j.Logger; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.jivesoftware.smack.PacketListener; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.packet.Message; -import org.jivesoftware.smack.packet.Packet; -import org.jivesoftware.smackx.Form; -import org.jivesoftware.smackx.FormField; -import org.jivesoftware.smackx.muc.MultiUserChat; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.net.IReceiver; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.net.TimedActivity; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.util.PacketProtokollLogger; - -public class MultiUserChatManager implements PacketListener { - - private static Logger log = Logger.getLogger(MultiUserChatManager.class - .getName()); - - // TODO: Room name should be configured by settings. - /* name of multi user chat room */ - private String room = "saros"; - - /* host name of jabber-server on which the muc room is created */ - private String server = "conference.jabber.org"; - - // TODO really needed as field? - private static String JID_PROPERTY = "jid"; - - /* current muc connection. */ - private MultiUserChat muc; - - public MultiUserChatManager(String roomName) { - room = roomName; - } - - public void initMUC(XMPPConnection connection, String user, String room) - throws XMPPException { - this.room = room; - initMUC(connection, user); - } - - public void initMUC(XMPPConnection connection, String user) - throws XMPPException { - - /* create room domain of current connection. */ - // JID(connection.getUser()).getDomain(); - String host = room + "@" + server; - - // Create a MultiUserChat using an XMPPConnection for a room - MultiUserChat muc = new MultiUserChat(connection, host); - - // try to join to room - try { - muc.join(user); - } catch (XMPPException e) { - log.debug(e); - if (e.getMessage().contains("404")) { - // room doesn't exist - - try { - - // Create the room - muc.create("testbot"); - - // Get the the room's configuration form - Form form = muc.getConfigurationForm(); - - // Create a new form to submit based on the original form - Form submitForm = form.createAnswerForm(); - - // Add default answers to the form to submit - for (Iterator fields = form.getFields(); fields.hasNext();) { - FormField field = (FormField) fields.next(); - if (!FormField.TYPE_HIDDEN.equals(field.getType()) - && field.getVariable() != null) { - // Sets the default value as the answer - submitForm.setDefaultAnswer(field.getVariable()); - } - } - - // set configuration, see XMPP Specs - submitForm.setAnswer("muc#roomconfig_moderatedroom", true); - submitForm.setAnswer("muc#roomconfig_allowinvites", true); - submitForm - .setAnswer("muc#roomconfig_persistentroom", false); - - // Send the completed form (with default values) to the - // server to configure the room - muc.sendConfigurationForm(submitForm); - - } catch (XMPPException ee) { - log.debug(e.getLocalizedMessage(), ee); - throw ee; - } - } else { - log.debug(e.getLocalizedMessage(), e); - throw e; - } - } - this.muc = muc; - } - - /** - * this method returns current muc or null no muc exists. - * - * @return - */ - public MultiUserChat getMUC() { - return muc; - } - - public void sendActivities(ISharedProject sharedProject, - List<TimedActivity> activities) { - - // log.info("Sent muc activities: " + activities); - try { - /* create new message for multi chat. */ - Message newMessage = muc.createMessage(); - /* add packet extension. */ - newMessage.addExtension(new ActivitiesPacketExtension(activities)); - /* add jid property */ - newMessage.setProperty(JID_PROPERTY, Saros.getDefault().getMyJID() - .toString()); - - // newMessage.setBody("test"); - muc.sendMessage(newMessage); - PacketProtokollLogger.getInstance().sendPacket(newMessage); - - } catch (XMPPException e) { - - Saros.getDefault().getLog().log( - new Status(IStatus.ERROR, Saros.SAROS, IStatus.ERROR, - "Could not send message, message queued", e)); - } - - } - - /** - * This method check sender of packet. - * - * @param packet - * incoming packet - * @param jid - * @return true if given jid is sender of packet. - */ - private boolean isMessageFromJID(Packet packet, JID jid) { - if (packet instanceof Message) { - Message message = (Message) packet; - /* replace room */ - String sender = message.getFrom(); - /* replace room info */ - sender = sender.replace(room + "/", ""); - if (sender.equals(jid.toString())) { - message.setFrom(sender); - return true; - } else { - return false; - } - } - return false; - } - - public void processPacket(Packet packet) { - // TODO should processing here instead of MessagingManager? - } - - public void setReceiver(IReceiver receiver) { - - } - - public String getRoomName() { - return this.room; - } - - public boolean isConnected() { - if (muc != null && muc.isJoined()) { - return true; - } - return false; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/PacketExtensions.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/PacketExtensions.java deleted file mode 100644 index e3ec7f0f06a0d798f061b0b32a576a8113a0a880..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/PacketExtensions.java +++ /dev/null @@ -1,276 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.net.internal; - -import java.util.List; - -import org.eclipse.core.runtime.IPath; -import org.jivesoftware.smack.packet.DefaultPacketExtension; -import org.jivesoftware.smack.packet.Message; -import org.jivesoftware.smack.packet.PacketExtension; -import org.jivesoftware.smack.provider.ProviderManager; - -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.net.JID; - -/** - * Holds various simple helper methods to create and parse simple Smack packet - * extensions. - * - * @author rdjemili - */ -public class PacketExtensions { - public static final String NAMESPACE = "de.fu_berlin.inf.dpp"; - - // elements - private static final String INVITATION = "invite"; - - private static final String CANCEL_INVITATION = "cancelInvite"; - - private static final String JOIN = "join"; - - private static final String LEAVE = "leave"; - - private static final String REQUEST_FOR_LIST = "requestList"; - - private static final String REQUEST_FOR_ACTIVITY = "requestActivity"; - - private static final String USER_LIST = "userList"; - - private static final String DATATRANSFER = "DataTransfer"; - - private static final String JINGLEERROR = "JingleError"; - - private static final String FILE_CHECKSUM_ERROR = "FileChecksumError"; - - private static final String JUPITER_TRANSFORMATION_ERROR = "JupiterTransformationError"; - - - - // attributes - public static final String DESCRIPTION = "description"; - - public static final String PROJECTNAME = "description"; - - public static final String ERROR = "error"; - - public static final String DT_NAME = "DTNAME"; - - public static final String DT_DESC = "DTDESC"; - - public static final String DT_SPLIT = "DTSPLIT"; - - public static final String DT_DATA = "DATA_BASE64"; - - public static final String FILE_PATH = "filename"; - - - - public static void hookExtensionProviders() { - - ProviderManager providermanager = ProviderManager.getInstance(); - providermanager.addExtensionProvider(ActivitiesPacketExtension.ELEMENT, NAMESPACE, - new ActivitiesProvider()); - providermanager.addExtensionProvider(RequestPacketExtension.ELEMENT, RequestPacketExtension.NAMESPACE, - new RequestExtensionProvider()); - - //TODO: Änderung für Smack 3 -// ProviderManager.addExtensionProvider(ActivitiesPacketExtension.ELEMENT, NAMESPACE, -// new ActivitiesProvider()); - } - - /** - * Creates the packet extension for new invitations. - * - * @param description - * an informal text that will be shown with the invitation. - * @return the packet extension. - */ - public static PacketExtension createInviteExtension(String projectName, String description) { - DefaultPacketExtension extension = new DefaultPacketExtension(INVITATION, NAMESPACE); - extension.setValue(PROJECTNAME, projectName); - extension.setValue(DESCRIPTION, description); - - return extension; - } - - /** - * Creates the packet extension for canceling invitations. - * - * @param error - * an user-readable text that contains the reason for the - * cancellation. Can be <code>null</code>. - * @return the packet extension. - */ - public static PacketExtension createCancelInviteExtension(String error) { - DefaultPacketExtension extension = new DefaultPacketExtension(CANCEL_INVITATION, NAMESPACE); - - if (error != null && error.length() > 0) - extension.setValue(ERROR, error); - return extension; - } - - public static PacketExtension createRequestForActivityExtension(int timestamp, boolean andup) { - - DefaultPacketExtension extension = new DefaultPacketExtension(REQUEST_FOR_ACTIVITY, NAMESPACE); - extension.setValue("ID", (new Integer(timestamp)).toString() ); - - if (andup) - extension.setValue("ANDUP", "true" ); - - return extension; - } - - public static PacketExtension createDataTransferExtension(String name, String desc, int index, int count, String data) { - - DefaultPacketExtension extension = new DefaultPacketExtension(DATATRANSFER, NAMESPACE); - extension.setValue(DT_NAME, name ); - extension.setValue(DT_DESC, desc ); - extension.setValue(DT_DATA, data ); - - String split= index+"/" + count; - extension.setValue(DT_SPLIT, split ); - - return extension; - } - - - public static PacketExtension createRequestForFileListExtension() { - return createExtension(REQUEST_FOR_LIST); - } - - public static PacketExtension createJoinExtension() { - return createExtension(JOIN); - } - - public static PacketExtension createLeaveExtension() { - return createExtension(LEAVE); - } - - public static PacketExtension createJingleErrorExtension(){ - return createExtension(JINGLEERROR); - } - - public static PacketExtension createChecksumErrorExtension(IPath path){ - DefaultPacketExtension extension = new DefaultPacketExtension(FILE_CHECKSUM_ERROR, NAMESPACE); - extension.setValue(FILE_PATH, path.toOSString()); - - return extension; - } - - public static PacketExtension createJupiterErrorExtension(IPath path){ - DefaultPacketExtension extension = new DefaultPacketExtension(JUPITER_TRANSFORMATION_ERROR, NAMESPACE); - extension.setValue(FILE_PATH, path.toOSString()); - - return extension; - } - - public static PacketExtension createUserListExtension(List<User> list) { - DefaultPacketExtension extension = new DefaultPacketExtension(USER_LIST, NAMESPACE); - - int count=0; - for (User participant : list ) { - JID jid = participant.getJid(); - String id="User" +count; - String role="UserRole"+count; - String color = "UserColor"+count; - extension.setValue( id , jid.toString() ); - extension.setValue(role, participant.getUserRole().toString()); - extension.setValue(color, participant.getColorID()+""); - count++; - } - - return extension; - } - - /** - * Tries to create an default packet extension from given message. The - * invite extension has a description field. - */ - public static DefaultPacketExtension getInviteExtension(Message message) { - return getExtension(INVITATION, message); - } - - /** - * Tries to create an default packet extension from given message. The - * cancel extension can have a error field. - */ - public static DefaultPacketExtension getCancelInviteExtension(Message message) { - return getExtension(CANCEL_INVITATION, message); - } - - public static DefaultPacketExtension getJoinExtension(Message message) { - return getExtension(JOIN, message); - } - - public static DefaultPacketExtension getLeaveExtension(Message message) { - return getExtension(LEAVE, message); - } - - public static DefaultPacketExtension getJingleErrorExtension(Message message){ - return getExtension(JINGLEERROR, message); - } - - public static DefaultPacketExtension getJupiterErrorExtension(Message message){ - return getExtension(JUPITER_TRANSFORMATION_ERROR, message); - } - - public static DefaultPacketExtension getChecksumErrorExtension(Message message){ - return getExtension(FILE_CHECKSUM_ERROR, message); - } - - public static DefaultPacketExtension getUserlistExtension(Message message) { - return getExtension(USER_LIST, message); - } - - - public static DefaultPacketExtension getRequestActivityExtension(Message message) { - return getExtension(REQUEST_FOR_ACTIVITY, message); - } - - public static DefaultPacketExtension getRequestExtension(Message message) { - return getExtension(REQUEST_FOR_LIST, message); - } - - public static DefaultPacketExtension getDataTransferExtension(Message message) { - return getExtension(DATATRANSFER, message); - } - - public static ActivitiesPacketExtension getActvitiesExtension(Message message) { - return (ActivitiesPacketExtension) message.getExtension(ActivitiesPacketExtension.ELEMENT, - NAMESPACE); - } - - public static RequestPacketExtension getJupiterRequestExtension(Message message) { - return (RequestPacketExtension) message.getExtension(RequestPacketExtension.ELEMENT, - NAMESPACE); - } - - private static DefaultPacketExtension createExtension(String element) { - DefaultPacketExtension extension = new DefaultPacketExtension(element, NAMESPACE); - extension.setValue(element, ""); - return extension; - } - - private static DefaultPacketExtension getExtension(String element, Message message) { - return (DefaultPacketExtension) message.getExtension(element, NAMESPACE); - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/RequestExtensionProvider.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/RequestExtensionProvider.java deleted file mode 100644 index fc07788215ec6fc06aaee7a3b361d09f220cad0c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/RequestExtensionProvider.java +++ /dev/null @@ -1,209 +0,0 @@ -package de.fu_berlin.inf.dpp.net.internal; - -import java.io.IOException; - -import org.eclipse.core.runtime.Path; -import org.jivesoftware.smack.packet.PacketExtension; -import org.jivesoftware.smack.provider.PacketExtensionProvider; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.JupiterVectorTime; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.RequestImpl; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.DeleteOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.InsertOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.NoOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.SplitOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.TimestampOperation; -import de.fu_berlin.inf.dpp.net.JID; - -public class RequestExtensionProvider implements PacketExtensionProvider{ - - public PacketExtension parseExtension(XmlPullParser parser) - throws XmlPullParserException, IOException { - - - Request request = null; - String path = null; - String jid = null; - int id = 0; - - try{ - boolean done = false; - while (!done) { - int eventType = parser.next(); - if (eventType == XmlPullParser.START_TAG) { - - if(parser.getName().equals(RequestPacketExtension.ELEMENT)){ - parser.next(); - } - - if (parser.getName().equals(RequestPacketExtension.PATH)) { - path = parsePath(parser); - parser.next(); - } - - if(parser.getName().equals(RequestPacketExtension.JID)){ - jid = parseJID(parser); - parser.next(); - } - - request = parseRequest(parser); - - request.setEditorPath(new Path(path)); - request.setJID(new JID(jid)); - - - - } else if (eventType == XmlPullParser.END_TAG) { - if (parser.getName().equals(RequestPacketExtension.ELEMENT)) { - done = true; - } - } - } - }catch(Exception e){ -// System.out.println("Mist"); - e.printStackTrace(); - } - - return new RequestPacketExtension(request); -// return null; - } - - private String parsePath(XmlPullParser parser) throws XmlPullParserException, IOException{ - parser.next(); // read text - String path = parser.getText(); - parser.next(); // read end tag - - return path; - } - - private String parseJID(XmlPullParser parser) throws XmlPullParserException, IOException{ - parser.next(); // read text - String jid = parser.getText(); - parser.next(); // read end tag - - return jid; - } - - private int parseSideID(XmlPullParser parser) throws XmlPullParserException, IOException{ - parser.next(); // read text - int id = Integer.parseInt(parser.getText()); - parser.next(); // read end tag - - return id; - } - - private Request parseRequest(XmlPullParser parser) throws XmlPullParserException, IOException{ -// // extract current editor for text edit. - int id = 0; - Timestamp timestamp = null; - Operation op = null; - if(parser.getName().equals(RequestPacketExtension.SIDE_ID)){ - id = parseSideID(parser); - parser.next(); - } - - if(parser.getName().equals(RequestPacketExtension.VECTOR_TIME)){ - int local = Integer.parseInt(parser.getAttributeValue(null,"local")); - int remote = Integer.parseInt(parser.getAttributeValue(null,"remote")); - timestamp = new JupiterVectorTime(local,remote); - parser.next(); - parser.next(); - } - -// if(parser.getName().equals(RequestPacketExtension.INSERT_OP)){ -// op = parseInsertOperation(parser); -// return new RequestImpl(id,timestamp,op); -// } -// -// if(parser.getName().equals(RequestPacketExtension.DELETE_OP)){ -// op = parseDeleteOperation(parser); -// return new RequestImpl(id,timestamp,op); -// } -// if(parser.getName().equals(RequestPacketExtension.NO_OP)){ -// op = new NoOperation(); -// return new RequestImpl(id,timestamp,op); -// } - if(parser.getName().equals(RequestPacketExtension.SPLIT_OP)){ - parser.next(); - Operation op1 = parseSingleOperation(parser); - parser.next(); - parser.next(); - Operation op2 = parseSingleOperation(parser); - op = new SplitOperation(op1,op2); - return new RequestImpl(id,timestamp,op); - } - else{ - op = parseSingleOperation(parser); - } - - Request req = new RequestImpl(id,timestamp,op); -// - return req; - } - - private Operation parseSingleOperation(XmlPullParser parser) throws XmlPullParserException, IOException{ - Operation op = null; - if(parser.getName().equals(RequestPacketExtension.INSERT_OP)){ - return parseInsertOperation(parser); - } - if(parser.getName().equals(RequestPacketExtension.DELETE_OP)){ - return parseDeleteOperation(parser); - - } - if(parser.getName().equals(RequestPacketExtension.NO_OP)){ - return new NoOperation(); - } - if(parser.getName().equals(RequestPacketExtension.TIMESTAMP_OP)){ - return new TimestampOperation(); - } - return op; - } - - private Operation parseInsertOperation(XmlPullParser parser) throws XmlPullParserException, IOException{ - Operation op = null; - int pos = Integer.parseInt(parser.getAttributeValue(null, RequestPacketExtension.POSITION)); - int origin = Integer.parseInt(parser.getAttributeValue(null, RequestPacketExtension.ORIGIN)); - - String text = ""; - if (parser.next() == XmlPullParser.TEXT) { - text = parser.getText(); - } - op = new InsertOperation(pos,text,origin); - return op; - } - - private Operation parseDeleteOperation(XmlPullParser parser) throws XmlPullParserException, IOException{ - Operation op = null; - int pos = Integer.parseInt(parser.getAttributeValue(null, RequestPacketExtension.POSITION)); - - String text = ""; - if (parser.next() == XmlPullParser.TEXT) { - text = parser.getText(); - } - op = new DeleteOperation(pos,text); - return op; - } -// -// private IActivity parseTextEditActivity(XmlPullParser parser) throws XmlPullParserException, -// IOException { -// -// // extract current editor for text edit. -// String pathString = parser.getAttributeValue(null, "path"); -// Path path = pathString.equals("null") ? null : new Path(pathString); -// -// int offset = Integer.parseInt(parser.getAttributeValue(null, "offset")); -// int replace = Integer.parseInt(parser.getAttributeValue(null, "replace")); -// -// String text = ""; -// if (parser.next() == XmlPullParser.TEXT) { -// text = parser.getText(); -// } -// -// return new TextEditActivity(offset, text, replace,path); -// } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/RequestPacketExtension.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/RequestPacketExtension.java deleted file mode 100644 index 394e0e7f785c2a20a18a2c1e442a7679879609e9..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/RequestPacketExtension.java +++ /dev/null @@ -1,193 +0,0 @@ -package de.fu_berlin.inf.dpp.net.internal; - -import java.util.List; -import java.util.Vector; - -import org.jivesoftware.smack.packet.PacketExtension; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.DeleteOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.InsertOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.NoOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.SplitOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.TimestampOperation; - - -public class RequestPacketExtension implements PacketExtension{ - public static final String NAMESPACE = "de.fu_berlin.inf.dpp"; - - public static final String ELEMENT = "request"; - - public static final String PATH = "path"; - - public static final String JID = "jid"; - - public static final String SIDE_ID = "sideID"; - - public static final String VECTOR_TIME = "vectortime"; - - public static final String INSERT_OP = "insert"; - - public static final String DELETE_OP = "delete"; - - public static final String NO_OP = "no_op"; - - public static final String SPLIT_OP = "split"; - - public static final String TIMESTAMP_OP = "time"; - - - public static final String LOCAL_TIME = "localtime"; - - public static final String REMOTE_TIME = "remotetime"; - - public static final String POSITION = "position"; - - public static final String ORIGIN = "origin"; - - public static final String TEXT = "text"; - - public static final String LENGTH = "length"; - - - - private Request request; - - public RequestPacketExtension(Request request){ - this.request = request; - } - - public void setRequest(Request request){ - this.request = request; - } - - public Request getRequest(){ - return request; - } - - public String getElementName() { - return ELEMENT; - } - - public String getNamespace() { - return NAMESPACE; - } - - public String toXML() { - if(request == null){ - return ""; - } - - StringBuffer buf = new StringBuffer(); - buf.append("<").append(getElementName()); - buf.append(" xmlns=\"").append(getNamespace()+"\""); - -// buf.append(" xmlns=\"").append(getNamespace()).append("\">"); - - buf.append(">"); - - buf.append(pathToXML()); - buf.append(jidToXML()); - buf.append(sideIDToXML()); - buf.append(vectorTimeToXML()); - buf.append(operationToXML()); - -// buf.append(requestToXML()); - - buf.append("</").append(getElementName()).append(">"); - return buf.toString(); -// return "<request></request>"; - } - - private String pathToXML(){ - return "<"+PATH+">"+ request.getEditorPath()+"</"+PATH+">"; - } - - private String jidToXML(){ - return "<"+JID+">"+ request.getJID()+"</"+JID+">"; - } - - private String sideIDToXML(){ - return "<"+SIDE_ID+">"+ request.getSiteId()+"</"+SIDE_ID+">"; - } - - private String vectorTimeToXML(){ - String xml = ""; - Timestamp timestamp = request.getTimestamp(); - xml += "<"+VECTOR_TIME + " local=\""+timestamp.getComponents()[0]+"\" remote=\""+timestamp.getComponents()[1]+"\""+ "/>"; - return xml; - } - - private String operationToXML(){ - Operation op = request.getOperation(); - String xml = ""; - if(op instanceof InsertOperation){ - xml += insertOp(op); - } - if(op instanceof DeleteOperation){ - xml += deleteOp(op); - } - if(op instanceof NoOperation){ -// NoOperation no = (NoOperation) op; - xml += "<"+NO_OP+ "/>"; - } - if(op instanceof TimestampOperation){ - xml += "<"+TIMESTAMP_OP+ "/>"; - } - if(op instanceof SplitOperation){ - SplitOperation split = (SplitOperation) op; - - List<Operation> ops = new Vector<Operation>(); - ops.add(split.getFirst()); - ops.add(split.getSecond()); - - xml += "<"+SPLIT_OP+">"; - for(Operation o: ops){ - if(o instanceof InsertOperation){ - xml += insertOp(o); - } - if(o instanceof DeleteOperation){ - xml += deleteOp(o); - } - if( o instanceof NoOperation){ - xml += "<"+NO_OP+ "/>"; - } - } - xml += "</"+SPLIT_OP+">"; - } - return xml; - } - - private String insertOp(Operation op){ - String xml = ""; - InsertOperation ins = (InsertOperation) op; - xml += "<"+INSERT_OP+ " "+POSITION+"=\""+ins.getPosition()+"\""+ " "+ORIGIN+"=\""+ins.getOrigin()+"\""+ ">"; - xml += "<![CDATA[" + ins.getText() + "]]>"; - xml += "</"+INSERT_OP+">"; - return xml; - } - - private String deleteOp(Operation op){ - String xml = ""; - DeleteOperation del = (DeleteOperation) op; - xml += "<"+DELETE_OP+ " "+POSITION+"=\""+del.getPosition()+"\""+">"; - xml += "<![CDATA[" + del.getText() + "]]>"; - xml += "</"+DELETE_OP+">"; - return xml; - } - - private String requestToXML(){ - return "<request " -// + "path=\"" + request.getEditorPath() + "\">" -// + "path=\"" + request.getEditorPath() + "\" " +"offset=\"" + textEditActivity.offset + "\" " + "replace=\"" -// + textEditActivity.replace + "\">" + "<![CDATA[" + textEditActivity.text + "]]>" - - + "</request>"; -// return "<request " + "path=\"" + request.getEditorPath() + "\" " +"offset=\"" + textEditActivity.offset + "\" " + "replace=\"" -// + textEditActivity.replace + "\">" + "<![CDATA[" + textEditActivity.text + "]]>" -// + "</request>"; - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/RosterListenerImpl.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/RosterListenerImpl.java deleted file mode 100644 index 4237e5e58072e5401ad1c3bc1510ae29bf6c7208..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/RosterListenerImpl.java +++ /dev/null @@ -1,179 +0,0 @@ -package de.fu_berlin.inf.dpp.net.internal; - -import java.util.Collection; -import java.util.Iterator; - -import org.apache.log4j.Logger; -import org.jivesoftware.smack.PacketListener; -import org.jivesoftware.smack.RosterEntry; -import org.jivesoftware.smack.RosterListener; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.packet.Packet; -import org.jivesoftware.smack.packet.Presence; -import org.jivesoftware.smack.packet.RosterPacket; - -import de.fu_berlin.inf.dpp.ui.IRosterTree; - - -public class RosterListenerImpl implements RosterListener, PacketListener{ - - private static Logger logger = Logger.getLogger(RosterListenerImpl.class); - - private XMPPConnection connection; - - private IRosterTree rtree; - - public RosterListenerImpl(XMPPConnection conn, IRosterTree rtree){ - this.connection = conn; - this.rtree = rtree; - } - - - public void entriesAdded(Collection<String> addresses) { - logger.debug("entriesAdded called."); - for (Iterator<String> it = addresses.iterator(); it.hasNext();) { - String address = it.next(); -// RosterEntry entry = roster.getEntry(address); - RosterEntry entry = connection.getRoster().getEntry(address); - // When the entry is only from the other user, then send a - // subscription request - try { - if (entry != null - && entry.getType() == RosterPacket.ItemType.none) { - - logger.debug("added with type none " + connection.getUser()); - - } - if (entry != null - && entry.getType() == RosterPacket.ItemType.from) { - logger.debug("added with type from " + connection.getUser()); - - /* called create entry method to complete the registration process. (third part)*/ - connection.getRoster().createEntry(entry.getUser(), entry.getUser(), - new String[0]); - } - } catch (XMPPException e) { - logger.error("error while entriesAdded is called.",e); - } - } - - rtree.refreshRosterTree(true); - - } - - - public void entriesDeleted(Collection<String> addresses) { - logger.debug("entry delete"); - - rtree.refreshRosterTree(false); - } - - - public void entriesUpdated(Collection<String> addresses) { - logger.debug("entries update " + connection.getUser()); - for (String address : addresses) { - RosterEntry entry = connection.getRoster().getEntry(address); - if (entry.getType().equals(RosterPacket.ItemType.to)) { - logger.debug("Type to called for : "+entry.getUser()); - } - if (entry.getType().equals(RosterPacket.ItemType.from)) { - logger.debug("Type from called for : "+entry.getUser()); - try { - - connection.getRoster().createEntry(entry.getUser(), - entry.getUser(), new String[0]); - - } catch (XMPPException e) { - logger.debug(e.getStackTrace().toString()); - } - } - - if (entry.getStatus() != null - && entry.getStatus().equals( - RosterPacket.ItemStatus.SUBSCRIPTION_PENDING)) { - logger.debug("subscripe"); - - if (entry.getUser().equals(connection.getUser())) { - Presence presence = new Presence(Presence.Type.unsubscribed); - presence.setTo(entry.getUser()); - presence.setFrom(connection.getUser()); - - connection.sendPacket(presence); - } else { - Presence presence = new Presence(Presence.Type.subscribed); - presence.setTo(entry.getUser()); - presence.setFrom(connection.getUser()); - - connection.sendPacket(presence); - } - - } - - } - - rtree.refreshRosterTree(false); - } - - public void presenceChanged(Presence presence) { - - logger.debug("presence changed user" + connection.getUser() - + " status :" + presence.getType() + " from: " - + presence.getFrom()); - - rtree.refreshRosterTree(true); - } - - public void processPacket(Packet packet) { - -// logger.info("Packet called. " + packet.getFrom()); - - - if (!packet.getFrom().equals(connection.getUser())) { - /* - * 1. überprüfen ob es eine subscribe anfrage ist 2. überprüfen, ob - * user im in liste ist. 3. hinzufügen des accounts. - */ - if (packet instanceof Presence) { - - Presence p = (Presence) packet; - - /* this states handled by roster listener. */ - if (p.getType().equals(Presence.Type.unavailable) - || p.getType().equals(Presence.Type.available)) { - logger.debug("Presence " + p.getFrom() + " " + p.getType()); - return; - } - - if (p.getType() == Presence.Type.subscribed) { - logger.debug("subcriped form " + p.getFrom()); - } - - /* Anfrage für eine Kontakthinzufügung. */ - if (p.getType().equals(Presence.Type.subscribe)) { - - RosterEntry e = connection.getRoster().getEntry(packet.getFrom()); - logger.debug("subscribe from " + p.getFrom()); - - - if (e == null) { - try { - /* create appropriate entry for request. */ - connection.getRoster().createEntry(packet.getFrom(), packet.getFrom(), null); - - } catch (XMPPException e1) { - logger.error(e1); - } - } - - } - if (packet instanceof RosterPacket) { - RosterPacket rp = (RosterPacket) packet; - logger.debug("roster packet with type "+rp.getType()); - } - } - } - - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/SkypeIQ.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/SkypeIQ.java deleted file mode 100644 index 11373013972ad2e375942cbd02c4617e255a0bd2..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/SkypeIQ.java +++ /dev/null @@ -1,28 +0,0 @@ -package de.fu_berlin.inf.dpp.net.internal; - -import org.jivesoftware.smack.packet.IQ; - -public class SkypeIQ extends IQ { - private String name; - - public void setName(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - @Override - public String getChildElementXML() { - StringBuffer buf = new StringBuffer(); - buf.append("<query xmlns=\"jabber:iq:skype\">"); - - if (name != null) { - buf.append("<name>").append(name).append("</name>"); - } - - buf.append("</query>"); - return buf.toString(); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/XMPPChatTransmitter.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/XMPPChatTransmitter.java deleted file mode 100644 index f31c4f29b05162c780ac4c2ce39ea150d81d4846..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/XMPPChatTransmitter.java +++ /dev/null @@ -1,1833 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.net.internal; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import org.apache.log4j.Logger; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.preference.IPreferenceStore; -import org.jivesoftware.smack.Chat; -import org.jivesoftware.smack.ChatManager; -import org.jivesoftware.smack.MessageListener; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.packet.DefaultPacketExtension; -import org.jivesoftware.smack.packet.Message; -import org.jivesoftware.smack.packet.Packet; -import org.jivesoftware.smack.packet.PacketExtension; -import org.jivesoftware.smackx.filetransfer.FileTransferListener; -import org.jivesoftware.smackx.filetransfer.FileTransferManager; -import org.jivesoftware.smackx.filetransfer.FileTransferNegotiator; -import org.jivesoftware.smackx.filetransfer.FileTransferRequest; -import org.jivesoftware.smackx.filetransfer.IBBTransferNegotiator; -import org.jivesoftware.smackx.filetransfer.IncomingFileTransfer; -import org.jivesoftware.smackx.filetransfer.OutgoingFileTransfer; -import org.xmlpull.v1.XmlPullParserException; - -import de.fu_berlin.inf.dpp.FileList; -import de.fu_berlin.inf.dpp.PreferenceConstants; -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.activities.FileActivity; -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess.TransferMode; -import de.fu_berlin.inf.dpp.net.IFileTransferCallback; -import de.fu_berlin.inf.dpp.net.IReceiver; -import de.fu_berlin.inf.dpp.net.ITransmitter; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.net.TimedActivity; -import de.fu_berlin.inf.dpp.net.internal.JingleFileTransferData.FileTransferType; -import de.fu_berlin.inf.dpp.net.jingle.IJingleFileTransferListener; -import de.fu_berlin.inf.dpp.net.jingle.JingleFileTransferManager; -import de.fu_berlin.inf.dpp.net.jingle.JingleFileTransferProcessMonitor; -import de.fu_berlin.inf.dpp.net.jingle.JingleSessionException; -import de.fu_berlin.inf.dpp.net.jingle.JingleFileTransferManager.JingleConnectionState; -import de.fu_berlin.inf.dpp.project.ISessionManager; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.ui.ErrorMessageDialog; - -/** - * The one ITransmitter implementation which uses Smack Chat objects. - * - * @author rdjemili - */ -public class XMPPChatTransmitter implements ITransmitter, IReceiver, - MessageListener, FileTransferListener, IJingleFileTransferListener { - private static Logger log = Logger.getLogger(XMPPChatTransmitter.class - .getName()); - - private static final int MAX_PARALLEL_SENDS = 10; - private static final int MAX_TRANSFER_RETRIES = 5; - private static final int FORCEDPART_OFFLINEUSER_AFTERSECS = 60; - - private static boolean jingle = true; - private boolean JingleError = false; - private JingleFileTransferManager jingleManager; - private JingleFileTransferProcessMonitor monitor; - - /* - * the following string descriptions are used to differentiate between - * transfers that are for invitations and transfers that are an activity for - * the current project. - */ - private static final String RESOURCE_TRANSFER_DESCRIPTION = "resourceAddActivity"; - - private static final String FILELIST_TRANSFER_DESCRIPTION = "filelist"; - - private static final String PROJECT_ARCHIVE_DESCRIPTION = "projectArchiveFile"; - - private XMPPConnection connection; - - /* - * old version of chatmanager. TODO: exchange this with private manager. - */ - private ChatManager chatmanager; - - private MultiUserChatManager mucmanager; - - private Map<JID, Chat> chats = new HashMap<JID, Chat>(); - - private FileTransferManager fileTransferManager; - - // TODO use ListenerList instead - private List<IInvitationProcess> processes = new CopyOnWriteArrayList<IInvitationProcess>(); - - private List<FileTransferData> fileTransferQueue = new LinkedList<FileTransferData>(); - private List<MessageTransfer> messageTransferQueue = new LinkedList<MessageTransfer>(); - private Map<String, IncomingFile> incomingFiles = new HashMap<String, IncomingFile>(); - private int runningFileTransfers = 0; - - private boolean m_bFileTransferByChat = false; // to switch to - - // chat-filetransfer as - // fallback - - /** - * A simple struct that is used to queue file transfers. - */ - public class FileTransferData { - - public FileTransferType type; - public JID recipient; - public IPath path; - public int timestamp; - public IFileTransferCallback callback; - public int retries = 0; - public byte[] content; - public long filesize; - public IProject project; - - // /* for testing only */ - // public File file; - // public String filePath; - } - - /** - * A simple struct that is used to manage incoming chunked files via - * chat-file transfer - */ - private class IncomingFile { - String name; - int receivedChunks; - int chunkCount; - List<String> messageBuffer; - - IncomingFile() { - messageBuffer = new LinkedList<String>(); - } - - boolean isComplete() { - return (receivedChunks == chunkCount); - } - } - - /** - * A simple struct that is used to queue message transfers. - */ - private class MessageTransfer { - public JID receipient; - public PacketExtension packetextension; - } - - public XMPPChatTransmitter(XMPPConnection connection) { - setXMPPConnection(connection); - } - - public void setXMPPConnection(XMPPConnection connection) { - this.connection = connection; - this.chatmanager = connection.getChatManager(); - fileTransferManager = new FileTransferManager(connection); - // TODO: aktuell noch nicht angesprochen - fileTransferManager.addFileTransferListener(this); - - chats.clear(); - - setProxyPort(connection); - - if (jingle) { - /* try to connect with jingle */ - jingleManager = new JingleFileTransferManager(connection, this); - } - } - - public void addInvitationProcess(IInvitationProcess process) { - processes.add(process); - } - - public void removeInvitationProcess(IInvitationProcess process) { - processes.remove(process); - /* terminate jingle session for states: done, cancel and joined. */ - jingleManager.terminateJingleSession(process.getPeer()); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.ITransmitter - */ - public void sendCancelInvitationMessage(JID user, String errorMsg) { - sendMessage(user, PacketExtensions - .createCancelInviteExtension(errorMsg)); - /* terminate jingle session. */ - jingleManager.terminateJingleSession(user); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ITransmitter - */ - public void sendRequestForFileListMessage(JID user) { - - sendMessage(user, PacketExtensions.createRequestForFileListExtension()); - - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ITransmitter - */ - public void sendRequestForActivity(ISharedProject sharedProject, - int timestamp, boolean andup) { - - // log.info("Requesting old activity (timestamp=" + timestamp + ", " - // + andup + ") from all..."); - // - // sendMessageToAll(sharedProject, PacketExtensions - // .createRequestForActivityExtension(timestamp, andup)); - - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ITransmitter - */ - public void sendInviteMessage(ISharedProject sharedProject, JID guest, - String description) { - sendMessage(guest, PacketExtensions.createInviteExtension(sharedProject - .getProject().getName(), description)); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ITransmitter - */ - public void sendJoinMessage(ISharedProject sharedProject) { - try { - /* sleep process for 500 millis to ensure invitation state process. */ - Thread.sleep(1000); - } catch (InterruptedException e) { - log.error(e); - } - sendMessageToAll(sharedProject, PacketExtensions.createJoinExtension()); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ITransmitter - */ - public void sendLeaveMessage(ISharedProject sharedProject) { - sendMessageToAll(sharedProject, PacketExtensions.createLeaveExtension()); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ITransmitter - */ - public void sendActivities(ISharedProject sharedProject, - List<TimedActivity> timedActivities) { - - // timer that calls sendActivities is called before setting chat - - for (TimedActivity timedActivity : timedActivities) { - IActivity activity = timedActivity.getActivity(); - - if (activity instanceof FileActivity) { - FileActivity fileAdd = (FileActivity) activity; - - /* send file checksum error message to exclusive recipient */ - if (fileAdd.getType().equals(FileActivity.Type.Error)) { - sendFileChecksumError(fileAdd.getRecipient(), fileAdd - .getPath()); - } - /* send file to solve checksum error to single recipient */ - if (fileAdd.getType().equals(FileActivity.Type.Created) - && fileAdd.getRecipient() != null) { - int time = timedActivity.getTimestamp(); - sendFile(fileAdd.getRecipient(), - sharedProject.getProject(), fileAdd.getPath(), - time, null); - return; - } - - if (fileAdd.getType().equals(FileActivity.Type.Created)) { - JID myJID = Saros.getDefault().getMyJID(); - - for (User participant : sharedProject.getParticipants()) { - JID jid = participant.getJid(); - if (jid.equals(myJID)) - continue; - - // TODO use callback - int time = timedActivity.getTimestamp(); - /* send file with other send method. */ - sendFile(jid, sharedProject.getProject(), fileAdd - .getPath(), time, null); - } - - // TODO remove activity and let this be handled by - // ActivitiesProvider instead - - // don't remove file activity so that it still bumps the - // time stamp when being received - } - } else { - sharedProject.getSequencer().getActivityHistory().add( - timedActivity); - - // TODO: removed very old entries - } - } - - log.info("Sent activities: " + timedActivities); - - /* send activities with muc chat messages. */ - if (mucmanager != null && mucmanager.isConnected()) { - mucmanager.sendActivities(sharedProject, timedActivities); - } else { - /* - * if no connection with muc room, send activities with private - * message - */ - if (timedActivities != null) { - sendMessageToAll(sharedProject, new ActivitiesPacketExtension( - timedActivities)); - } - } - - } - - private void sendFileListWithJingle(JID recipient, String fileListContent) { - JingleFileTransferProcessMonitor monitor = new JingleFileTransferProcessMonitor(); - /* create file transfer. */ - JingleFileTransferData data = new JingleFileTransferData(); - - /* only for testing. */ - data.file_list_content = fileListContent; - data.type = FileTransferType.FILELIST_TRANSFER; - data.recipient = recipient; - data.sender = new JID(connection.getUser()); - data.file_project_path = FileTransferType.FILELIST_TRANSFER.toString(); - - jingleManager.createOutgoingJingleFileTransfer(recipient, - new JingleFileTransferData[] { data }, monitor); - - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ITransmitter - */ - public void sendFileList(JID recipient, FileList fileList) - throws XMPPException { - - String xml = fileList.toXML(); - String to = recipient.toString(); - - if (getFileTransferModeViaChat()) { - - if (sendChatTransfer(FILELIST_TRANSFER_DESCRIPTION, "", xml - .getBytes(), recipient)) - log.debug("Sent file list via ChatTransfer"); - else - log.warn("Error sending file list via ChatTransfer"); - } - - /* send with jingle file transfer */ - if (jingle - && (jingleManager.getState(recipient) != JingleConnectionState.ERROR) - && !JingleError) { - - sendFileListWithJingle(recipient, xml); - - } else { - /* send file with IBB File Transfer */ - - log.debug("Establishing file list transfer"); - - /* Write xml datas to temp file for transfering. */ - try { - File newfile = new File(FILELIST_TRANSFER_DESCRIPTION + "." - + new JID(connection.getUser()).getName()); - if (newfile.exists()) { - newfile.delete(); - } - log.debug("file : " + newfile.getAbsolutePath()); - - FileWriter writer = new FileWriter( - FILELIST_TRANSFER_DESCRIPTION + "." - + new JID(connection.getUser()).getName()); - writer.append(xml); - writer.close(); - - // } catch (IOException e1) { - // // TODO Auto-generated catch block - // e1.printStackTrace(); - // } - - // while (true) { - - // try { - OutgoingFileTransfer - .setResponseTimeout(MAX_TRANSFER_RETRIES * 1000); - OutgoingFileTransfer transfer = fileTransferManager - .createOutgoingFileTransfer(to); - - // OutputStream out = transfer.sendFile( - // FILELIST_TRANSFER_DESCRIPTION, xml.getBytes().length, - // FILELIST_TRANSFER_DESCRIPTION); - // - // if (out != null) { - // if (attempts-- > 0) - // continue; - // throw new XMPPException(transfer.getException()); - // } - // - // BufferedWriter writer = new BufferedWriter(new - // PrintWriter( - // out)); - // writer.write(xml); - // writer.flush(); - // writer.close(); - // } - - log.info("Sending file list"); - FileTransferProcessMonitor monitor = new FileTransferProcessMonitor( - transfer); - transfer.sendFile(newfile, FILELIST_TRANSFER_DESCRIPTION); - - /* wait for complete transfer. */ - while (monitor.isAlive() && monitor.isRunning()) { - Thread.sleep(500); - } - monitor.closeMonitor(true); - - // int time = 0; - // while (!transfer.isDone()) { - // - // if (transfer - // .getStatus() - // .equals( - // org.jivesoftware.smackx.filetransfer.FileTransfer.Status.error)) - // { - // log.error("ERROR!!! " + transfer.getError()); - // } else { - // log.debug("Status : " + transfer.getStatus()+" Progress : - // " + - // transfer.getProgress()); - // } - // try { - // /* check response time out. */ - // if (time < OutgoingFileTransfer.getResponseTimeout()) { - // Thread.sleep(100); - // time += 100; - // } - // else{ - // log.error("File transfer response error."); - // throw new XMPPException("File transfer response error."); - // } - // } catch (InterruptedException e) { - // // TODO Auto-generated catch block - // e.printStackTrace(); - // } - // } - - /* - * TODO: es kommt momentan zu einer file not found exception, - * obwohl die Datei übertragen wurde. - */ - // if (!transfer - // .getStatus() - // .equals( - // org.jivesoftware.smackx.filetransfer.FileTransfer.Status.complete)) - // { - // log.warn("file list transfer incomplete!"); - // throw new XMPPException("file list transfer incomplete"); - // } - /* delete temp file. */ - // File list = new File(FILELIST_TRANSFER_DESCRIPTION); - if (newfile.exists()) { - newfile.delete(); - } - log.info("File list sent"); - - // break; - - } catch (IOException e) { - // if (attempts-- > 0) - // continue; - - m_bFileTransferByChat = true; - sendChatTransfer(FILELIST_TRANSFER_DESCRIPTION, "", xml - .getBytes(), recipient); - // TODO errorhandling - - log - .info("File list sent via ChatTransfer. File transfer mode is set to ChatTransfer."); - } - // } - catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - // end of jingle transfer - } - - } - - /** - * Sends a data buffer to a recipient using chat messages. The buffer is - * transmitted Base64 encoded and split into blocks of size MAX_MSG_LENGTH. - * - * @param name - * name of the data buffer. e.g. the filename of the transmitted - * file - * @param desc - * description String of the transfer. e.g. encoded timestamp for - * file activity - * @param data - * a byte buffer to be transmitted. it will be base64 encoded - * @param recipient - * JID of the user to send this data to - * - * @return <code>true</code> if the message was send successfully - */ - boolean sendChatTransfer(String name, String desc, byte[] data, - JID recipient) { - - final int maxMsgLen = Saros.getDefault().getPreferenceStore().getInt( - PreferenceConstants.CHATFILETRANSFER_CHUNKSIZE); - - // Convert byte array to base64 string - String data64 = new sun.misc.BASE64Encoder().encode(data); - - // send large data sets in several messages - int tosend = data64.length(); - int pcount = (tosend / maxMsgLen) + ((tosend % maxMsgLen == 0) ? 0 : 1); - int start = 0; - try { - for (int i = 1; i <= pcount; i++) { - int psize = Math.min(tosend, maxMsgLen); - int end = start + psize; - - PacketExtension extension = PacketExtensions - .createDataTransferExtension(name, desc, i, pcount, - data64.substring(start, end)); - - sendMessage(recipient, extension); - - start = end; - tosend -= psize; - - } - } catch (Exception e) { - e.printStackTrace(); - return false; - } - return true; - } - - /** - * Receives a data buffer sent by a chat message. The data will be decoded - * from base64 encoding. Splitted transfer will be buffered until all chunks - * are received. Then the file will be reconstructed and processed as a - * whole. - * - * @param message - * Message containing the data as extension. - * - * @return <code>true</code> if the message was handled successfully. - */ - boolean receiveChatTransfer(Message message) { - DefaultPacketExtension dt = PacketExtensions - .getDataTransferExtension(message); - String sName = dt.getValue(PacketExtensions.DT_NAME); - String sData = dt.getValue(PacketExtensions.DT_DATA); - - String sSplit = dt.getValue(PacketExtensions.DT_SPLIT); - try { - // is this a multipart transfer? - if (sSplit != null && sSplit.equals("1/1") == false) { - // parse split information (index and chunk count) - int i = sSplit.indexOf('/'); - int cur = Integer.parseInt(sSplit.substring(0, i)); - int max = Integer.parseInt(sSplit.substring(i + 1)); - - log.debug("Received chunk " + cur + " of " + max + " of file " - + sName); - - // check for previous chunks - IncomingFile ifile = incomingFiles.get(sName); - if (ifile == null) { - // this is the first received chunk->create incoming file - // object - ifile = new IncomingFile(); - ifile.receivedChunks++; - ifile.chunkCount = max; - ifile.name = sName; - for (i = 0; i < max; i++) - ifile.messageBuffer.add(null); - ifile.messageBuffer.set(cur - 1, sData); - incomingFiles.put(sName, ifile); - return true; - } else { - // this is a following chunk - ifile.receivedChunks++; - ifile.messageBuffer.set(cur - 1, sData); - - if (ifile.isComplete() == false) - return true; - - // join the buffers to restore the file from chunks - sData = ""; - for (i = 0; i < max; i++) - sData += ifile.messageBuffer.get(i); - incomingFiles.remove(ifile); - } - } - } catch (Exception e) { - e.printStackTrace(); - return false; - - } - - byte[] dataOrg = null; - try { - dataOrg = new sun.misc.BASE64Decoder().decodeBuffer(sData); - } catch (IOException e) { - e.printStackTrace(); - return false; - } - - // File list received - if (sName.equals(FILELIST_TRANSFER_DESCRIPTION)) { - FileList fileList = null; - IInvitationProcess myProcess = null; - try { - JID fromJID = new JID(message.getFrom()); - for (IInvitationProcess process : processes) { - if (process.getPeer().equals(fromJID)) { - myProcess = process; - fileList = new FileList(new String(dataOrg)); - process.fileListReceived(fromJID, fileList); - } - } - log.info("Received file list via ChatTransfer"); - } catch (Exception e) { - if (myProcess != null) - myProcess.cancel("Error receiving file list", false); - } - - } else { - // receiving file (resource) - - try { - - JID from = new JID(message.getFrom()); - Path path = new Path(sName); - - ByteArrayInputStream in = new ByteArrayInputStream(dataOrg); - - log.debug("Receiving resource from " + from.toString() + ": " - + sName + " (ChatTransfer)"); - - boolean handledByInvitation = false; - for (IInvitationProcess process : processes) { - if (process.getPeer().equals(from)) { - process.resourceReceived(from, path, in); - handledByInvitation = true; - } - } - - if (!handledByInvitation) { - - if (Saros.getDefault().getSessionManager() - .getSharedProject() == null) { - // receiving resource without a running session? not - // accepted - return false; - } - - FileActivity activity = new FileActivity( - FileActivity.Type.Created, path, in); - - int time; - String description = dt.getValue(PacketExtensions.DT_DESC); - try { - time = Integer.parseInt(description - .substring(RESOURCE_TRANSFER_DESCRIPTION - .length() + 1)); - } catch (Exception e) { - Saros.log("Could not parse time from description: " - + description, e); - time = 0; // HACK - } - - TimedActivity timedActivity = new TimedActivity(activity, - time); - - ISessionManager sm = Saros.getDefault().getSessionManager(); - sm.getSharedProject().getSequencer().exec(timedActivity); - } - - log.info("Received resource " + sName); - - } catch (Exception e) { - log.warn("Failed to receive " + sName, e); - } - } - - return true; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.ITransmitter - */ - public void sendFile(JID to, IProject project, IPath path, - IFileTransferCallback callback) { - sendFile(to, project, path, -1, callback); - } - - /** - * Reads a files content into a buffer. - * - * @param transfer - * Object containing file path and a buffer (among other) to read - * from and to. - * - * @return <code>true</code> if the file was read successfully - */ - boolean readFile(FileTransferData transfer) { - // SessionManager sm = Saros.getDefault().getSessionManager(); - // IProject project = sm.getSharedProject().getProject(); - - File f = new File(transfer.project.getFile(transfer.path).getLocation() - .toOSString()); - transfer.filesize = f.length(); - transfer.content = new byte[(int) transfer.filesize]; - - try { - InputStream in = transfer.project.getFile(transfer.path) - .getContents(); - in.read(transfer.content, 0, (int) transfer.filesize); - } catch (Exception e) { - e.printStackTrace(); - transfer.content = null; - return false; - } - return true; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.ITransmitter - */ - public void sendFile(JID to, IProject project, IPath path, int timestamp, - IFileTransferCallback callback) { - - FileTransferData transfer = new FileTransferData(); - transfer.recipient = to; - transfer.path = path; - transfer.timestamp = timestamp; - transfer.callback = callback; - transfer.project = project; - transfer.filesize = project.getFile(path).getLocation().toFile() - .length(); - - // if transfer will be delayed, we need to buffer the file - // to not send modified versions later - if (!connection.isConnected()) - readFile(transfer); - else - transfer.content = null; - - fileTransferQueue.add(transfer); - sendNextFile(); - } - - /* - * (non-Javadoc) - * - * @see - * de.fu_berlin.inf.dpp.net.ITransmitter#sendProjectArchive(de.fu_berlin - * .inf.dpp.net.JID, org.eclipse.core.resources.IProject, java.io.File, - * de.fu_berlin.inf.dpp.net.IFileTransferCallback) - */ - public void sendProjectArchive(JID recipient, IProject project, - File archive, IFileTransferCallback callback) { - OutgoingFileTransfer.setResponseTimeout(MAX_TRANSFER_RETRIES * 1000); - OutgoingFileTransfer transfer = fileTransferManager - .createOutgoingFileTransfer(recipient.toString()); - - try { - transfer.sendFile(archive, PROJECT_ARCHIVE_DESCRIPTION); - - FileTransferProcessMonitor monitor = new FileTransferProcessMonitor( - transfer, callback); - /* wait for complete transfer. */ - while (monitor.isAlive() && monitor.isRunning()) { - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - monitor.closeMonitor(true); - - if (transfer - .getStatus() - .equals( - org.jivesoftware.smackx.filetransfer.FileTransfer.Status.complete)) { - log.debug("transfer complete"); - callback.fileSent(new Path(archive.getName())); - } - - /* delete temp archive file. */ - archive.delete(); - - } catch (Exception e) { - - log.warn("Failed to send archive file", e); - if (callback != null) - callback.fileTransferFailed(null, e); - } - } - - private void sendNextFile() { - if (fileTransferQueue.size() == 0 - || runningFileTransfers > MAX_PARALLEL_SENDS - // || Saros.getDefault().getConnectionState() != - // Saros.ConnectionState.CONNECTED - ) { - log.debug("non file to send in queue."); - return; - } - - final FileTransferData transfer = fileTransferQueue.remove(0); - - new Thread(new Runnable() { - - /* - * (non-Javadoc) - * - * @see java.lang.Runnable#run() - */ - public void run() { - try { - runningFileTransfers++; - log.debug("try to send file " + transfer.path); - transferFile(transfer); - - } catch (Exception e) { - if (transfer.retries >= MAX_TRANSFER_RETRIES) { - log.warn("Failed to send " + transfer.path, e); - if (transfer.callback != null) - transfer.callback.fileTransferFailed(transfer.path, - e); - - } else { - transfer.retries++; - fileTransferQueue.add(transfer); - } - - } finally { - runningFileTransfers--; - sendNextFile(); - } - } - - }).start(); - } - - public void sendUserListTo(JID to, List<User> participants) { - log.debug("Sending user list to " + to.toString()); - - sendMessage(to, PacketExtensions.createUserListExtension(participants)); - } - - /* - * (non-Javadoc) - * - * @see - * de.fu_berlin.inf.dpp.net.ITransmitter#sendFileChecksumError(de.fu_berlin - * .inf.dpp.net.JID, org.eclipse.core.runtime.IPath) - */ - public void sendFileChecksumError(JID to, IPath path) { - log.debug("Sending checksum error message to " + to + " of file " - + path.lastSegment()); - sendMessage(to, PacketExtensions.createChecksumErrorExtension(path)); - } - - /* - * (non-Javadoc) - * - * @see - * de.fu_berlin.inf.dpp.net.ITransmitter#sendJupiterTransformationError( - * de.fu_berlin.inf.dpp.net.JID, org.eclipse.core.runtime.IPath) - */ - public void sendJupiterTransformationError(JID to, IPath path) { - log.debug("Sending jupiter transformation error message to " + to - + " of file " + path.lastSegment()); - sendMessage(to, PacketExtensions.createJupiterErrorExtension(path)); - } - - public void sendRemainingFiles() { - - if (fileTransferQueue.size() > 0) - sendNextFile(); - } - - public void sendRemainingMessages() { - - try { - while (messageTransferQueue.size() > 0) { - final MessageTransfer pex = messageTransferQueue.remove(0); - - Chat chat = getChat(pex.receipient); - Message message; - // TODO: Änderung für Smack 3 - message = new Message(); - // message = chat.createMessage(); - message.addExtension(pex.packetextension); - chat.sendMessage(message); - log.info("Resending message"); - } - } catch (Exception e) { - Saros.getDefault().getLog().log( - new Status(IStatus.ERROR, Saros.SAROS, IStatus.ERROR, - "Could not send message", e)); - } - } - - public boolean resendActivity(JID jid, int timestamp, boolean andup) { - - boolean sent = false; - - ISharedProject project = Saros.getDefault().getSessionManager() - .getSharedProject(); - - try { - List<TimedActivity> tempActivities = new LinkedList<TimedActivity>(); - for (TimedActivity tact : project.getSequencer() - .getActivityHistory()) { - - if ((andup == false && tact.getTimestamp() != timestamp) - || (andup == true && tact.getTimestamp() < timestamp)) - continue; - - tempActivities.add(tact); - sent = true; - - if (andup == false) - break; - } - - if (sent) { - PacketExtension extension = new ActivitiesPacketExtension( - tempActivities); - sendMessage(jid, extension); - } - - } catch (Exception e) { - Saros.getDefault().getLog().log( - new Status(IStatus.ERROR, Saros.SAROS, IStatus.ERROR, - "Could not resend message", e)); - } - - return sent; - } - - public void processMessage(Chat chat, Message message) { - // TODO: new method für smack 3 - // log.debug("incomming message : " + message.getBody()); - // processPacket(message); - - } - - public void processPacket(Chat chat, Packet packet) { - - } - - /* - * (non-Javadoc) - * - * @see - * de.fu_berlin.inf.dpp.net.ITransmitter#sendActivitiyTo(de.fu_berlin.inf - * .dpp.project.ISharedProject, java.util.List, - * de.fu_berlin.inf.dpp.net.JID) - */ - public void sendJupiterRequest(ISharedProject sharedProject, - Request request, JID jid) { - log.info("send request to : " + jid + " request: " + request); - sendMessage(jid, new RequestPacketExtension(request)); - } - - public void processRequest(Packet packet) { - Message message = (Message) packet; - - RequestPacketExtension packetExtension = PacketExtensions - .getJupiterRequestExtension(message); - - if (packetExtension != null) { - ISharedProject project = Saros.getDefault().getSessionManager() - .getSharedProject(); - log.info("Received request : " - + packetExtension.getRequest().toString()); - project.getSequencer().receiveRequest(packetExtension.getRequest()); - - } else { - log.error("Failure in request packet extension."); - } - - } - - // TODO replace dependencies by more generic listener interfaces - /* - * (non-Javadoc) - * - * @see org.jivesoftware.smack.PacketListener - */ - public void processPacket(Packet packet) { - Message message = (Message) packet; - - JID fromJID = new JID(message.getFrom()); - // Change the input method to get the right chats - putIncomingChat(fromJID, message.getThread()); - ISharedProject project = Saros.getDefault().getSessionManager() - .getSharedProject(); - - ActivitiesPacketExtension activitiesPacket = PacketExtensions - .getActvitiesExtension(message); - - boolean isProjectParticipant = false; - if (project != null) - isProjectParticipant = (project.getParticipant(fromJID) != null); - - if (activitiesPacket != null) { - List<TimedActivity> timedActivities = activitiesPacket - .getActivities(); - - log.debug("Received activities from " + fromJID.toString() + ": " - + timedActivities); - - if (!isProjectParticipant) { - log.info("user not member!"); - return; - } - - for (TimedActivity timedActivity : timedActivities) { - - IActivity activity = timedActivity.getActivity(); - activity.setSource(fromJID.toString()); - - // if (activity instanceof TextSelectionActivity) { - // ((TextSelectionActivity) activity).setSource(fromJID - // .toString()); - // } - // if (activity instanceof TextEditActivity) { - // ((TextEditActivity) activity).setSource(fromJID.toString()); - // } - - /* - * incoming fileActivities that add files are only used as - * placeholder to bump the timestamp. the real fileActivity will - * be processed by using a file transfer. - */ - if (!(activity instanceof FileActivity) - || !((FileActivity) activity).getType().equals( - FileActivity.Type.Created)) { - - // TODO: Empfang der Aktivitäten und weiterleitung an den - // sequencer - project.getSequencer().exec(timedActivity); - - } - } - } - - if (PacketExtensions.getJoinExtension(message) != null) { - - boolean iAmInviter = false; - - for (IInvitationProcess process : processes) { - if (process.getPeer().equals(fromJID)) { - process.joinReceived(fromJID); - iAmInviter = true; - } - } - if (!iAmInviter && project != null) - project.addUser(new User(fromJID)); // a new user joined this - // session - - } - - else if (PacketExtensions.getLeaveExtension(message) != null) { - if (project != null) - project.removeUser(new User(fromJID)); // HACK - } - - else if (PacketExtensions.getRequestActivityExtension(message) != null - && isProjectParticipant) { - DefaultPacketExtension rae = PacketExtensions - .getRequestActivityExtension(message); - String sID = rae.getValue("ID"); - String sIDandup = rae.getValue("ANDUP"); - - int ts = -1; - if (sID != null) { - ts = (new Integer(sID)).intValue(); - // get that activity from history (if it was mine) and send it - boolean sent = resendActivity(fromJID, ts, (sIDandup != null)); - - String info = "Received Activity request for timestamp=" + ts - + "."; - if (sIDandup != null) - info += " (andup) "; - if (sent) - info += " I sent response."; - else - info += " (not for me)"; - - log.info(info); - } - } - - else if (PacketExtensions.getDataTransferExtension(message) != null) { - receiveChatTransfer(message); - } - - /* invitee request for project file list (state.INVITATION_SEND */ - else if (PacketExtensions.getRequestExtension(message) != null) { - for (IInvitationProcess process : processes) { - if (process.getPeer().equals(fromJID)) - process.invitationAccepted(fromJID); - } - } - - else if (PacketExtensions.getUserlistExtension(message) != null) { - DefaultPacketExtension userlistExtension = PacketExtensions - .getUserlistExtension(message); - - // My inviter sent a list of all session participants - // I need to adapt the order for later case of driver leaving the - // session - log.debug("Received user list from " + fromJID); - - int count = 0; - while (true) { - String jidS = userlistExtension.getValue("User" + count); - if (jidS == null) - break; - log.debug(" *:" + jidS); - - JID jid = new JID(jidS); - User user = new User(jid); - - String userRole = userlistExtension - .getValue("UserRole" + count); - user.setUserRole(de.fu_berlin.inf.dpp.User.UserRole - .valueOf(userRole)); - - String color = userlistExtension.getValue("UserColor" + count); - try { - user.setColorID(Integer.parseInt(color)); - } catch (NumberFormatException nfe) { - log - .warn("Exception during convert user color form userlist for user : " - + user.getJid()); - } - - if (project.getParticipant(jid) == null) - sendMessage(jid, PacketExtensions.createJoinExtension()); - - project.addUser(user, count - 1); // add user to internal user - // list, maintaining the - // received order - count++; - } - } - - else if (PacketExtensions.getInviteExtension(message) != null) { - DefaultPacketExtension inviteExtension = PacketExtensions - .getInviteExtension(message); - String desc = inviteExtension - .getValue(PacketExtensions.DESCRIPTION); - String pName = inviteExtension - .getValue(PacketExtensions.PROJECTNAME); - - ISessionManager sm = Saros.getDefault().getSessionManager(); - sm.invitationReceived(fromJID, pName, desc); - } - - else if (PacketExtensions.getCancelInviteExtension(message) != null) { - DefaultPacketExtension cancelInviteExtension = PacketExtensions - .getCancelInviteExtension(message); - - String errorMsg = cancelInviteExtension - .getValue(PacketExtensions.ERROR); - - for (IInvitationProcess process : processes) { - if (process.getPeer().equals(fromJID)) - process.cancel(errorMsg, true); - } - } - - else if (PacketExtensions.getJingleErrorExtension(message) != null) { - log.debug("Receive jingle error messages from " + fromJID); - /* set error state for this peer in jingle connection states. */ - jingleManager.setJingleErrorState(fromJID); - /* TODO: callback for other connections possible? */ - } else if (PacketExtensions.getJupiterErrorExtension(message) != null) { - log.debug("Receive jingle error messages from " + fromJID); - - } else if (PacketExtensions.getChecksumErrorExtension(message) != null) { - // log.debug("Receive jingle error messages from "+fromJID); - DefaultPacketExtension checksumErrorExtension = PacketExtensions - .getChecksumErrorExtension(message); - String path = checksumErrorExtension - .getValue(PacketExtensions.FILE_PATH); - System.out.println("Checksum Error for " + path); - ErrorMessageDialog.showChecksumErrorMessage(path); - } - - } - - /* - * (non-Javadoc) - * - * @see org.jivesoftware.smackx.filetransfer.FileTransferListener - */ - public void fileTransferRequest(FileTransferRequest incommingRequest) { - - /* for testing file transfer. */ - - // File newfile = null; - // try { - // - // String fileDescription = request.getDescription(); - // log.debug("incomming file transfer " + request.getFileName()); - // if (fileDescription.equals(FILELIST_TRANSFER_DESCRIPTION)) { - // - // /* - // * Create file list file - // */ - // IncomingFileTransfer transfer = request.accept(); - // - // log.debug(request.getFileName() + " with filepath " - // + transfer.getFilePath()); - // - // FileTransferProcessMonitor monitor = new FileTransferProcessMonitor( - // transfer); - // /* receive file. */ - // newfile = new File(request.getFileName()); - // transfer.recieveFile(newfile); - // - // /* wait for complete transfer. */ - // while (monitor.isAlive() && monitor.isRunning()) { - // Thread.sleep(500); - // } - // monitor.closeMonitor(true); - // - // /* change file list receiver */ - // FileList fileList = receiveFileList(newfile); - // - // // FileList fileList = receiveFileList(request); - // - // JID fromJID = new JID(request.getRequestor()); - // - // for (IInvitationProcess process : processes) { - // if (process.getPeer().equals(fromJID)) - // process.fileListReceived(fromJID, fileList); - // } - // log.debug("received filelist with file transfer. "); - // } else { - // if (fileDescription - // .startsWith(RESOURCE_TRANSFER_DESCRIPTION, 0)) { - // // /* receive file. */ - // // newfile = new File(request.getFileName()); - // // transfer.recieveFile(newfile); - // - // receiveResource(request); - // log.debug("receive ressource file transfer."); - // } - // } - // - // } catch (Exception e) { - // log.error(e); - // } - /* end for testing file transfer. */ - - final FileTransferRequest request = incommingRequest; - - new Thread(new Runnable() { - - public void run() { - try { - String fileDescription = request.getDescription(); - log.debug("1. incomming file transfer " - + request.getFileName()); - if (fileDescription.equals(PROJECT_ARCHIVE_DESCRIPTION)) { - log.debug(" incoming project archive file."); - receiveArchiveFile(request); - } - if (fileDescription.equals(FILELIST_TRANSFER_DESCRIPTION)) { - FileList fileList = receiveFileListBufferByteArray(request); - JID fromJID = new JID(request.getRequestor()); - - log.debug("2. inform invitation process..."); - for (IInvitationProcess process : processes) { - if (process.getPeer().equals(fromJID)) { - process.fileListReceived(fromJID, fileList); - /* - * incoming IBB transfer. cancel jingle transfer - * mode. - */ - process.setTransferMode(TransferMode.IBB); - } - } - - } else if (fileDescription.startsWith( - RESOURCE_TRANSFER_DESCRIPTION, 0)) { - receiveResource(request); - } - } catch (Exception e) { - // TODO Exception weiter reichen. - log.error("Incoming File Transfer Thread: ", e); - for (IInvitationProcess process : processes) { - if (process.getPeer().equals( - new JID(request.getRequestor()))) - process.cancel(e.getMessage(), false); - } - } - - } - - }).start(); - - } - - /** - * read incoming file and open inputstream to IInvitationProcess. - * - * @param request - * @throws Exception - */ - private void receiveArchiveFile(FileTransferRequest request) - throws Exception { - // try{ - File archive = receiveFile(request); - - ZipFile zip = new ZipFile(archive); - Enumeration<ZipEntry> entries = (Enumeration<ZipEntry>) zip.entries(); - while (entries.hasMoreElements()) { - ZipEntry entry = entries.nextElement(); - System.out.println(entry.getName()); - JID fromJID = new JID(request.getRequestor()); - - log.debug("2. inform invitation process..."); - for (IInvitationProcess process : processes) { - if (process.getPeer().equals(fromJID)) - process.resourceReceived(fromJID, - new Path(entry.getName()), zip - .getInputStream(entry)); - } - } - archive.delete(); - } - - private void sendMessageToAll(ISharedProject sharedProject, - PacketExtension extension) { // HACK - - JID myJID = Saros.getDefault().getMyJID(); - - for (User participant : sharedProject.getParticipants()) { - if (participant.getJid().equals(myJID)) - continue; - - // if user is known to be offline, dont send but queue - if (sharedProject != null) { - - User user = sharedProject.getParticipant(participant.getJid()); - if (user != null - && user.getPresence() == User.UserConnectionState.OFFLINE) { - - // offline for too long - if (user.getOfflineSecs() > FORCEDPART_OFFLINEUSER_AFTERSECS) { - log.info("Removing offline user from session..."); - sharedProject.removeUser(user); - } else { - queueMessage(participant.getJid(), extension); - log.info("User known as offline - Message queued!"); - } - - continue; - } - } - - sendMessage(participant.getJid(), extension); - } - } - - private void queueMessage(JID jid, PacketExtension extension) { - MessageTransfer msg = new MessageTransfer(); - msg.receipient = jid; - msg.packetextension = extension; - messageTransferQueue.add(msg); - } - - private void sendMessage(JID jid, PacketExtension extension) { - - if (!connection.isConnected()) { - queueMessage(jid, extension); - return; - } - - try { - - Chat chat = getChat(jid); - Message message; - // Änderung für Smack 3 - message = new Message(); - // message = chat.createMessage(); - message.addExtension(extension); - - chat.sendMessage(message); - - } catch (Exception e) { - queueMessage(jid, extension); - - Saros.getDefault().getLog().log( - new Status(IStatus.ERROR, Saros.SAROS, IStatus.ERROR, - "Could not send message, message queued", e)); - } - } - - private void receiveResource(JingleFileTransferData data, InputStream input) { - try { - JID from = data.sender; - Path path = new Path(data.file_project_path); - - for (IInvitationProcess process : processes) { - if (process.getPeer().equals(from)) { - process.resourceReceived(from, path, input); - - } - } - - } catch (Exception e) { - log.error("Error during receive file", e); - } - } - - /** - * receive resource with file transfer. - * - * @param request - */ - private void receiveResource(FileTransferRequest request) { - try { - - JID from = new JID(request.getRequestor()); - /* file path exists in description. */ - Path path = new Path(request.getDescription().substring( - RESOURCE_TRANSFER_DESCRIPTION.length() + 1)); - - log.debug("Receiving resource from" + from.toString() + ": " - + request.getFileName()); - - // InputStream in = request.accept().recieveFile(); - - IncomingFileTransfer transfer = request.accept(); - - // FileTransferProcessMonitor monitor = new - // FileTransferProcessMonitor( - // transfer); - - InputStream in = transfer.recieveFile(); - /* 1. Wenn es innerhalb des Invitation processes stattfindet. */ - boolean handledByInvitation = false; - for (IInvitationProcess process : processes) { - if (process.getPeer().equals(from)) { - process.resourceReceived(from, path, in); - handledByInvitation = true; - } - } - - /* - * 2. wenn es nicht innerhalb des invitation process stattfindet, - * sondern innerhalb der session. - */ - if (!handledByInvitation) { - FileActivity activity = new FileActivity( - FileActivity.Type.Created, path, in); - - int time; - String description = request.getDescription(); - try { - time = Integer - .parseInt(description - .substring(RESOURCE_TRANSFER_DESCRIPTION - .length() + 1)); - } catch (NumberFormatException e) { - Saros.log("Could not parse time from description: " - + description, e); - time = 0; // HACK - } - - TimedActivity timedActivity = new TimedActivity(activity, time); - - ISessionManager sm = Saros.getDefault().getSessionManager(); - sm.getSharedProject().getSequencer().exec(timedActivity); - } - - // /* wait for complete transfer. */ - // while (monitor.isAlive() && monitor.isRunning()) { - // Thread.sleep(500); - // } - // monitor.closeMonitor(true); - - log.info("Received resource " + request.getFileName()); - - } catch (Exception e) { - log.warn("Failed to receive " + request.getFileName(), e); - } - } - - private void transferFile(FileTransferData transferData) - throws CoreException, XMPPException, IOException { - - log.info("Sending file " + transferData.path); - - JID recipient = transferData.recipient; - - String description = RESOURCE_TRANSFER_DESCRIPTION; - if (transferData.timestamp >= 0) { - description = description + ':' + transferData.timestamp; - } - - if (getFileTransferModeViaChat() || transferData.callback == null) { - - if (transferData.content == null) - readFile(transferData); - - sendChatTransfer(transferData.path.toString(), description, - transferData.content, recipient); - - log.info("Sent file " + transferData.path + " (by ChatTransfer)"); - return; - } - - if (jingle - && (jingleManager.getState(recipient) != JingleConnectionState.ERROR)) { - log.info("Sent file " + transferData.path + " (with Jingle)"); - - JingleFileTransferProcessMonitor monitor = new JingleFileTransferProcessMonitor(); - /* create file transfer. */ - JingleFileTransferData data = new JingleFileTransferData(); - - /* only for testing. */ - data.file_project_path = transferData.path.toString(); - data.project_name = transferData.project.getName(); - data.type = FileTransferType.RESOURCE_TRANSFER; - data.recipient = recipient; - data.sender = new JID(connection.getUser()); - - /* read content data. */ - File f = new File(transferData.project.getFile(transferData.path) - .getLocation().toOSString()); - data.filesize = f.length(); - data.content = new byte[(int) data.filesize]; - - try { - InputStream in = transferData.project - .getFile(transferData.path).getContents(); - in.read(data.content, 0, (int) data.filesize); - } catch (Exception e) { - e.printStackTrace(); - data.content = null; - log.error("Error during read file content for transfer!"); - } - - jingleManager.createOutgoingJingleFileTransfer(recipient, - new JingleFileTransferData[] { data }, monitor); - - /* inform callback. */ - if (transferData.callback != null) - transferData.callback.fileSent(transferData.path); - - } else { - /* Fallback to transfer all data into one archive file. */ - // TODO: Don't ask the InvitationProcesses what to do, rather try - // IBB yourself. - transferData.callback.jingleFallback(); - - } - } - - /** - * Receive file and save temporary. - * - * @param request - * transfer request of incoming file. - * @return File object of received file - */ - private File receiveFile(FileTransferRequest request) { - File archiveFile = new File("./incoming_archive.zip"); - log.debug("Archive file: " + archiveFile.getAbsolutePath()); - try { - final IncomingFileTransfer transfer = request.accept(); - - IFileTransferCallback callback = null; - - /* get IInvitationprocess for monitoring. */ - JID fromJID = new JID(request.getRequestor()); - for (IInvitationProcess process : processes) { - if (process.getPeer().equals(fromJID)) { - /* set callback. */ - callback = process; - } - } - - /* monitoring of transfer process */ - FileTransferProcessMonitor monitor = new FileTransferProcessMonitor( - transfer, callback); - - /* receive file. */ - transfer.recieveFile(archiveFile); - - /* wait for complete transfer. */ - while (monitor.isAlive() && monitor.isRunning()) { - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - monitor.closeMonitor(true); - - } catch (Exception e) { - log.error("Error in Incoming File: ", e); - return null; - // e.printStackTrace(); - // Saros.log("Exception while receiving file list", e); - // TODO retry? but we dont catch any exception here, - // smack might not throw them up - } - - return archiveFile; - } - - private FileList receiveFileListBufferByteArray(FileTransferRequest request) { - FileList fileList = null; - try { - final IncomingFileTransfer transfer = request.accept(); - - InputStream in = transfer.recieveFile(); - - byte[] buffer = new byte[1024]; - int bytesRead; - String sb = new String(); - while ((bytesRead = in.read(buffer, 0, 1024)) != -1) { - sb += new String(buffer, 0, bytesRead).toString(); - } - in.close(); - log.debug("Close input stream"); - fileList = new FileList(sb.toString()); - - } catch (Exception e) { - log.error("Error in Incoming File List: ", e); - return null; - // e.printStackTrace(); - // Saros.log("Exception while receiving file list", e); - // TODO retry? but we dont catch any exception here, - // smack might not throw them up - } - - return fileList; - } - - private void putIncomingChat(JID jid, String thread) { - if (!chats.containsKey(jid)) { - - // TODO: Änderung für Smack 3 - // Chat chat = this.chatmanager.createChat(jid.toString(), thread, - // this); - Chat chat = this.chatmanager.getThreadChat(thread); - chats.put(jid, chat); - } - - } - - private Chat getChat(JID jid) { - if (connection == null) - throw new NullPointerException("Connection can't be null."); - - Chat chat = chats.get(jid); - - if (chat == null) { - - // ChatManager chatmanager = connection.getChatManager(); - // chat = new Chat(connection, jid.toString()); - - // TODO: Änderung für Smack 3 : Listener angeben - chat = this.chatmanager.createChat(jid.toString(), this); - chats.put(jid, chat); - } - - return chat; - } - - private void setProxyPort(XMPPConnection connection) { - - IPreferenceStore preferenceStore = Saros.getDefault() - .getPreferenceStore(); - // TODO: Änderung für smack 3 : filetransfer have to be implements new - fileTransferManager.getProperties().setProperty( - FileTransferNegotiator.AVOID_SOCKS5, "true"); - fileTransferManager - .getProperties() - .setProperty( - IBBTransferNegotiator.PROPERTIES_BLOCK_SIZE, - preferenceStore - .getString(PreferenceConstants.CHATFILETRANSFER_CHUNKSIZE)); - // fileTransferManager.getProperties().setProperty(Socks5TransferNegotiator.PROPERTIES_PORT, - // preferenceStore.getString(PreferenceConstants.FILE_TRANSFER_PORT)); - - } - - private boolean getFileTransferModeViaChat() { - return m_bFileTransferByChat - || Saros.getDefault().getPreferenceStore().getBoolean( - PreferenceConstants.FORCE_FILETRANSFER_BY_CHAT); - - } - - public void incommingFileList(String fileList_content, JID recipient) { - FileList fileList = null; - log.info("incoming file list"); - try { - fileList = new FileList(fileList_content); - } catch (XmlPullParserException e) { - - e.printStackTrace(); - } catch (IOException e) { - - e.printStackTrace(); - } - for (IInvitationProcess process : processes) { - if (process.getPeer().equals(recipient)) - process.fileListReceived(recipient, fileList); - } - - } - - public void exceptionOccured(JingleSessionException exception) { - // TODO: exception weiter geben oder für Fallback verwenden! - log.error("Jingle Session Exception"); - - // this.JingleError = true; - /* jingle exception with given jid */ - if (exception.getJID() != null) { - /* inform invitation process. */ - for (IInvitationProcess process : processes) { - if (process.getPeer().equals(exception.getJID())) { - /* set jingle connection error. */ - jingleManager.setJingleErrorState(exception.getJID()); - /* fallback in invitation process */ - process.jingleFallback(); - /* send error state to recipient. */ - sendMessage(exception.getJID(), PacketExtensions - .createJingleErrorExtension()); - log.debug("jingle fallback. send error message to " - + exception.getJID()); - } - } - } else { - ErrorMessageDialog.showErrorMessage(exception); - } - } - - public void incomingResourceFile(JingleFileTransferData data, - InputStream input) { - log.debug("incoming file"); - receiveResource(data, input); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/FileTransferMediaManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/FileTransferMediaManager.java deleted file mode 100644 index e6540dae89ee08ca319558dd85c6f010d1a4e052..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/FileTransferMediaManager.java +++ /dev/null @@ -1,168 +0,0 @@ -package de.fu_berlin.inf.dpp.net.jingle; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import org.apache.log4j.Logger; -import org.jivesoftware.smackx.jingle.JingleSession; -import org.jivesoftware.smackx.jingle.media.JingleMediaManager; -import org.jivesoftware.smackx.jingle.media.JingleMediaSession; -import org.jivesoftware.smackx.jingle.media.PayloadType; -import org.jivesoftware.smackx.jingle.nat.JingleTransportManager; -import org.jivesoftware.smackx.jingle.nat.TransportCandidate; - -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.net.internal.JingleFileTransferData; - -public class FileTransferMediaManager extends JingleMediaManager { - - private static Logger logger = Logger - .getLogger(FileTransferMediaManager.class); - - private List<PayloadType> payloads = new ArrayList<PayloadType>(); - - private IJingleFileTransferListener listener; - private HashMap<JID, FileTransferSession> sessions; - private JingleTransportManager transportManager; - - /* tranfer data */ - private JingleFileTransferData[] transferData; - private JingleFileTransferProcessMonitor monitor; - - public FileTransferMediaManager(JingleTransportManager transportManager) { - - super(transportManager); - this.transportManager = transportManager; - setupPayloads(); - sessions = new HashMap<JID, FileTransferSession>(); - } - - @Override - public JingleTransportManager getTransportManager(){ - return this.transportManager; - } - - @Override - public JingleMediaSession createMediaSession(PayloadType payloadType, - TransportCandidate remote, TransportCandidate local, - JingleSession jingleSession) { - /* get responder JID. */ - JID jid = new JID(jingleSession.getResponder()); - - FileTransferSession session = sessions.get(jid); - if (transferData == null) { - /* session for incomming transfer. */ - session = new FileTransferSession(payloadType, remote, local, - "FileTransfer", jingleSession); - } else { - /* session for outgoing transfer. */ - session = new FileTransferSession(payloadType, remote, local, - "FileTransfer", jingleSession, transferData, monitor); - } - session.addJingleFileTransferListener(listener); - // this.session = session; - - /* add to session list. */ - sessions.put(jid, session); - return session; - } - - /** - * Setup API supported Payloads - */ - private void setupPayloads() { - payloads.add(new PayloadType.Audio(333, "fileshare")); - } - - @Override - public List<PayloadType> getPayloads() { - return payloads; - } - - public PayloadType getPreferredPayloadType() { - return new PayloadType.Audio(333, "fileshare"); - } - - /** - * set the file data for transfer - * - * @param transferData - */ - public void setTransferFile(JingleFileTransferData[] transferData, - JingleFileTransferProcessMonitor monitor) { - this.transferData = transferData; - this.monitor = monitor; - } - - /** - * send new transfer data over existing stream. - * - * @param transferData - */ - public void setTransferFile(JingleFileTransferData[] transferData) - throws JingleSessionException { - // this.transferData = transferData; - - for (JingleFileTransferData data : transferData) { - /* set data for appropriate session. */ - FileTransferSession session = sessions.get(data.recipient); - if (session != null) { - session.sendFileData(transferData); - } else { - /* incoming session registered to sender. */ - session = sessions.get(data.sender); - if (session != null) { - session.sendFileData(transferData); - } - } - } - } - - @Deprecated - public void setTransferMonitor(JingleFileTransferProcessMonitor monitor) { - this.monitor = monitor; - } - - // public void sendFileData() throws JingleSessionException { - // if(session == null){ - // throw new JingleSessionException("Jingle Session not exist."); - // } - // - // - // } - - /** - * add listener to all active sessions. - */ - public void addJingleFileTransferListener( - IJingleFileTransferListener listener) { - this.listener = listener; - FileTransferSession session = null; - for (JID jid : sessions.keySet()) { - session = sessions.get(jid); - if (session != null) { - session.addJingleFileTransferListener(listener); - } - } - } - - public void removeJingleFileTransferListener( - IJingleFileTransferListener listener) { - this.listener = null; - FileTransferSession session = null; - for (JID jid : sessions.keySet()) { - session = sessions.get(jid); - if (session != null) { - session.removeJingleFileTransferListener(listener); - } - } - - } - - public void removeJingleSession(JID jid) { - logger.debug("remove session with JID: " + jid); - sessions.remove(jid); - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/FileTransferSession.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/FileTransferSession.java deleted file mode 100644 index 517060afb849fa7c949761c9f7187122aa0fe83b..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/FileTransferSession.java +++ /dev/null @@ -1,215 +0,0 @@ -package de.fu_berlin.inf.dpp.net.jingle; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.ServerSocket; -import java.net.UnknownHostException; - -import org.jivesoftware.smackx.jingle.JingleSession; -import org.jivesoftware.smackx.jingle.media.JingleMediaSession; -import org.jivesoftware.smackx.jingle.media.PayloadType; -import org.jivesoftware.smackx.jingle.nat.TransportCandidate; - -import de.fu_berlin.inf.dpp.net.internal.JingleFileTransferData; -import de.fu_berlin.inf.dpp.net.jingle.receiver.FileTransferTCPReceiver; -import de.fu_berlin.inf.dpp.net.jingle.transmitter.FileTransferTCPTransmitter; - -public class FileTransferSession extends JingleMediaSession { - - private IFileTransferTransmitter transmitter = null; - private IFileTransferReceiver receiver = null; -// private XMPPConnection connection; - - /* transfer information */ - private JingleFileTransferData[] transferData; - private JingleFileTransferProcessMonitor monitor; - private IJingleFileTransferListener listener; - - public FileTransferSession(PayloadType payloadType, - TransportCandidate remote, TransportCandidate local, - String mediaLocator, JingleSession jingleSession) { - super(payloadType, remote, local, mediaLocator, jingleSession); - initialize(); - } - - public FileTransferSession(PayloadType payloadType, - TransportCandidate remote, TransportCandidate local, - String mediaLocator, JingleSession jingleSession, - JingleFileTransferData[] transferData, - JingleFileTransferProcessMonitor monitor) { - super(payloadType, remote, local, mediaLocator, jingleSession); - - this.transferData = transferData; - this.monitor = monitor; - - initialize(); - } - - @Override - public void initialize() { - JingleSession session = getJingleSession(); - if (!((session != null) && (session.getInitiator().equals(session.getConnection().getUser())))) { -// if (this.getJingleSession() instanceof JingleSession) { - try { - - receiver = new FileTransferTCPReceiver(InetAddress - .getByName(getRemote().getIp()), getRemote().getPort(), - getLocal().getPort()); - receiver.addJingleFileTransferListener(listener); -// /* call listener. */ -// if (listener != null) { -// listener -// .incommingFileTransfer(((FileTransferTCPReceiver) receiver) -// .getMonitor()); -// } - System.out.println("Receiving on:" + receiver.getLocalPort()); - } catch (UnknownHostException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - - } else { - try { - - InetAddress remote = InetAddress.getByName(getRemote().getIp()); - System.out.println("local Port: " + getLocal().getPort()); - transmitter = new FileTransferTCPTransmitter(getLocal() - .getPort(), remote, getRemote().getPort(), - transferData, monitor); - transmitter.sendFileData(transferData); - transmitter.addJingleFileTransferListener(listener); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - } - - /** - * Set transmit activity. If the active is true, the instance should - * trasmit. If it is set to false, the instance should pause transmit. - * - * @param active - * active state - */ - public void setTrasmit(boolean active) { - transmitter.setTransmit(true); - - } - - /** - * For NAT Reasons this method does nothing. Use startTransmit() to start - * transmit and receive jmf - */ - public void startReceive() { - // Do nothing. - - } - - /** - * Starts transmission and for NAT Traversal reasons start receiving also. - */ - public void startTrasmit() { - new Thread(transmitter).start(); - } - - @Override - public void stopReceive() { - if (receiver != null) { - receiver.stop(); - } - } - - /** - * Stops transmission and for NAT Traversal reasons stop receiving also. - */ - public void stopTrasmit() { - if (transmitter != null) { - transmitter.stop(); - } - } - - /** - * Obtain a free port we can use. - * - * @return A free port number. - */ - protected int getFreePort() { - ServerSocket ss; - int freePort = 0; - - for (int i = 0; i < 10; i++) { - freePort = (int) (10000 + Math.round(Math.random() * 10000)); - freePort = freePort % 2 == 0 ? freePort : freePort + 1; - try { - ss = new ServerSocket(freePort); - freePort = ss.getLocalPort(); - ss.close(); - return freePort; - } catch (IOException e) { - e.printStackTrace(); - } - } - try { - ss = new ServerSocket(0); - freePort = ss.getLocalPort(); - ss.close(); - } catch (IOException e) { - e.printStackTrace(); - } - return freePort; - } - - public JingleFileTransferProcessMonitor getProcessMonitor() { - return this.monitor; - } - - /** - * send new data with current session - */ - public void sendFileData(JingleFileTransferData[] transferData) throws JingleSessionException{ - IJingleFileTransferConnection conn = null; - if(receiver != null){ - conn = receiver; - } - if(transmitter != null){ - conn = transmitter; - } - - if(conn == null){ - throw new JingleSessionException("connection stream not exists."); - } - - /* send data with existing streams*/ - conn.sendFileData(transferData); - } - - /* - * TODO: 1. Diese beiden Methoden auslagern - * 2. Listener Liste umsetzen. - */ - - public void addJingleFileTransferListener( - IJingleFileTransferListener listener) { - this.listener = listener; - if(receiver != null){ - receiver.addJingleFileTransferListener(listener); - } - if(transmitter != null){ - transmitter.addJingleFileTransferListener(listener); - } - } - - public void removeJingleFileTransferListener(IJingleFileTransferListener listener){ - this.listener = null; - if(receiver != null){ - removeJingleFileTransferListener(listener); - } - if(transmitter != null){ - removeJingleFileTransferListener(listener); - } - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/IFileTransferReceiver.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/IFileTransferReceiver.java deleted file mode 100644 index 8ac248cd286bd944d4c9bf1f09527a4dceed1dda..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/IFileTransferReceiver.java +++ /dev/null @@ -1,16 +0,0 @@ -package de.fu_berlin.inf.dpp.net.jingle; - -import java.net.InetAddress; - -public interface IFileTransferReceiver extends IJingleFileTransferConnection{ - - public InetAddress getLocalHost(); - - public InetAddress getRemoteHost() ; - - public int getLocalPort(); - - public int getRemotePort() ; - - public void stop(); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/IFileTransferTransmitter.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/IFileTransferTransmitter.java deleted file mode 100644 index 03ab35a190d4845c52e0beaab06ce90cdf94df97..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/IFileTransferTransmitter.java +++ /dev/null @@ -1,11 +0,0 @@ -package de.fu_berlin.inf.dpp.net.jingle; - -public interface IFileTransferTransmitter extends Runnable, IJingleFileTransferConnection{ - - public void setTransmit(boolean transmit); - - public void start(); - - public void stop(); - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/IJingleFileTransferConnection.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/IJingleFileTransferConnection.java deleted file mode 100644 index ae2d55c9006c184dda455c91e4ea78d0369ddfd8..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/IJingleFileTransferConnection.java +++ /dev/null @@ -1,16 +0,0 @@ -package de.fu_berlin.inf.dpp.net.jingle; - -import de.fu_berlin.inf.dpp.net.internal.JingleFileTransferData; - -public interface IJingleFileTransferConnection { - - /** - * send data with exist connection. - * @param transferData - */ - public void sendFileData(JingleFileTransferData[] transferData); - - public void addJingleFileTransferListener(IJingleFileTransferListener listener); - - public void removeJingleFileTransferListener(IJingleFileTransferListener listener); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/IJingleFileTransferListener.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/IJingleFileTransferListener.java deleted file mode 100644 index 2e3ab3ff9c5ef2208c4042abb8149025b9e72fd4..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/IJingleFileTransferListener.java +++ /dev/null @@ -1,20 +0,0 @@ -package de.fu_berlin.inf.dpp.net.jingle; - -import java.io.InputStream; - -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.net.internal.JingleFileTransferData; - -/** - * this class contains method for jingle file transfer action - * @author orieger - * - */ -public interface IJingleFileTransferListener { - - public void incommingFileList(String fileList_content, JID sender); - - public void incomingResourceFile(JingleFileTransferData data, InputStream input); - - public void exceptionOccured(JingleSessionException exception); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleFileTransferManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleFileTransferManager.java deleted file mode 100644 index 2e45c4a433690faa9dbf9d5c66cbbb8c58f2f6a0..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleFileTransferManager.java +++ /dev/null @@ -1,450 +0,0 @@ -package de.fu_berlin.inf.dpp.net.jingle; - -import java.util.HashMap; -import java.util.List; -import java.util.Vector; - -import org.apache.log4j.Logger; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smackx.jingle.JingleManager; -import org.jivesoftware.smackx.jingle.JingleNegotiatorState; -import org.jivesoftware.smackx.jingle.JingleSession; -import org.jivesoftware.smackx.jingle.JingleSessionRequest; -import org.jivesoftware.smackx.jingle.listeners.JingleMediaListener; -import org.jivesoftware.smackx.jingle.listeners.JingleSessionListener; -import org.jivesoftware.smackx.jingle.listeners.JingleSessionRequestListener; -import org.jivesoftware.smackx.jingle.listeners.JingleTransportListener; -import org.jivesoftware.smackx.jingle.media.JingleMediaManager; -import org.jivesoftware.smackx.jingle.media.PayloadType; -import org.jivesoftware.smackx.jingle.nat.ICETransportManager; -import org.jivesoftware.smackx.jingle.nat.TransportCandidate; - -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.net.internal.JingleFileTransferData; - -public class JingleFileTransferManager { - - private static Logger logger = Logger - .getLogger(JingleFileTransferManager.class); - - private XMPPConnection xmppConnection; - private IJingleFileTransferListener transmitter; - private JingleManager jm; - - private HashMap<JID, JingleSession> incomingSessions = null; - private HashMap<JID, JingleSession> outgoingSessions = null; - - public static int JINGLE_TIME_OUT = 10000; - - /** - * this map contains for all incoming and outgoing jingle sessions the - * appropriate connection states. If an error occur the connection state - * stay in list for call back setting. - */ - private HashMap<JID, JingleConnectionState> connectionStates = null; - private FileTransferMediaManager mediaManager = null; - - public enum JingleConnectionState { - INIT, ESTABLISHED, CLOSED, ERROR, DEFAULT - } - - public JingleFileTransferManager(XMPPConnection connection, - IJingleFileTransferListener transmitter) { - this.xmppConnection = connection; - this.transmitter = transmitter; - incomingSessions = new HashMap<JID, JingleSession>(); - outgoingSessions = new HashMap<JID, JingleSession>(); - connectionStates = new HashMap<JID, JingleConnectionState>(); - logger.debug("initialized jingle file transfer manager."); - initialize(); - } - - /** - * control time out of jingle session initiation - * - * @param jid - */ - private void timeOutCheck(final JID jid, final int timeout) { - int count = 0; - new Thread(new Runnable() { - - public void run() { - int count = 0; - while (getState(jid) != (JingleConnectionState.ESTABLISHED)) { - try { - Thread.sleep(200); - - if (count < timeout) { - count += 200; - } else { - logger.error("Time out for : "+jid + " with current state : "+getState(jid)); - connectionStates.remove(jid); - connectionStates.put(jid, JingleConnectionState.ERROR); - terminateJingleSession(jid); - transmitter.exceptionOccured(new JingleSessionException("Time out Exception",jid)); - return; - } - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - } - }).start(); - - } - - private void initJingleListener(JingleSession js, final JID jid) { - - connectionStates.put(jid, JingleConnectionState.INIT); - - /* add media listener. */ - js.addMediaListener(new JingleMediaListener() { - - public void mediaClosed(PayloadType cand) { - logger.debug("media closed : " + jid.toString()); - - // NEGOTIATION = false; - // notifyAll(); - } - - public void mediaEstablished(PayloadType pt) { - logger.debug("media established : " + jid.toString()); - - // NEGOTIATION = false; - // notifyAll(); - } - }); - -// /* add state listener. */ -// js.addStateListener(new JingleSessionStateListener() { -// -// public void afterChanged(State old, State newOne) { -// // logger.debug("session state after change new state : -// // "+newOne.toString()+" JID: "+jid_string); -// -// } -// -// public void beforeChange(State old, State newOne) -// throws JingleException { -// // logger.debug("session state before change : -// // "+old.toString()+" new : "+newOne.toString()+" JID: -// // "+jid_string); -// -// } -// }); - - js.addListener( new JingleSessionListener(){ - - public void sessionClosed(String arg0, JingleSession arg1) { - logger.info("session closed : " + jid.toString()); - - /* if session closed during pending process, fallback to XEP-0096 transfer*/ - if(arg1.getNegotiatorState() == JingleNegotiatorState.PENDING && (connectionStates.get(jid) != JingleConnectionState.ESTABLISHED && connectionStates.get(jid) != JingleConnectionState.ERROR)){ - logger.error("Session closed during pending process : "+jid + " with current state : "+getState(jid)); - connectionStates.remove(jid); - connectionStates.put(jid, JingleConnectionState.ERROR); - transmitter.exceptionOccured(new JingleSessionException("Session closed during establishing process",jid)); - - } - connectionStates.remove(jid); - connectionStates.put(jid, JingleConnectionState.CLOSED); - - } - - public void sessionClosedOnError(XMPPException arg0, - JingleSession arg1) { - logger.error("session closed on error : " + jid.toString()); - connectionStates.remove(jid); - connectionStates.put(jid, JingleConnectionState.ERROR); - - } - - public void sessionDeclined(String arg0, JingleSession arg1) { - // TODO Auto-generated method stub - - } - - public void sessionEstablished(PayloadType arg0, - TransportCandidate arg1, TransportCandidate arg2, - JingleSession arg3) { - logger.debug("session established : " + jid.toString()); - connectionStates.remove(jid); - connectionStates.put(jid, JingleConnectionState.ESTABLISHED); - - } - - public void sessionMediaReceived(JingleSession arg0, String arg1) { - // TODO Auto-generated method stub - - } - - public void sessionRedirected(String arg0, JingleSession arg1) { - // TODO Auto-generated method stub - - } - - }); - - /* transport events */ - js.addTransportListener(new JingleTransportListener() { - - public void transportClosed(TransportCandidate cand) { - logger.debug("transport closed: " + jid.toString()); - connectionStates.remove(jid); - connectionStates.put(jid, JingleConnectionState.CLOSED); - // NEGOTIATION = false; - // notifyAll(); - } - - public void transportClosedOnError(XMPPException e) { - logger.error("transport closed on error : " + jid.toString()); - connectionStates.remove(jid); - connectionStates.put(jid, JingleConnectionState.ERROR); - // NEGOTIATION = false; - // notifyAll(); - } - - public void transportEstablished(TransportCandidate local, - TransportCandidate remote) { - logger.debug("transport established : " + jid.toString()); - connectionStates.remove(jid); - connectionStates.put(jid, JingleConnectionState.ESTABLISHED); - // NEGOTIATION = false; - // notifyAll(); - } - }); - - /* time out. */ -// timeOutCheck(jid, JINGLE_TIME_OUT); - } - - public void initialize() { - - /* other stun server. */ - ICETransportManager icetm0 = new ICETransportManager(xmppConnection, - "jivesoftware.com", 3478); - - mediaManager = new FileTransferMediaManager(icetm0); - mediaManager.addJingleFileTransferListener(transmitter); - - List<JingleMediaManager> medias = new Vector<JingleMediaManager>(); - medias.add(mediaManager); - - jm = new JingleManager(xmppConnection, medias); - jm.addCreationListener(icetm0); - - jm.addJingleSessionRequestListener(new JingleSessionRequestListener() { - public void sessionRequested(JingleSessionRequest request) { - - JID jid = new JID(request.getFrom()); - JingleSession incoming = incomingSessions.get(jid); - - if (incoming != null) - return; - - try { - - // Accept the call - incoming = request.accept(); - - initJingleListener(incoming, new JID(incoming - .getInitiator())); - /* put to current session list. */ - incomingSessions.put(jid, incoming); - // Start the call - incoming.startIncoming(); - } catch (XMPPException e) { - e.printStackTrace(); - } - - } - }); - - } - - /** - * intiate a jingle session - * - * @param jid - * @param transferData - * @param monitor - */ - public void createOutgoingJingleFileTransfer(JID jid, - JingleFileTransferData[] transferData, - JingleFileTransferProcessMonitor monitor) { - - final String jid_string = jid.toString(); - - JingleSession incoming = incomingSessions.get(jid); - if (incoming != null) { - /* an incoming session already exist. */ - try { - logger - .debug("Incoming stream exists. Send data with current stream."); - mediaManager.setTransferFile(transferData); - } catch (JingleSessionException jse) { - jse.printStackTrace(); - } - return; - } - - JingleSession outgoing = outgoingSessions.get(jid); - if (outgoing != null) { - /* send new data with current connection. */ - try { - mediaManager.setTransferFile(transferData); - } catch (JingleSessionException jse) { - jse.printStackTrace(); - } - return; - } - try { - // Set file info for media manager - - mediaManager.setTransferFile(transferData, monitor); - outgoing = jm.createOutgoingJingleSession(jid.toString()); - - initJingleListener(outgoing, jid); - - /* add to outgoing session list. */ - outgoingSessions.put(jid, outgoing); - outgoing.startOutgoing(); - } catch (XMPPException e1) { - e1.printStackTrace(); - } - } - - // private IncomingJingleSession getIncomingJingleSession(JID jid){ - // return incomingSessions.get(jid); - // } - // - // private OutgoingJingleSession getOutgoingJingleSession(JID jid){ - // return outgoingSessions.get(jid); - // } - - // /** - // * send datas with active jingle session. - // * @param transferData - // */ - // public void sendFileDatas(JingleFileTransferData[] transferData){ - // - // } - - /** - * remove all jingle sessions. - */ - public void terminateAllJingleSessions() { - - logger.debug("Terminate all jingle sessions."); - - JingleSession outgoing = null; - for (JID jid : outgoingSessions.keySet()) { - outgoing = outgoingSessions.get(jid); - if (outgoing != null) { - try { - outgoing.terminate(); - } catch (XMPPException e1) { - e1.printStackTrace(); - } finally { - outgoing = null; - mediaManager.removeJingleSession(jid); - outgoingSessions.remove(jid); - } - } - } - - JingleSession incoming = null; - for (JID jid : incomingSessions.keySet()) { - incoming = incomingSessions.get(jid); - if (incoming != null) { - try { - incoming.terminate(); - } catch (XMPPException e1) { - e1.printStackTrace(); - } finally { - incoming = null; - mediaManager.removeJingleSession(jid); - incomingSessions.remove(jid); - } - } - } - - /* reset connection state list */ -// connectionStates.clear(); - } - - /** - * terminate and remove jingle session for jid. - * - * @param jid - */ - public void terminateJingleSession(JID jid) { - JingleSession outgoing = outgoingSessions.get(jid); - if (outgoing != null) { - try { - outgoing.terminate(); - } catch (XMPPException e1) { -// e1.printStackTrace(); - logger.error("Error during terminate outgoing jingle session with JID : "+jid,e1); - } finally { - outgoing = null; - mediaManager.removeJingleSession(jid); - outgoingSessions.get(jid).close(); - outgoingSessions.remove(jid); - logger.debug("Terminate outgoing jingle session with JID : "+jid); - } - } - - JingleSession incoming = incomingSessions.get(jid); - if (incoming != null) { - try { - incoming.terminate(); - } catch (XMPPException e1) { -// e1.printStackTrace(); - logger.error("Error during terminate incoming jingle session with JID : "+jid,e1); - } finally { - incoming = null; - mediaManager.removeJingleSession(jid); - incomingSessions.remove(jid); - logger.debug("Terminate incoming jingle session with JID : "+jid); - } - } - -// if(connectionStates.get(jid) != JingleConnectionState.ERROR){ -// connectionStates.remove(jid); -// } - } - - /** - * this method returns the appropriate connection state of active jingle - * session. - * - * @param jid - * identify the jingle session - * @return JingleConnectionState for given jabber id, or null if non jingle - * session has found. - */ - public JingleConnectionState getState(JID jid) { - JingleConnectionState state = connectionStates.get(jid); - return state; - } - - /** - * Terminate Jingle connection and set error state for given - * peer. - * @param jid - */ - public void setJingleErrorState(JID jid){ - if(jid != null){ - logger.debug("Terminate Jingle Session for "+jid); - terminateJingleSession(jid); - connectionStates.remove(jid); - connectionStates.put(jid, JingleConnectionState.ERROR); - } - else{ - logger.warn("JID is null. Jingle error state couldn't be set."); - } - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleFileTransferProcessMonitor.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleFileTransferProcessMonitor.java deleted file mode 100644 index 30793b5b14ff8e96742f597fd5a63010b933bae4..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleFileTransferProcessMonitor.java +++ /dev/null @@ -1,24 +0,0 @@ -package de.fu_berlin.inf.dpp.net.jingle; - -/** - * - * @author orieger - * - */ -public class JingleFileTransferProcessMonitor { - - private boolean complete = false; - - public JingleFileTransferProcessMonitor(){ - - } - - public boolean isDone(){ - return complete; - } - - public void setComplete(boolean status){ - this.complete = status; - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleFileTransferTCPConnection.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleFileTransferTCPConnection.java deleted file mode 100644 index 8f0c129a0423c57c4d0942eeddf7e0537535dff6..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleFileTransferTCPConnection.java +++ /dev/null @@ -1,57 +0,0 @@ -package de.fu_berlin.inf.dpp.net.jingle; - -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.OutputStream; - -import org.apache.log4j.Logger; - -import de.fu_berlin.inf.dpp.net.internal.JingleFileTransferData; - -public abstract class JingleFileTransferTCPConnection { - - private static Logger logger = Logger - .getLogger(JingleFileTransferTCPConnection.class); - - /* transfer information */ - protected JingleFileTransferData receiveTransferData; - - protected IJingleFileTransferListener listener; - - protected void sendFileListData(OutputStream output, - String file_list_content) throws IOException { - ObjectOutputStream oo = new ObjectOutputStream(output); - - oo.writeObject(file_list_content); - oo.flush(); - } - - protected void sendMetaData(OutputStream output, JingleFileTransferData data) - throws IOException { - ObjectOutputStream oo = new ObjectOutputStream(output); - oo.writeObject(data); - oo.flush(); - } - - protected void receiveFileListData(InputStream input) throws IOException, - ClassNotFoundException { - logger.debug("receive file List"); - ObjectInputStream ii = new ObjectInputStream(input); - - String fileListData = (String) ii.readObject(); - - /* inform listener. */ - listener.incommingFileList(fileListData, receiveTransferData.sender); - } - - protected void receiveMetaData(InputStream input) throws IOException, - ClassNotFoundException { - ObjectInputStream ii = new ObjectInputStream(input); - - JingleFileTransferData meta = (JingleFileTransferData) ii.readObject(); - this.receiveTransferData = meta; - - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleSessionException.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleSessionException.java deleted file mode 100644 index 75d4e0f4e28cb18317975a4c2c24dc97f39ad57b..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleSessionException.java +++ /dev/null @@ -1,48 +0,0 @@ -package de.fu_berlin.inf.dpp.net.jingle; - -import de.fu_berlin.inf.dpp.net.JID; - -/** - * this exception is throw if jingle session request is failed. - * @author orieger - * - */ -public class JingleSessionException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 4395402562918748941L; - - private String message; - private JID jid; - private String errorName = "Jingle Tranfer Error"; - - public JingleSessionException(String message){ - super(); - this.message = message; - } - - public JingleSessionException(String message, JID jid){ - super(); - this.message = message; - this.jid = jid; - } - - public JingleSessionException(String message, Throwable cause){ - super(); - this.message = message; - } - - public JID getJID(){ - return jid; - } - - public String getMessage(){ - return message; - } - - public String toString(){ - return errorName; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/receiver/FileTransferTCPReceiver.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/receiver/FileTransferTCPReceiver.java deleted file mode 100644 index a335a85abb284c609337a31aea526f8fa2768d7f..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/receiver/FileTransferTCPReceiver.java +++ /dev/null @@ -1,298 +0,0 @@ -package de.fu_berlin.inf.dpp.net.jingle.receiver; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.OutputStream; -import java.net.InetAddress; -import java.net.ServerSocket; -import java.net.Socket; -import java.net.SocketException; - -import org.apache.log4j.Logger; - -import de.fu_berlin.inf.dpp.net.internal.JingleFileTransferData; -import de.fu_berlin.inf.dpp.net.internal.JingleFileTransferData.FileTransferType; -import de.fu_berlin.inf.dpp.net.jingle.IFileTransferReceiver; -import de.fu_berlin.inf.dpp.net.jingle.IJingleFileTransferListener; -import de.fu_berlin.inf.dpp.net.jingle.JingleFileTransferProcessMonitor; -import de.fu_berlin.inf.dpp.net.jingle.JingleFileTransferTCPConnection; -import de.fu_berlin.inf.dpp.net.jingle.JingleSessionException; - -public class FileTransferTCPReceiver extends JingleFileTransferTCPConnection implements IFileTransferReceiver { - - private static Logger logger = Logger - .getLogger(FileTransferTCPReceiver.class); - - private InetAddress localHost; - private InetAddress remoteHost; - private int localPort; - private int remotePort; - public static final int tileWidth = 25; - private boolean on = true; - private boolean transmit = false; - private boolean receive = false; - - /* transfer information */ -// private JingleFileTransferData receiveTransferData; - - /* transmit transfer data */ - private JingleFileTransferData[] transferData; - - private ServerSocket serverSocket = null; - - private final JingleFileTransferProcessMonitor monitor; -// private IJingleFileTransferListener listener; - - public FileTransferTCPReceiver(final InetAddress remoteHost, - final int remotePort, final int localPort) throws IOException { - // try { - - this.remoteHost = remoteHost; - this.remotePort = remotePort; - this.localPort = localPort; - - try { - serverSocket = new ServerSocket(localPort); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - transmit = false; - receive = true; - - /* init process monitor. */ - monitor = new JingleFileTransferProcessMonitor(); - - new Thread(new Runnable() { - - public void run() { - - try { - final Socket socket = serverSocket.accept(); - - InputStream input = socket.getInputStream(); - OutputStream output = socket.getOutputStream(); - - while (on) { - if (receive) { - - /* get number of file to be transfer. */ - int fileNumber = input.read(); - - if(fileNumber > 0){ - logger.debug("file number: "+fileNumber); - } - - for (int i = 0; i < fileNumber; i++) { - /* receive file meta data */ - logger.debug("receive meta data for"); - receiveMetaData(input); - - if (receiveTransferData.type == FileTransferType.FILELIST_TRANSFER) { - receiveFileListData(input); - /* file list receive, in the next step remote file list have to be send. */ - receive = false; - } - if (receiveTransferData.type == FileTransferType.RESOURCE_TRANSFER) { - /* receive file. */ - logger.info("File incoming: "+receiveTransferData.file_project_path); - /* received by meta data. */ -// receiveFile(input,output); - - listener.incomingResourceFile(receiveTransferData, new ByteArrayInputStream(receiveTransferData.content)); - - } - - } - - monitor.setComplete(true); - - } - if (transmit) { - -// if(transferData == null){ -// throw new JingleSessionException("No Transfer Data for sending remote filelist."); -// } - - int waitcount = 5; - while(transferData == null){ - /* wait for transferData*/ - logger.info("No TransferData available. Try again."); - Thread.sleep(50); - waitcount--; - if(waitcount < 1 && transferData == null){ - throw new JingleSessionException("No Transfer Data for sending remote filelist."); - } - } - - /* send file number. */ - output.write(transferData.length); - - for (int i = 0; i < transferData.length; i++) { - - /* send file meta data */ - sendMetaData(output, transferData[i]); - - if (transferData[i].type == FileTransferType.FILELIST_TRANSFER) { - sendFileListData(output, - transferData[i].file_list_content); - /* - * if file list send, we expect remote file - * list to receive. - */ - receive = true; - } - // if (transferData[i].type == - // FileTransferType.RESOURCE_TRANSFER) { - // sendFile(socket, transferData[i].file); - // } - - } - - /* set monitor status complete :) */ - monitor.setComplete(true); - - transmit = false; - - } - } - output.close(); - input.close(); - socket.close(); - - } - - catch (SocketException se) { - if (listener != null) { - listener.exceptionOccured(new JingleSessionException(se - .getMessage())); - } - logger.error("Socket Exception",se); - se.printStackTrace(); - return; - } - catch(JingleSessionException jse){ - if (listener != null) { - listener.exceptionOccured(jse); - } - logger.error("JingleSessionException",jse); - return; - } - catch (Exception e1) { - if (listener != null) { - listener.exceptionOccured(new JingleSessionException(e1 - .getMessage())); - } - logger.error("Exception",e1); - return; - } - } - }).start(); - - } - - @Deprecated - private void receiveFile(InputStream input, OutputStream output) throws IOException { -// InputStream input = socket.getInputStream(); - - /* on the first receive data into stream. */ - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - byte[] buffer = new byte[1024]; - int length = 0; - long filesize = receiveTransferData.filesize; - long currentSize = 0; - int readSize = 1024; - /* zuvor informationen schicken, wie groß die Datei ist.*/ - while(currentSize < filesize){ - - /* check end of file*/ - if((currentSize + readSize)>= filesize){ - readSize = (int)(filesize - currentSize); - } - - if((length = input.read(buffer, 0, readSize)) >= 0){ - bos.write(buffer, 0, length); - currentSize += length; - } -// System.out.println(new String(buffer,0,length)); - } - - /* inform listener */ - listener.incomingResourceFile(receiveTransferData, new ByteArrayInputStream(bos.toByteArray())); - - output.write(1); - output.flush(); - } - - @Deprecated - private void receiveString(Socket socket) throws IOException, - ClassNotFoundException { - ObjectOutputStream oo = new ObjectOutputStream(socket.getOutputStream()); - ObjectInputStream ii = new ObjectInputStream(socket.getInputStream()); - - String s1 = (String) ii.readObject(); - - oo.writeObject("Result " + s1); - oo.flush(); - ii.close(); - oo.close(); - } - - @Deprecated - private void printContent(byte[] data) throws Exception { - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - data); - byte[] buffer = new byte[4000]; - int len = byteArrayInputStream.read(buffer, 0, 4000); - String str = new String(buffer, 0, len); - - System.out.println(str); - } - - public InetAddress getLocalHost() { - return localHost; - } - - public InetAddress getRemoteHost() { - return remoteHost; - } - - public int getLocalPort() { - return localPort; - } - - public int getRemotePort() { - return remotePort; - } - - public void stop() { - this.on = false; - // socket.close(); - } - - public JingleFileTransferProcessMonitor getMonitor() { - return this.monitor; - } - - public void sendFileData(JingleFileTransferData[] transferData) { - transmit = true; - this.transferData = transferData; - } - - public void addJingleFileTransferListener( - IJingleFileTransferListener listener) { - this.listener = listener; - - } - - public void removeJingleFileTransferListener( - IJingleFileTransferListener listener) { - this.listener = null; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/transmitter/FileTransferTCPTransmitter.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/transmitter/FileTransferTCPTransmitter.java deleted file mode 100644 index 55925d0739d8c2837697ce1905a484db37df6177..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/transmitter/FileTransferTCPTransmitter.java +++ /dev/null @@ -1,256 +0,0 @@ -package de.fu_berlin.inf.dpp.net.jingle.transmitter; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.InetAddress; -import java.net.Socket; -import java.net.SocketException; -import java.util.List; -import java.util.Vector; - -import org.apache.log4j.Logger; - -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.net.internal.JingleFileTransferData; -import de.fu_berlin.inf.dpp.net.internal.JingleFileTransferData.FileTransferType; -import de.fu_berlin.inf.dpp.net.jingle.IFileTransferTransmitter; -import de.fu_berlin.inf.dpp.net.jingle.IJingleFileTransferListener; -import de.fu_berlin.inf.dpp.net.jingle.JingleFileTransferProcessMonitor; -import de.fu_berlin.inf.dpp.net.jingle.JingleFileTransferTCPConnection; -import de.fu_berlin.inf.dpp.net.jingle.JingleSessionException; - -public class FileTransferTCPTransmitter extends JingleFileTransferTCPConnection implements IFileTransferTransmitter, - Runnable { - - private static Logger logger = Logger - .getLogger(FileTransferTCPTransmitter.class); - - private InetAddress remoteHost; - private int remotePort; - public static final int tileWidth = 25; - private boolean on = true; - private boolean transmit = false; - private boolean receive = false; - - /* transfer information */ - private List<JingleFileTransferData> transferList = new Vector<JingleFileTransferData>(); - - private JingleFileTransferData currentSending = null; - - public FileTransferTCPTransmitter(int localPort, InetAddress remoteHost, - int remotePort, JingleFileTransferData[] transferData, - JingleFileTransferProcessMonitor monitor) { - - this.remoteHost = remoteHost; - this.remotePort = remotePort; - - transmit = true; - } - - public void run() { - start(); - } - - public void start() { - - Socket socket = null; - try { - - try { - // TODO: Socket create methode mit time out einfügen - - /* Übertragung zwischen zwei Partnern. */ - socket = new Socket(remoteHost, remotePort); - } catch (SocketException se) { - logger.warn("Second tcp socket initiation."); - Thread.sleep(1500); - socket = new Socket(remoteHost, remotePort); - } - - - - InputStream input = socket.getInputStream(); - OutputStream output = socket.getOutputStream(); - - while (on) { - - /** - * Time out f�r offen verbindung ohne daten einbauen. - */ - if (transmit) { - - /* send file number. */ - transferData(output,input); - - - } - if (receive) { - /* get number of file to be transfer. */ - // InputStream input = socket.getInputStream(); - int fileNumber = input.read(); - - System.out.println("incomming file numbers: " + fileNumber); - - for (int i = 0; i < fileNumber; i++) { - /* receive file meta data */ - receiveMetaData(input); - - if (receiveTransferData.type == FileTransferType.FILELIST_TRANSFER) { - receiveFileListData(input); - } - // if (receiveTransferData.type == - // FileTransferType.RESOURCE_TRANSFER) { - // /* receive file. */ - // receiveFile(socket); - // } - - } - - receive = false; - } - } - output.close(); - input.close(); - socket.close(); - - } catch (Exception e1) { - logger.error(e1); - if (listener != null) { - listener.exceptionOccured(new JingleSessionException("Error during Jingle file transfer.",getRemoteJID())); - } - - return; - } - } - - private JID getRemoteJID(){ - if(currentSending != null){ - return currentSending.recipient; - } - else{ - /* error occured on the beginning. try to find out recipient jid - * with transfer list. */ - if(transferList != null && transferList.size() > 0){ - return transferList.get(0).recipient; - } - } - return null; - } - - /** - * Set Transmit Enabled/Disabled - * - * @param transmit - * boolean Enabled/Disabled - */ - public synchronized void setTransmit(boolean transmit) { - this.transmit = transmit; - } - - /** - * Stops Transmitter - */ - public void stop() { - this.transmit = false; - this.on = false; - } - - /** - * add new data to transfer. - * - * @param transferData - * new data to send - */ - public void sendFileData(JingleFileTransferData[] transferData) { - - addNewData(transferData); - transmit = true; - } - - private synchronized void transferData(OutputStream output, InputStream input) throws IOException{ - /* if no jobs in queue. */ - while(transferList.size() == 0){ - try { - wait(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - logger.debug("send transfer number : " - + transferList.size()); - output.write(transferList.size()); - - for (JingleFileTransferData data : transferList) { - - /* save current packet for error handling*/ - currentSending = data; - - /* send file meta data */ - logger.debug("send meta data for : " - + data.file_project_path); - sendMetaData(output, data); - - if (data.type == FileTransferType.FILELIST_TRANSFER) { - sendFileListData(output, - data.file_list_content); - /* - * if file list send, we expect remote file list to receive. - */ - receive = true; - transmit = false; - } - if (data.type == FileTransferType.RESOURCE_TRANSFER) { - logger.debug("send file : " - + data.file_project_path); - /* file has been send by meta data object. */ -// sendFile(output, data); - } - - } - - - /* remove from queue */ - transferList.clear(); - currentSending = null; - /* set monitor status complete :) */ -// monitor.setComplete(true); - - notifyAll(); - } - - /** - * add new transfer data to transfer queue - * - * @param transferData - */ - private synchronized void addNewData(JingleFileTransferData[] transferData){ - /* if job in queue. */ - while(transferList.size() > 0){ - try { - wait(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - /* add new jobs. */ - for(JingleFileTransferData d : transferData){ - this.transferList.add(d); - } - - notifyAll(); - } - - public void addJingleFileTransferListener( - IJingleFileTransferListener listener) { - this.listener = listener; - } - - public void removeJingleFileTransferListener( - IJingleFileTransferListener listener) { - this.listener = null; - - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ActivityRegistry.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ActivityRegistry.java deleted file mode 100644 index 0ba97e9446611530038a519e420ca48ce1160705..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ActivityRegistry.java +++ /dev/null @@ -1,85 +0,0 @@ -package de.fu_berlin.inf.dpp.project; - -import java.util.ArrayList; -import java.util.List; - -import org.xmlpull.v1.XmlPullParser; - -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.editor.EditorManager; -import de.fu_berlin.inf.dpp.project.internal.RoleManager; - -/** - * The activity registry holds references to all active activity providers and - * their activities. - * - * @author rdjemili - */ -public class ActivityRegistry { - private List<IActivityProvider> activityProviders = new ArrayList<IActivityProvider>(); - - private static ActivityRegistry instance; - - /** - * @return the singleton instance of this registry.. - */ - public static ActivityRegistry getDefault() { - if (instance == null) - instance = new ActivityRegistry(); - - return instance; - } - - public void addProvider(IActivityProvider provider) { - if (!activityProviders.contains(provider)) - activityProviders.add(provider); - } - - /** - * Converts given XML data into an activity. - */ - public IActivity parseActivity(XmlPullParser parser) { - IActivity activity = null; - for (IActivityProvider provider : activityProviders) { - activity = provider.fromXML(parser); - - if (activity != null) - return activity; - } - - return null; - } - - /** - * Converts given activity into a XML format. - */ - public String toXML(IActivity activity) { - String xml; - for (IActivityProvider provider : activityProviders) { - xml = provider.toXML(activity); - - if (xml != null) - return xml; - } - - return null; - } - - /** - * Singleton constructor - */ - private ActivityRegistry() { - loadDefaultActivityProviders(); - loadExtensionPoints(); - } - - private void loadDefaultActivityProviders() { - addProvider(EditorManager.getDefault()); - addProvider(new SharedResourcesManager()); - addProvider(new RoleManager()); - } - - private void loadExtensionPoints() { - // TODO load activity providers from the extension-point for Saros - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/IActivityListener.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/IActivityListener.java deleted file mode 100644 index 06c4588a74743312b1d3b0dd87d7209e1cab06e2..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/IActivityListener.java +++ /dev/null @@ -1,7 +0,0 @@ -package de.fu_berlin.inf.dpp.project; - -import de.fu_berlin.inf.dpp.activities.IActivity; - -public interface IActivityListener { - public void activityCreated(IActivity activity); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/IActivityManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/IActivityManager.java deleted file mode 100644 index 08e667e31dd6822d30ce7d2d7396e352785aaa34..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/IActivityManager.java +++ /dev/null @@ -1,15 +0,0 @@ -package de.fu_berlin.inf.dpp.project; - -import java.util.List; - -import de.fu_berlin.inf.dpp.activities.IActivity; - -public interface IActivityManager { - public void addProvider(IActivityProvider provider); - - public void removeProvider(IActivityProvider provider); - - public List<IActivity> flush(); - - public void exec(IActivity activity); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/IActivityProvider.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/IActivityProvider.java deleted file mode 100644 index 56cd57b8b98687539cd9bdc01223c664418c1a86..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/IActivityProvider.java +++ /dev/null @@ -1,29 +0,0 @@ -package de.fu_berlin.inf.dpp.project; - -import org.xmlpull.v1.XmlPullParser; - -import de.fu_berlin.inf.dpp.activities.IActivity; - -/** - * Every activity provider is responsible for one or more activities. It handles - * creating and executing the activity. - * - * @author rdjemili - */ -public interface IActivityProvider extends ISessionListener { - public void exec(IActivity activity); - - public void addActivityListener(IActivityListener listener); - - public void removeActivityListener(IActivityListener listener); - - /** - * Converts the XML doc to an activity. - */ - public IActivity fromXML(XmlPullParser parser); - - /** - * Converts the given activity to a XML format. - */ - public String toXML(IActivity activity); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISessionListener.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISessionListener.java deleted file mode 100644 index ff0847601dca0f54d7364aa43d8f3dbf2647e87a..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISessionListener.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.project; - -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; - -/** - * A listener for SharedProject life-cycle related events. - * - * @author rdjemili - */ -public interface ISessionListener { - - /** - * Is fired when a new session started. - * - * @param session - * the shared project that has been created. Is never - * <code>null</code>. - * - */ - public void sessionStarted(ISharedProject session); - - /** - * Is fired when a session ended. Reasons for this can be that the session - * was closed or that the user left by himself. - * - * @param session - * the shared project that has just been left. Is never - * <code>null</code>. - */ - public void sessionEnded(ISharedProject session); - - /** - * Is fired when the local user is invited to a session. Use - * {@link SessionManager#acceptSessionInvitation(JID, String, - * org.eclipse.core.resources.IProject)} to accept the invitation. - * - * @param process - * the invitation process which represents the invitation. - */ - public void invitationReceived(IIncomingInvitationProcess invitation); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISessionManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISessionManager.java deleted file mode 100644 index 87dcbf5bec651e737ec547d06678ffeaea231636..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISessionManager.java +++ /dev/null @@ -1,98 +0,0 @@ -package de.fu_berlin.inf.dpp.project; - -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; - -import de.fu_berlin.inf.dpp.Saros.ConnectionState; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; - -public interface ISessionManager { - - /** - * Starts a new shared project with the local user as only participant. - * - * @param project - * the local Eclipse project which should become shared. - * @throws XMPPException - * if this method is called with no established XMPP-connection. - */ - public abstract void startSession(IProject project) throws XMPPException; - - /** - * Joins an remotly already running shared project. - * - * @param project - * the local Eclipse project which should be used to replicate - * the remote shared project. - * @param host - * the host of the remotly shared project. - * @param driver - * the driver of the shared project. - * @param users - * the participants of the shared project. - * @return the shared project. - */ - public abstract ISharedProject joinSession(IProject project, JID host, - JID driver, List<JID> users); - - /** - * Leaves the currently active session. If the local user is the host, this - * will close the session for everybody. - * - * Has no effect if there is no currently shared project. - */ - public abstract void leaveSession(); - - /** - * @return the active SharedProject object or <code>null</code> if there - * is no active project. - */ - public abstract ISharedProject getSharedProject(); - - /** - * Add the given session listener. Is ignored if the listener is already - * listening. - * - * @param listener - * the listener that is to be added. - */ - public abstract void addSessionListener(ISessionListener listener); - - /** - * Removes the given session listener. Is ignored if the given listener - * wasn't listening. - * - * @param listener - * the listener that is to be removed. - */ - public abstract void removeSessionListener(ISessionListener listener); - - /** - * Is fired when an incoming invitation is received. - * - * @param from - * the sender of this invitation. - * @param description - * the informal description text that can be given with - * invitations. - * @return the process that represents the invitation and which handles the - * further interaction with the invitation. - */ - public abstract IIncomingInvitationProcess invitationReceived(JID from, - String projectName, String description); - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.IConnectionListener - */ - public abstract void connectionStateChanged(XMPPConnection connection, - ConnectionState newState); - - public abstract void OnReconnect(int oldtimestamp); - -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISharedProject.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISharedProject.java deleted file mode 100644 index 5a88b3f42f81ed0fa9c782f0c8b83a16ddee755e..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISharedProject.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.project; - -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; - -import de.fu_berlin.inf.dpp.FileList; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.invitation.IOutgoingInvitationProcess; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess.IInvitationUI; -import de.fu_berlin.inf.dpp.net.IActivitySequencer; -import de.fu_berlin.inf.dpp.net.JID; - -/** - * Shared projects are the central concept of this plugin. They are associated - * with usual Eclipse projects and make them available for synchronous/real-time - * collaboration. - * - * @author rdjemili - */ -public interface ISharedProject { - - /** - * @return a list of all participants of the shared project. This list - * includes yourself. - */ - public List<User> getParticipants(); - - /** - * Sets the new driver. If given driver is already driver the call is - * ignored. - * - * @param driver - * the new driver. - * @param replicated - * <code>false</code> if this event was created by this client. - * <code>true</code> if it was created by another client and - * only replicated to this client. - */ - public void setDriver(User driver, boolean replicated); - - /** - * Remove driver role for given User. - * - * @param driver - * one current driver. - * @param replicated - * <code>false</code> if this event was created by this client. - * <code>true</code> if it was created by another client and - * only replicated to this client. - */ - public void removeDriver(User driver, boolean replicated); - - /** - * The driver is the person that is currently allowed to edit the resources. - * - * @return the driver. - */ - public User getDriver(); - - /** - * @return <code>true</code> if the local client is the current driver of - * this shared project. <code>false</code> otherwise. - */ - public boolean isDriver(); - - /** - * @return <code>true</code> if the given user is one of the current driver of - * this shared project. <code>false</code> otherwise. - */ - public boolean isDriver(User user); - - /** - * The host is the person that initiated this SharedProject and holds all - * original files. - * - * @return the host. - */ - public User getHost(); - - /** - * @return <code>true</code> if the local client is the host of this - * shared project. <code>false</code> otherwise. - */ - public boolean isHost(); - - /** - * Adds the user. - * - * @param user - * the user that is to be added. - */ - public void addUser(User user); - public void addUser(User user, int index); - - /** - * Removes the user. - * - * @param user - * the user that is to be removed. - */ - public void removeUser(User user); - - /** - * Invites a user to the shared project. - * - * @param jid - * the JID of the user that is to be invited. - * @param description - * a description that will be shown to the invited user before he - * makes the decision to accept or decline the invitation. - * @param inviteUI - * user interface of the invitation for feedback calls. - * @return the outgoing invitation process. - */ - public IOutgoingInvitationProcess invite(JID jid, String description, boolean inactive, IInvitationUI inviteUI); - - /** - * Adds the given shared project listener. This call is ignored if the - * listener is all a listener of this shared project. - * - * @param listener - * The listener that is to be added. - */ - public void addListener(ISharedProjectListener listener); - - /** - * Removes the given shared project listener. This call is ignored if the - * listener doesn't belongs to the current listeners of this shared project. - * - * @param listener - * the listener that is to be removed. - */ - public void removeListener(ISharedProjectListener listener); - - /** - * @return the Eclipse project associtated with this shared project. This - * never returns <code>null</code>. - */ - public IProject getProject(); - - /** - * @return the file list representation of the Eclipse project that is - * associated with this shared project. - * @throws CoreException - * if there are problems while reading file tree of the Eclipse - * project. - */ - public FileList getFileList() throws CoreException; - - // TODO remove direct uses of FileList - - /** - * @return the sequencer that is responsible for sending and receiving - * activities. - */ - public IActivitySequencer getSequencer(); - - /** - * @return the activity manager that is responsible for all activity - * providers. - */ - public IActivityManager getActivityManager(); - - /** - * Starts the invitation wizard to invite users. - * @param jid - * the JID of a user to invite without manual selection - */ - public void startInvitation(JID jid); - - /** - * Activates sending of activities. The reason that this isn't done - * automatically are unit tests. - */ - public void start(); - - /** - * Deactivates sending of activities. - */ - public void stop(); - - public User getParticipant(JID jid); - - /** - * Sets all resources of the project to a readonly state - * on the local file system. - * @param The readonly state to set the file to. - */ - public void setProjectReadonly(boolean readonly); - - /** - * true, if single driver is active, false otherwise. - * @return - */ - public boolean exclusiveDriver(); -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISharedProjectListener.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISharedProjectListener.java deleted file mode 100644 index e385a80a12f0a98b0bc586a32a7a4c9f17f415cf..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISharedProjectListener.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.project; - -import de.fu_berlin.inf.dpp.net.JID; - -/** - * Listens for events that can happen inside a SharedProject session. For - * life-cycle events like starts and ends of shared projects use the - * {@link ISessionListener}. - * - * @author rdjemili - */ -public interface ISharedProjectListener { - // TODO add some easy way to check if given driver is the client (you) - - /** - * The driver role of one participant has changed. - * - * @param driver - * the new driver. - * - * @param replicated - * <code>false</code> if this event was created by this client. - * <code>true</code> if it was created by another client and - * only replicated to this client. - */ - public void driverChanged(JID driver, boolean replicated); - - /** - * The driver role of one participant has changed. - * - * @param driver - * the new driver. - * - * @param replicated - * <code>false</code> if this event was created by this client. - * <code>true</code> if it was created by another client and - * only replicated to this client. - */ -// public void driverAdded(JID driver, boolean replicated); - - /** - * Is fired when an user joins the shared project. - * - * @param user - * the user that has joined. - */ - public void userJoined(JID user); - - /** - * Is fired when an user leaves the shared project. - * - * @param user - * the user that has left. - */ - public void userLeft(JID user); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/SessionManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/SessionManager.java deleted file mode 100644 index 9f3da0ca7694ce06519bdd478f7a3ebfd7e03705..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/SessionManager.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.project; - -import java.util.Collection; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.logging.Logger; - -import org.eclipse.core.resources.IProject; -import org.jivesoftware.smack.Roster; -import org.jivesoftware.smack.RosterListener; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.packet.Presence; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.Saros.ConnectionState; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.invitation.internal.IncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.IConnectionListener; -import de.fu_berlin.inf.dpp.net.ITransmitter; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.net.internal.XMPPChatTransmitter; -import de.fu_berlin.inf.dpp.project.internal.SharedProject; - -/** - * The SessionManager is responsible for initiating new Saros sessions and for - * reacting to invitiations. The user can be only part of one session at most. - * - * @author rdjemili - */ -public class SessionManager implements IConnectionListener, ISessionManager { - private static Logger log = Logger.getLogger(SessionManager.class.getName()); - - private SharedProject sharedProject; - - // TODO use ListenerList instead - private List<ISessionListener> listeners = new CopyOnWriteArrayList<ISessionListener>(); - - ITransmitter transmitter; - - public SessionManager() { - Saros.getDefault().addListener(this); - } - - /* (non-Javadoc) - * @see de.fu_berlin.inf.dpp.project.ISessionManager#startSession(org.eclipse.core.resources.IProject) - */ - public void startSession(IProject project) throws XMPPException { - if (!Saros.getDefault().isConnected()) { - throw new XMPPException("No connection"); - } - - JID myJID = Saros.getDefault().getMyJID(); - sharedProject = new SharedProject(transmitter, project, myJID); - sharedProject.start(); - - for (ISessionListener listener : listeners) { - listener.sessionStarted(sharedProject); - } - - sharedProject.startInvitation(null); - - log.info("Session started"); - } - - /* (non-Javadoc) - * @see de.fu_berlin.inf.dpp.project.ISessionManager#joinSession(org.eclipse.core.resources.IProject, de.fu_berlin.inf.dpp.net.JID, de.fu_berlin.inf.dpp.net.JID, java.util.List) - */ - public ISharedProject joinSession(IProject project, JID host, JID driver, List<JID> users) { - - sharedProject = new SharedProject(transmitter, project, Saros.getDefault().getMyJID(), - host, driver, users); - sharedProject.start(); - - for (ISessionListener listener : listeners) { - listener.sessionStarted(sharedProject); - } - - log.info("Session joined"); - - return sharedProject; - } - - /* (non-Javadoc) - * @see de.fu_berlin.inf.dpp.project.ISessionManager#leaveSession() - */ - public void leaveSession() { - if (sharedProject == null) - return; - - transmitter.sendLeaveMessage(sharedProject); - sharedProject.setProjectReadonly(false); // set ressources writeable again - - sharedProject.stop(); - - ISharedProject closedProject = sharedProject; - sharedProject = null; - - for (ISessionListener listener : listeners) { - listener.sessionEnded(closedProject); - } - - log.info("Session left"); - } - - /* (non-Javadoc) - * @see de.fu_berlin.inf.dpp.project.ISessionManager#getSharedProject() - */ - public ISharedProject getSharedProject() { - return sharedProject; - } - - /* (non-Javadoc) - * @see de.fu_berlin.inf.dpp.project.ISessionManager#addSessionListener(de.fu_berlin.inf.dpp.project.ISessionListener) - */ - public void addSessionListener(ISessionListener listener) { - if (!listeners.contains(listener)) { - listeners.add(listener); - } - } - - /* (non-Javadoc) - * @see de.fu_berlin.inf.dpp.project.ISessionManager#removeSessionListener(de.fu_berlin.inf.dpp.project.ISessionListener) - */ - public void removeSessionListener(ISessionListener listener) { - listeners.remove(listener); - } - - /* (non-Javadoc) - * @see de.fu_berlin.inf.dpp.project.ISessionManager#invitationReceived(de.fu_berlin.inf.dpp.net.JID, java.lang.String, java.lang.String) - */ - public IIncomingInvitationProcess invitationReceived(JID from, String projectName, - String description) { - - IIncomingInvitationProcess process = new IncomingInvitationProcess(transmitter, from, - projectName, description); - - for (ISessionListener listener : listeners) { - listener.invitationReceived(process); - } - - log.info("Received invitation"); - - return process; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.IConnectionListener - */ - /* (non-Javadoc) - * @see de.fu_berlin.inf.dpp.project.ISessionManager#connectionStateChanged(org.jivesoftware.smack.XMPPConnection, de.fu_berlin.inf.dpp.Saros.ConnectionState) - */ - public void connectionStateChanged(XMPPConnection connection, - ConnectionState newState) { - - if (newState == Saros.ConnectionState.CONNECTED) { - if (transmitter == null) { - transmitter = new XMPPChatTransmitter(connection); - attachRosterListener(); - } else { - // TODO: Does this ever happen? - transmitter.setXMPPConnection(connection); - } - - } else if (newState == Saros.ConnectionState.NOT_CONNECTED) { - if (sharedProject != null) - leaveSession(); - - transmitter = null; - } - } - - private void attachRosterListener() { - Roster roster = Saros.getDefault().getRoster(); - roster.addRosterListener(new RosterListener() { - public void entriesAdded(Collection<String> addresses) { - } - - public void entriesUpdated(Collection<String> addresses) { - } - - public void entriesDeleted(Collection<String> addresses) { - } - - public void presenceChanged(String XMPPAddress) { - - if (sharedProject==null) - return; - - Roster roster = Saros.getDefault().getRoster(); - Presence presence = roster.getPresence(XMPPAddress); - - JID jid = new JID(XMPPAddress); - User user = sharedProject.getParticipant(jid); - if (user!=null){ - if (presence==null) { - user.setPresence( User.UserConnectionState.OFFLINE); - - } else - user.setPresence( User.UserConnectionState.ONLINE ); - } - } - - - public void presenceChanged(Presence presence) { - //TODO: new Method for Smack 3 - presenceChanged(presence.getFrom()); - - } - - }); - } - - /* (non-Javadoc) - * @see de.fu_berlin.inf.dpp.project.ISessionManager#OnReconnect(int) - */ - public void OnReconnect(int oldtimestamp){ - - if (sharedProject==null) - return; - - transmitter.sendRemainingFiles(); - transmitter.sendRemainingMessages(); - - // ask for next expected timestamp activities (in case I missed something while being not available) - transmitter.sendRequestForActivity( sharedProject, oldtimestamp, true ); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/SharedResourcesManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/SharedResourcesManager.java deleted file mode 100644 index bc3a33842697638c77d5e24bea106ebd173825ef..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/SharedResourcesManager.java +++ /dev/null @@ -1,372 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.project; - -import java.io.IOException; -import java.io.InputStream; -import java.util.LinkedList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectNature; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.activities.FileActivity; -import de.fu_berlin.inf.dpp.activities.FolderActivity; -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.editor.EditorManager; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; - -/** - * This manager is responsible for handling all resource changes that aren't - * handled by the EditorManager, that is for changes that aren't done by - * entering text in an text editor. It creates and executes file activities and - * folder activities. - * - * @author rdjemili - */ -public class SharedResourcesManager implements IResourceChangeListener, IActivityProvider { - - private static Logger log = Logger.getLogger(SharedResourcesManager.class.getName()); - - /** - * Should be set to <code>true</code> while executing resource changes to - * avoid an infinite resource event loop. - */ - private boolean replicationInProgess = false; - - private ISharedProject sharedProject; - - private ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(); - - private List<IActivityListener> listeners = new LinkedList<IActivityListener>(); - - /** - * Listens for resource changes in shared project and fires activities. - */ - private class ResourceDeltaVisitor implements IResourceDeltaVisitor { - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.resources.IResourceDeltaVisitor - */ - public boolean visit(IResourceDelta delta) { - assert sharedProject != null; - - if (replicationInProgess || !sharedProject.isDriver()) - return false; - - IResource resource = delta.getResource(); - if (resource.getProject() == null) // work space root - return true; - - if (resource.getProject() != sharedProject.getProject()) - return false; - - if (resource.isDerived()) - return false; - - IPath path = delta.getProjectRelativePath(); - int kind = delta.getKind(); - - IActivity activity = null; - if (resource instanceof IFile) { - activity = handleFileDelta(path, kind); - - } else if (resource instanceof IFolder) { - activity = handleFolderDelta(path, kind); - } - - fireActivity(activity); - closeRemovedEditors(); - - return delta.getKind() > 0; - } - - private IActivity handleFolderDelta(IPath path, int kind) { - switch (kind) { - case IResourceDelta.ADDED: - return new FolderActivity(FolderActivity.Type.Created, path); - - case IResourceDelta.REMOVED: - return new FolderActivity(FolderActivity.Type.Removed, path); - - default: - return null; - } - } - - private IActivity handleFileDelta(IPath path, int kind) { - switch (kind) { - case IResourceDelta.CHANGED: - case IResourceDelta.ADDED: - // ignore opened files because otherwise we might send CHANGED - // events for files that are also handled by the editor manager. - if (EditorManager.getDefault().isOpened(path)) - return null; - - // fall through - - return new FileActivity(FileActivity.Type.Created, path); - - case IResourceDelta.REMOVED: - return new FileActivity(FileActivity.Type.Removed, path); - - default: - return null; - } - } - - private void fireActivity(IActivity activity) { - if (activity == null) - return; - - for (IActivityListener listener : listeners) - listener.activityCreated(activity); - } - } - - public SharedResourcesManager() { - Saros.getDefault().getSessionManager().addSessionListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - sharedProject = session; - sharedProject.getActivityManager().addProvider(this); - ResourcesPlugin.getWorkspace().addResourceChangeListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); - sharedProject.getActivityManager().removeProvider(this); - sharedProject = null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess invitation) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityProvider - */ - public void addActivityListener(IActivityListener listener) { - if (!listeners.contains(listener)) { - listeners.add(listener); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityProvider - */ - public void removeActivityListener(IActivityListener listener) { - listeners.remove(listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.resources.IResourceChangeListener - */ - public void resourceChanged(IResourceChangeEvent event) { - try { - event.getDelta().accept(visitor); - } catch (CoreException e) { - log.log(Level.SEVERE, "Couldn't handle resource change.", e); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityProvider - */ - public void exec(IActivity activity) { - try { - replicationInProgess = true; - - if (activity instanceof FileActivity) - exec((FileActivity) activity); - - else if (activity instanceof FolderActivity) - exec((FolderActivity) activity); - - } catch (CoreException e) { - log.log(Level.SEVERE, "Failed to execute resource activity.", e); - - } finally { - replicationInProgess = false; - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.IActivityProvider - */ - public IActivity fromXML(XmlPullParser parser) { - try { - if (parser.getName().equals("file")) { - return parseFile(parser); - - } else if (parser.getName().equals("folder")) { - return parseFolder(parser); - } - - } catch (IOException e) { - log.severe("Couldn't parse message"); - } catch (XmlPullParserException e) { - log.severe("Couldn't parse message"); - } - - return null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.IActivityProvider - */ - public String toXML(IActivity activity) { - if (activity instanceof FileActivity) { - FileActivity fileActivity = (FileActivity) activity; - return "<file " + "path=\"" + fileActivity.getPath() + "\" " + "type=\"" - + fileActivity.getType() + "\" />"; - - } else if (activity instanceof FolderActivity) { - FolderActivity folderActivity = (FolderActivity) activity; - return "<folder " + "path=\"" + folderActivity.getPath() + "\" " + "type=\"" - + folderActivity.getType() + "\" />"; - } - - return null; - } - - private void exec(FileActivity activity) throws CoreException { - IProject project = sharedProject.getProject(); - IFile file = project.getFile(activity.getPath()); - - if (activity.getType() == FileActivity.Type.Created) { - InputStream in = activity.getContents(); - if (file.exists()) { - file.setContents(in, IResource.FORCE, null); - } else { - file.create(in, true, new NullProgressMonitor()); - } - - } else if (activity.getType() == FileActivity.Type.Removed) { - file.delete(false, new NullProgressMonitor()); - } - - closeRemovedEditors(); - } - - private void exec(FolderActivity activity) throws CoreException { - IProject project = sharedProject.getProject(); - IFolder folder = project.getFolder(activity.getPath()); - - if (activity.getType() == FolderActivity.Type.Created) { - folder.create(true, true, new NullProgressMonitor()); - } else if (activity.getType() == FolderActivity.Type.Removed) { - folder.delete(true, new NullProgressMonitor()); - } - } - - private FileActivity parseFile(XmlPullParser parser) throws XmlPullParserException, IOException { - - IPath path = new Path(parser.getAttributeValue(null, "path")); - return new FileActivity(FileActivity.Type.valueOf(parser.getAttributeValue(null, "type")), - path); - } - - private FolderActivity parseFolder(XmlPullParser parser) { - Path path = new Path(parser.getAttributeValue(null, "path")); - - return new FolderActivity(FolderActivity.Type.valueOf(parser - .getAttributeValue(null, "type")), path); - } - - /** - * Checks if given project is a Java project and returns the output location - * of that Java project. - * - * @param the - * project for which the output location should be fetched. - * @return the output location of given Java project. <code>null</code> if - * given project has no Java nature. - */ - private static IPath getJavaOutputLocation(IProject project) { - // we are using IResource#isDerived() instead. this should probably be - // removed - - try { - IProjectNature javaNature = project.getNature(JavaCore.NATURE_ID); - - IJavaProject javaProject = (IJavaProject) javaNature; - IPath path = javaProject.getOutputLocation(); - return path.removeFirstSegments(1); - - } catch (CoreException e) { - // ignore - not a Java project - return null; - } - } - - private void closeRemovedEditors() { - // TODO - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/internal/RoleManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/internal/RoleManager.java deleted file mode 100644 index f98f230ba732dd5ee43094a4d1ad8f5169f4f9aa..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/internal/RoleManager.java +++ /dev/null @@ -1,154 +0,0 @@ -package de.fu_berlin.inf.dpp.project.internal; - -import java.util.LinkedList; -import java.util.List; - -import org.xmlpull.v1.XmlPullParser; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.activities.RoleActivity; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.IActivityListener; -import de.fu_berlin.inf.dpp.project.IActivityProvider; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; - -/** - * This manager is responsible for handling driver changes. - * - * @author rdjemili - */ -public class RoleManager implements IActivityProvider, ISharedProjectListener { - private List<IActivityListener> activityListeners = new LinkedList<IActivityListener>(); - - private ISharedProject sharedProject; - - public RoleManager() { - Saros.getDefault().getSessionManager().addSessionListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - sharedProject = session; - sharedProject.addListener(this); - sharedProject.getActivityManager().addProvider(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - sharedProject.removeListener(this); - sharedProject.getActivityManager().removeProvider(this); - sharedProject = null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess invitation) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityProvider - */ - public void addActivityListener(IActivityListener listener) { - activityListeners.add(listener); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityProvider - */ - public void removeActivityListener(IActivityListener listener) { - activityListeners.remove(listener); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityProvider - */ - public void exec(IActivity activity) { - if (activity instanceof RoleActivity) { - RoleActivity roleActivity = (RoleActivity) activity; - User user = sharedProject.getParticipant(roleActivity.getDriver()); - sharedProject.setDriver(user, true); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProjectListener - */ - public void driverChanged(JID driver, boolean replicated) { - if (!replicated) { - IActivity activity = new RoleActivity(driver); - for (IActivityListener listener : activityListeners) { - listener.activityCreated(activity); - } - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProjectListener - */ - public void userJoined(JID user) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProjectListener - */ - public void userLeft(JID user) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.IActivityProvider - */ - public IActivity fromXML(XmlPullParser parser) { - if (parser.getName().equals("driver")) { - JID user = new JID(parser.getAttributeValue(null, "id")); - return new RoleActivity(user); - } - - return null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.IActivityProvider - */ - public String toXML(IActivity activity) { - if (activity instanceof RoleActivity) { - RoleActivity roleActivity = (RoleActivity) activity; - return "<driver id=\"" + roleActivity.getDriver() + "\" />"; - } - - return null; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/internal/SharedModelProvider.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/internal/SharedModelProvider.java deleted file mode 100644 index 9ea2b360cc0a141a5f4dea677622d9d977dbc9d9..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/internal/SharedModelProvider.java +++ /dev/null @@ -1,137 +0,0 @@ -package de.fu_berlin.inf.dpp.project.internal; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.mapping.ModelProvider; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISessionManager; -import de.fu_berlin.inf.dpp.project.ISharedProject; - -/** - * This model provider is responsible for keeping an session observer from - * modifying the file tree of a shared project on his own. - * - * @author rdjemili - */ -public class SharedModelProvider extends ModelProvider implements - ISessionListener { - - private static final String ERROR_TEXT = "Only the driver should edit the resources of this shared project."; - private static final String EXCLUSIVE_ERROR_TEXT = "The project host should be the exclusive driver to edit resources of this shared project."; - - private static final IStatus ERROR_STATUS = new Status(IStatus.ERROR, - "de.fu_berlin.inf.dpp", 2, ERROR_TEXT, null); - - private static final IStatus EXCLUSIVE_ERROR_STATUS = new Status(IStatus.ERROR, - "de.fu_berlin.inf.dpp", 2, EXCLUSIVE_ERROR_TEXT, null); - - /** the currently running shared project */ - private ISharedProject sharedProject; - - public SharedModelProvider() { - - } - - /** - * Validates the resource delta. - */ - private class ResourceDeltaVisitor implements IResourceDeltaVisitor { - private boolean isAllowed = true; - private boolean isExclusive = true; - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.resources.IResourceDeltaVisitor - */ - public boolean visit(IResourceDelta delta) throws CoreException { - if (sharedProject == null || sharedProject.isDriver()) { - /* check driver status */ - if (!(sharedProject.isHost() && sharedProject.exclusiveDriver())){ - isExclusive = false; - } - return false; - } - - IResource resource = delta.getResource(); - if (resource.getProject() == null) // work space root - return true; - - if (resource.getProject() != sharedProject.getProject()) - return false; - - if (resource instanceof IFile || resource instanceof IFolder) { - isAllowed = false; - return false; - } - - return delta.getKind() > 0; - } - } - - @Override - protected void initialize() { - ISessionManager sm = Saros.getDefault().getSessionManager(); - - sm.addSessionListener(this); - sharedProject = sm.getSharedProject(); - } - - @Override - public IStatus validateChange(IResourceDelta delta, IProgressMonitor pm) { - ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(); - - try { - delta.accept(visitor); - } catch (CoreException e) { - e.printStackTrace(); - } - - IStatus result = Status.OK_STATUS; - if(!visitor.isAllowed){ - result = ERROR_STATUS; - } - if(!visitor.isExclusive){ - result = EXCLUSIVE_ERROR_STATUS; - } - return result; -// return visitor.isAllowed ? Status.OK_STATUS : ERROR_STATUS; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - sharedProject = session; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - sharedProject = null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess invitation) { - // ignore - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/internal/SharedProject.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/internal/SharedProject.java deleted file mode 100644 index 3976766b915dbb4c9303cbdbc3110344cb5e9f7a..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/internal/SharedProject.java +++ /dev/null @@ -1,735 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.project.internal; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; -import java.util.Timer; -import java.util.TimerTask; - -import org.apache.log4j.Logger; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourceAttributes; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -import de.fu_berlin.inf.dpp.FileList; -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.User.UserRole; -import de.fu_berlin.inf.dpp.concurrent.ConcurrentManager; -import de.fu_berlin.inf.dpp.concurrent.IDriverDocumentManager; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.management.DriverDocumentManager; -import de.fu_berlin.inf.dpp.invitation.IOutgoingInvitationProcess; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess.IInvitationUI; -import de.fu_berlin.inf.dpp.invitation.internal.OutgoingInvitationProcess; -import de.fu_berlin.inf.dpp.net.IActivitySequencer; -import de.fu_berlin.inf.dpp.net.ITransmitter; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.net.TimedActivity; -import de.fu_berlin.inf.dpp.net.internal.ActivitySequencer; -import de.fu_berlin.inf.dpp.project.IActivityManager; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; -import de.fu_berlin.inf.dpp.ui.InvitationDialog; - -public class SharedProject implements ISharedProject { - private static Logger log = Logger.getLogger(SharedProject.class.getName()); - - private static final int REQUEST_ACTIVITY_ON_AGE = 5; - protected static final int MILLIS_UPDATE = 1000; - - protected JID myID; - - protected List<User> participants = new ArrayList<User>(); - - private IProject project; - - private List<ISharedProjectListener> listeners = new ArrayList<ISharedProjectListener>(); - - private User driver; - - private User host; - - private final ITransmitter transmitter; - - private IDriverDocumentManager driverManager; - - private ActivitySequencer activitySequencer = new ActivitySequencer(); - - private static final int MAX_USERCOLORS = 5; - private int colorlist[] = new int[MAX_USERCOLORS + 1]; - - // private ConcurrentManager concurrentManager; - - public SharedProject(ITransmitter transmitter, IProject project, JID myID) { // host - this.transmitter = transmitter; - - // concurrentManager = new ConcurrentDocumentManager(); - - this.myID = myID; - User u = new User(myID); - u.setUserRole(UserRole.DRIVER); - driver = host = u; - - participants.add(host); - - /* add host to driver list. */ - activitySequencer.initConcurrentManager( - ConcurrentManager.Side.HOST_SIDE, host, myID, this); - - /* init driver manager */ - driverManager = DriverDocumentManager.getInstance(); - this.addListener(driverManager); - driverManager.addDriver(host.getJid()); - -// activitySequencer.getConcurrentManager().addDriver(host.getJid()); - - this.project = project; - setProjectReadonly(false); - } - - public SharedProject(ITransmitter transmitter, IProject project, JID myID, // guest - JID host, JID driver, List<JID> allParticipants) { - - this.transmitter = transmitter; - - this.myID = myID; - - this.host = new User(host); - this.driver = new User(driver); - - activitySequencer.initConcurrentManager( - ConcurrentManager.Side.CLIENT_SIDE, this.host, myID, this); - - for (JID jid : allParticipants) { // HACK - User user = new User(jid); - participants.add(user); - assignColorId(user); - } - - this.project = project; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ISharedProject - */ - public List<User> getParticipants() { - return participants; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ISharedProject - */ - public IActivitySequencer getSequencer() { - return activitySequencer; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public IActivityManager getActivityManager() { - return activitySequencer; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ISharedProject - */ - public void setDriver(User driver, boolean replicated) { - assert driver != null; - - /* if user has current role observer */ - if (getParticipant(driver.getJid()).getUserRole() == UserRole.OBSERVER) { - - /* set new driver status in participant list of sharedProject. */ - getParticipant(driver.getJid()).setUserRole(UserRole.DRIVER); - - /* - * TODO: 1. actual the host never lost the driver status and added - * new driver to driverlist - */ - - // host - if (activitySequencer.getConcurrentManager() != null - && activitySequencer.getConcurrentManager().isHostSide()) { - // if replicated=false check for privileges - if (driver.equals(this.driver)) - return; - - /* add new driver to list. */ - // TODO: durch hinzufügen von isharedprojectlistener zum - // concurrentmanager - // könnte dieser punkt ausgelagert werden. -// activitySequencer.getConcurrentManager().addDriver(driver.getJid()); - } - // client - else { - // if replicated=false check for privileges - if (driver.equals(this.driver)) - return; - - /* - * set driver in client to observer driver actions or to set the - * local driver status. - */ - - /* currently, no other driver than host can be followed. */ -// this.driver = driver; - } - - // // TODO if replicated=false check for privileges - // if (driver.equals(this.driver)) - // return; - // - // this.driver = driver; - - /* set local file settings. */ - if(driver.getJid().equals(myID)){ - setProjectReadonly(!isDriver()); - } - - } else { - /* changed state form observer to driver */ - if (getParticipant(driver.getJid()).getUserRole() == UserRole.DRIVER) { - - /* set the local driver state to observer */ - if (driver.getJid().equals(myID) && isDriver(new User(myID))) { - setProjectReadonly(true); - this.driver = host; - } - - /* set observer state. */ - getParticipant(driver.getJid()).setUserRole(UserRole.OBSERVER); - - } - } - - /* inform observer. */ - JID jid = driver.getJid(); - for (ISharedProjectListener listener : listeners) { - listener.driverChanged(jid, replicated); - } - } - - - public void removeDriver(User driver, boolean replicated) { - /* set new observer status in participant list of sharedProject. */ - getParticipant(driver.getJid()).setUserRole(UserRole.OBSERVER); - - this.driver = host; - /** - * communicate driver role change to listener. - */ - JID jid = driver.getJid(); - for (ISharedProjectListener listener : listeners) { - listener.driverChanged(jid, replicated); - } - - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ISharedProject - */ - public User getDriver() { - return driver; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ISharedProject - */ - public boolean isDriver() { - // TODO: change driver status request to userrole request of - // participient list. - - // HOST - /* TODO: change to driver document manager. */ -// if (activitySequencer.getConcurrentManager() != null -// && activitySequencer.getConcurrentManager().isHostSide()) { -// return activitySequencer.getConcurrentManager().isDriver(driver.getJid()); -// } - // CLIENT - return (getParticipant(myID).getUserRole() == UserRole.DRIVER); -// return driver.getJid().equals(myID); - - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject#isDriver(de.fu_berlin.inf.dpp.User) - */ - public boolean isDriver(User user) { - //HOST - if(driverManager != null){ - return driverManager.isDriver(user.getJid()); - } - //CLIENT - if (getParticipant(user.getJid()).getUserRole() == UserRole.DRIVER) { - return true; - } - return false; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ISharedProject - */ - public User getHost() { - return host; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public boolean isHost() { - return host.getJid().equals(myID); - } - - /* - * (non-Javadoc) - * @see de.fu_berlin.inf.dpp.project.ISharedProject#exclusiveDriver() - */ - public boolean exclusiveDriver(){ - return driverManager.exclusiveDriver(); - } - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public void addUser(User user) { - addUser(user, -1); - } - - public void addUser(User user, int index) { - if (participants.contains(user)) { - if (index >= 0 && participants.indexOf(user) != index) { - participants.remove(user); - participants.add(index, user); - } - /* update exists user. */ - participants.remove(user); - participants.add(user); - for (ISharedProjectListener listener : listeners) { - listener.userJoined(user.getJid()); - } - return; - } - - participants.add(user); - - // find free color and assign it to user - assignColorId(user); - - for (ISharedProjectListener listener : listeners) { - listener.userJoined(user.getJid()); - } - - log.info("User " + user.getJid() + " joined session"); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public void removeUser(User user) { - participants.remove(user); - - // free colorid - colorlist[user.getColorID()] = 0; - - if (driver.equals(user)) { - setDriver(participants.get(0), true); - } - - for (ISharedProjectListener listener : listeners) { - listener.userLeft(user.getJid()); - } - - log.info("User " + user.getJid() + " left session"); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public IOutgoingInvitationProcess invite(JID jid, String description, - boolean inactive, IInvitationUI inviteUI) { - return new OutgoingInvitationProcess(transmitter, jid, this, - description, inactive, inviteUI); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public void addListener(ISharedProjectListener listener) { - if (!listeners.contains(listener)) { - listeners.add(listener); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public void removeListener(ISharedProjectListener listener) { - listeners.remove(listener); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public IProject getProject() { - return project; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public FileList getFileList() throws CoreException { - return new FileList(project); - } - - public Timer flushTimer = new Timer(true); - public Thread requestTransmitter = null; - private static int queuedsince = 0; - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public void start() { - - flushTimer.schedule(new TimerTask() { - @Override - public void run() { - if (participants.size() <= 1) { - activitySequencer.flush(); - - } else { - List<TimedActivity> activities = activitySequencer - .flushTimed(); - - if (activities != null) - transmitter.sendActivities(SharedProject.this, - activities); - } - - // missing activities? (cant execute all) - if (activitySequencer.getQueuedActivities() > 0) { - queuedsince++; - - // if i am missing activities for REQUEST_ACTIVITY_ON_AGE - // seconds, ask all (because I dont know the origin) - // to send it to me again. - if (queuedsince >= REQUEST_ACTIVITY_ON_AGE) { - - transmitter.sendRequestForActivity(SharedProject.this, - activitySequencer.getTimestamp(), false); - - queuedsince = 0; - - // TODO: forever? - } - - } else - queuedsince = 0; - } - }, 0, MILLIS_UPDATE); - - /* 2. start thread for sending jupiter requests. */ - requestTransmitter = new Thread(new Runnable() { - - public void run() { - while (true) { - sendRequest(); - } - - } - - }); - requestTransmitter.start(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public void stop() { - flushTimer.cancel(); - requestTransmitter = null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public User getParticipant(JID jid) { - for (User participant : participants) { - if (participant.getJid().equals(jid)) { - return participant; - } - } - - return null; - } - - boolean assignColorId(User user) { - - // already has a color assigned - if (user.getColorID() == -1) - return true; - - for (int i = 0; i < MAX_USERCOLORS; i++) { - if (colorlist[i] == 0) { - user.setColorID(i); - colorlist[user.getColorID()] = 1; - return true; - } - } - - return false; - } - - public void startInvitation(final JID jid) { - - Shell shell = Display.getDefault().getActiveShell(); - - if (searchUnsavedChangesInProject(false)) { - if (MessageDialog - .openQuestion( - shell, - "Unsaved file modifications", - "Before inviting users and therefore synchronizing files, " - + "this project needs to be saved to disk. " - + "Do you want to save all unsaved files of this project now?")) { - - // save - // PlatformUI.getWorkbench().saveAllEditors(false); // saves all - // editors - searchUnsavedChangesInProject(true); - - } else - return; - } - - Display.getDefault().asyncExec(new Runnable() { - public void run() { - try { - Shell shell = Display.getDefault().getActiveShell(); - Window iw = new InvitationDialog(shell, jid); - iw.open(); - } catch (Exception e) { - Saros - .getDefault() - .getLog() - .log( - new Status( - IStatus.ERROR, - Saros.SAROS, - IStatus.ERROR, - "Error while running invitation helper", - e)); - } - } - }); - - } - - boolean searchUnsavedChangesInProject(boolean save) { - FileList flist = null; - - try { - flist = new FileList(getProject()); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return false; - } - - try { - IWorkbenchWindow[] wbWindows = PlatformUI.getWorkbench() - .getWorkbenchWindows(); - for (IWorkbenchWindow window : wbWindows) { - IWorkbenchPage activePage = window.getActivePage(); - IEditorReference[] editorRefs = activePage - .getEditorReferences(); - for (IEditorReference editorRef : editorRefs) { - if (editorRef.isDirty() - && editorRef.getEditorInput() instanceof IFileEditorInput) { - - IPath fp = ((IFileEditorInput) editorRef - .getEditorInput()).getFile() - .getProjectRelativePath(); - - // is that dirty file in my project? - if (flist.getPaths().contains(fp)) { - if (save) - editorRef.getEditor(false).doSave(null); - else - return true; - } - } - } - } - } catch (CoreException e1) { - System.out.println(e1.getMessage()); - } - - return false; - } - - public void setProjectReadonly(final boolean readonly) { - - /* run project read only settings in progress monitor thread. */ - Display.getDefault().syncExec(new Runnable() { - public void run() { - ProgressMonitorDialog dialog = new ProgressMonitorDialog( - Display.getDefault().getActiveShell()); - try { - dialog.run(true, false, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) { - - FileList flist; - try { - flist = new FileList(project); - - monitor.beginTask("Project settings ... ", - flist.getPaths().size()); - - ResourceAttributes attributes = new ResourceAttributes(); - attributes.setReadOnly(readonly); - attributes.setArchive(readonly); - - for (int i = 0; i < flist.getPaths().size(); i++) { - IPath path = flist.getPaths().get(i); - path = path.makeAbsolute(); - IFile file = getProject().getFile(path); - if (file != null && file.exists()) { - file.setResourceAttributes(attributes); - } - - monitor.worked(1); - } - } catch (CoreException e) { - // log.log(Level.WARNING, "",e); - log.warn("", e); - monitor.done(); - } - - monitor.done(); - - } - - }); - } catch (InvocationTargetException e) { - // log.log(Level.WARNING, "",e); - log.warn("", e); - e.printStackTrace(); - } catch (InterruptedException e) { - // log.log(Level.WARNING, "",e); - log.warn("", e); - e.printStackTrace(); - } - - } - }); - - } - - public void sendRequest() { - try { - // Request request = outgoing.getNextOutgoingRequest(); - Request request = activitySequencer.getNextOutgoingRequest(); - - if (isHost()) { - - /* - * if jupiter server request to has to execute locally on host - * side. - */ - if (request.getJID().equals(host.getJid())) { - log.debug("Send host request back for local execution: " - + request); - activitySequencer.receiveRequest(request); - } else { - /* send operation to client. */ - log.debug("Send request to client: " + request - + request.getJID()); - transmitter.sendJupiterRequest(this, request, request - .getJID()); - } - } else { - log.debug("Send request to host : " + request); - transmitter.sendJupiterRequest(this, request, host.getJid()); - } - // connection.sendOperation(new - // NetworkRequest(this.jid,request.getJID(),request), 0); - } catch (InterruptedException e) { - - e.printStackTrace(); - } - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/AdvancedPreferencePage.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/AdvancedPreferencePage.java deleted file mode 100644 index ce9d67e04edfee29508f4f220e0d66c8afb98194..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/AdvancedPreferencePage.java +++ /dev/null @@ -1,53 +0,0 @@ -package de.fu_berlin.inf.dpp.ui; - -import org.eclipse.jface.preference.BooleanFieldEditor; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.IntegerFieldEditor; -import org.eclipse.jface.preference.StringFieldEditor; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -import de.fu_berlin.inf.dpp.PreferenceConstants; -import de.fu_berlin.inf.dpp.Saros; - -/** - * Contains the advanced preferences - consisting of preferences that are geared - * towards developers and power users and that are not necessary for normal use. - * - * @author rdjemili - */ -public class AdvancedPreferencePage extends FieldEditorPreferencePage implements - IWorkbenchPreferencePage { - - public AdvancedPreferencePage() { - super(GRID); - setPreferenceStore(Saros.getDefault().getPreferenceStore()); - setDescription("Advanced settings geared toward developers and power users."); - } - - @Override - protected void createFieldEditors() { - addField(new StringFieldEditor(PreferenceConstants.SKYPE_USERNAME, "Skype name:", - getFieldEditorParent())); - - addField(new IntegerFieldEditor(PreferenceConstants.FILE_TRANSFER_PORT, - "File transfer port (needs reconnect):", getFieldEditorParent())); - - addField(new BooleanFieldEditor(PreferenceConstants.DEBUG, - "Show Jabber debug window (needs restart).", getFieldEditorParent())); - - addField(new BooleanFieldEditor(PreferenceConstants.FORCE_FILETRANSFER_BY_CHAT , - "Avoid direct file transfer connection", getFieldEditorParent())); - - addField(new IntegerFieldEditor(PreferenceConstants.CHATFILETRANSFER_CHUNKSIZE , - "Chunk size for chat data transfer", getFieldEditorParent())); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IWorkbenchPreferencePage - */ - public void init(IWorkbench workbench) { - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/ChatView.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/ChatView.java deleted file mode 100644 index 949865910ce881d1dfbe0ea24f5a412b7bb338a6..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/ChatView.java +++ /dev/null @@ -1,212 +0,0 @@ -package de.fu_berlin.inf.dpp.ui; - -import org.apache.log4j.Logger; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.SashForm; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.editors.text.EditorsUI; -import org.eclipse.ui.editors.text.TextSourceViewerConfiguration; -import org.eclipse.ui.part.ViewPart; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; - -import de.fu_berlin.inf.dpp.MessagingManager; -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.MessagingManager.IChatListener; -import de.fu_berlin.inf.dpp.MessagingManager.MultiChatSession; -import de.fu_berlin.inf.dpp.Saros.ConnectionState; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.IConnectionListener; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISharedProject; - -public class ChatView extends ViewPart implements ISessionListener, - IConnectionListener, IChatListener { - - private static Logger log = Logger.getLogger(ChatView.class.getName()); - - private Text inputText; - - private MultiChatSession session; - - private SourceViewer viewer; - - private boolean joined = false; - - private Action connectAction; - - private static final int[] WEIGHTS = { 75, 25 }; - - @Override - public void createPartControl(Composite parent) { - Composite rootComposite = new Composite(parent, SWT.NONE); - rootComposite.setLayout(new FillLayout()); - - SashForm sash = new SashForm(rootComposite, SWT.VERTICAL); - - viewer = new SourceViewer(sash, null, null, true, SWT.BORDER | SWT.WRAP - | SWT.V_SCROLL | SWT.MULTI | SWT.READ_ONLY); - viewer.configure(new TextSourceViewerConfiguration(EditorsUI - .getPreferenceStore())); - viewer.setDocument(new Document()); - final StyledText chatText = viewer.getTextWidget(); - - inputText = new Text(sash, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); - inputText.setText("To Join the chat please use the connect button."); - inputText.setEditable(false); - - sash.setWeights(WEIGHTS); - - inputText.addKeyListener(new KeyAdapter() { - public void keyPressed(KeyEvent e) { - switch (e.keyCode) { - case SWT.CR: - case SWT.KEYPAD_CR: - if (e.stateMask == 0) { - String text = inputText.getText(); - inputText.setText(""); //$NON-NLS-1$ - - if (!text.equals("")) { //$NON-NLS-1$ - Saros.getDefault().getMessagingManager() - .getSession().sendMessage(text); - } - // append("ID-TODO", text); - } - break; - } - } - }); - - // TODO add disconnect-action - connectAction = new Action("Connect/DisConnect") { - - public void run() { - MessagingManager mm = Saros.getDefault().getMessagingManager(); - String user = Saros.getDefault().getConnection().getUser(); - if (joined) { - try { - session.sendMessage("is leaving the chat.."); - inputText - .setText("You have left the chat. To renter the chat please use the connect button."); - mm.disconnectMultiUserChat(); - session = null; - inputText.setEditable(false); - - } catch (XMPPException e) { - viewer.getDocument().set("Error: Couldn't disconnect"); - } - joined = false; - connectAction.setImageDescriptor(SarosUI - .getImageDescriptor("/icons/disconnect.png")); - } else { - try { - mm.connectMultiUserChat(); - session = Saros.getDefault().getMessagingManager() - .getSession(); - session.sendMessage("have joined the chat"); - joined = true; - viewer.setDocument(new Document()); - inputText.setEditable(true); - inputText.setText(""); - connectAction.setImageDescriptor(SarosUI - .getImageDescriptor("/icons/connect.png")); - } catch (XMPPException e) { - viewer.getDocument().set("Error: Couldn't connect"); - joined = false; - } - - } - } - }; - - if (joined) { - connectAction.setImageDescriptor(SarosUI - .getImageDescriptor("/icons/connect.png")); - } else { - connectAction.setImageDescriptor(SarosUI - .getImageDescriptor("/icons/disconnect.png")); - } - - IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager(); - mgr.add(connectAction); - - // register ChatView as chat listener - MessagingManager mm = Saros.getDefault().getMessagingManager(); - mm.addChatListener(this); - - // register as connection listener - Saros.getDefault().addListener(this); - } - - @Override - public void setFocus() { - // TODO Auto-generated method stub - - } - - @Override - public void invitationReceived(IIncomingInvitationProcess invitation) { - // TODO Auto-generated method stub - - } - - @Override - public void sessionEnded(ISharedProject session) { - // TODO Auto-generated method stub - - } - - @Override - public void sessionStarted(ISharedProject session) { - // TODO Auto-generated method stub - - } - - @Override - public void connectionStateChanged(XMPPConnection connection, - ConnectionState newState) { - if (newState == ConnectionState.CONNECTED) { - this.connectAction.setEnabled(true); - } else if (newState == ConnectionState.NOT_CONNECTED) { - // TODO do a little bit more here... - this.connectAction.setEnabled(false); - } - } - - public void displayMessage(String body) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - // - } - }); - - } - - @Override - public void chatMessageAdded(final String sender, final String message) { - log.debug("Received Message from " + sender + ": " + message); - Display.getDefault().asyncExec(new Runnable() { - public void run() { - int prefixPos = sender.indexOf('/') + 1; - String m = message.startsWith("\n") ? message.substring(1) - : message; - viewer.getTextWidget().append( - sender.substring(prefixPos, sender.indexOf('/', - prefixPos)) - + ": " + m + "\n"); - } - }); - - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/ErrorMessageDialog.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/ErrorMessageDialog.java deleted file mode 100644 index fedda774ef3dc65b717b9fc3fc0d7211d50f853b..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/ErrorMessageDialog.java +++ /dev/null @@ -1,55 +0,0 @@ -package de.fu_berlin.inf.dpp.ui; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Display; -/** - * Eclipse Dialog to show Exception Messages. - * @author rdjemili - * - */ -public class ErrorMessageDialog { - - /** - * show error message dialog. - * @param exception - */ - public static void showErrorMessage(final Exception exception){ - Display.getDefault().syncExec(new Runnable() { - public void run() { - MessageDialog.openError(Display.getDefault().getActiveShell(), - exception.toString(), exception.getMessage()); - } - }); - } - - /** - * show error message dialog. - * @param exception - */ - public static void showErrorMessage(final String exceptionMessage){ - Display.getDefault().syncExec(new Runnable() { - public void run() { - if(exceptionMessage == null || exceptionMessage.equals("")){ - MessageDialog.openError(Display.getDefault().getActiveShell(), - "Exception", "Error occured."); - }else{ - MessageDialog.openError(Display.getDefault().getActiveShell(),"Exception", exceptionMessage); - } - } - - }); - } - - /** - * show error message dialog. - * @param exception - */ - public static void showChecksumErrorMessage(final String fileName){ - Display.getDefault().syncExec(new Runnable() { - public void run() { - MessageDialog.openWarning(Display.getDefault().getActiveShell(), "Consistency Problem!", "Inconsitent file state has detected. File "+fileName+ " has to synchronized with project host"); - } - }); - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/IRosterTree.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/IRosterTree.java deleted file mode 100644 index f79548217813b2c187c0ee0c006f0e7d9a6f62ab..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/IRosterTree.java +++ /dev/null @@ -1,18 +0,0 @@ -package de.fu_berlin.inf.dpp.ui; - -/** - * This interface handles the event updates for roster tree. - * @author orieger - * - */ -public interface IRosterTree { - - /** - * Refreshes the roster tree. - * - * @param updateLabels - * <code>true</code> if item labels (might) have changed. - * <code>false</code> otherwise. - */ - public void refreshRosterTree(final boolean updateLabels); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/InvitationDialog.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/InvitationDialog.java deleted file mode 100644 index 6ce2705b6fa2a1fb9faa1a09f6a85cbb8d6e1667..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/InvitationDialog.java +++ /dev/null @@ -1,523 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui; - -import java.util.ArrayList; -import java.util.Collection; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; -import org.jivesoftware.smack.Roster; -import org.jivesoftware.smack.RosterEntry; -import org.jivesoftware.smack.RosterListener; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.packet.Presence; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.Saros.ConnectionState; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess; -import de.fu_berlin.inf.dpp.invitation.IOutgoingInvitationProcess; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess.IInvitationUI; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess.State; -import de.fu_berlin.inf.dpp.net.IConnectionListener; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISharedProject; - -public class InvitationDialog extends Dialog implements IInvitationUI, IConnectionListener { - - private TableViewer tableviewer; - private Table table; - private ArrayList<inviterdata> input; - private Button cancelButton; - - private Roster roster=Saros.getDefault().getRoster(); - private InvState inviteStep = InvState.SELECTION; - private JID autoinviteJID = null; - private Display display = null; - - private static enum InvState { - SELECTION, INVITING, DONE - } - - // assigned to any of the entries of the invite-tableview - private class inviterdata { - JID jid; - String name; - IOutgoingInvitationProcess outginvatationProc; - } - - - // Class for providing labels of my Tableview - private class MyLabelProvider extends LabelProvider implements ITableLabelProvider { - - public Image getColumnImage(Object element, int columnIndex) { - return null; - } - - public String getColumnText(Object element, int columnIndex) { - inviterdata item = (inviterdata)element; - - switch(columnIndex) { - case 0: - return item.name; - case 1: - if (item.outginvatationProc!=null) - return getStateDesc(item.outginvatationProc.getState()); - else - return ""; - case 2: - if (item.outginvatationProc!=null){ - if (item.outginvatationProc.getState()==IInvitationProcess.State.SYNCHRONIZING) - return "Transfering file "+ - (item.outginvatationProc.getProgressCurrent()) +" of "+ - item.outginvatationProc.getProgressMax()+": "+ - item.outginvatationProc.getProgressInfo(); - else - return ""; - } else - return ""; - } - return ""; - } - } - - public InvitationDialog(Shell parentShell, JID jid) { - super(parentShell); - autoinviteJID=jid; - - // TODO Auto-generated constructor stub - } - - - @Override - protected Control createContents(Composite parent) { - - getShell().setText("Invitation Helper"); - display = getShell().getDisplay(); - - Composite composite = new Composite(parent, SWT.NONE); - - GridLayout gl = new GridLayout(); - composite.setLayout(gl); - GridData gd = new GridData(GridData.FILL_BOTH); - gd.minimumHeight=200; - - Label usersLabel = new Label(composite, SWT.NONE); - usersLabel.setText("Select users to invite:"); - - Composite comTable = new Composite(composite , SWT.NONE); - comTable .setLayout(gl); - comTable .setLayoutData(gd); - -// tableviewer = new TableViewer(comTable, SWT.FULL_SELECTION | SWT.MULTI); - //avoid multi selection - tableviewer = new TableViewer(comTable, SWT.FULL_SELECTION); - table = tableviewer.getTable(); - table.setLinesVisible(true); - tableviewer.setContentProvider(new ArrayContentProvider()); - tableviewer.setLabelProvider(new MyLabelProvider()); - table.setHeaderVisible(true); - table.setLayoutData(gd); - TableColumn column = new TableColumn(table,SWT.NONE); - column.setText("User"); - column.setWidth(150); - column = new TableColumn(table,SWT.NONE); - column.setText("Status"); - column.setWidth(300); - column = new TableColumn(table,SWT.NONE); - column.setText("Action"); - column.setWidth(200); - - -// table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - input = new ArrayList<inviterdata>(); - tableviewer.setInput(input); - - cancelButton = new Button(composite, SWT.NONE); - cancelButton.setText("Cancel selected invitation"); - cancelButton.addSelectionListener(new SelectionListener() { - - public void widgetDefaultSelected(SelectionEvent e) { - } - - public void widgetSelected(SelectionEvent e) { - cancelInvite(); - Display.getDefault().syncExec(new Runnable() { - public void run() { - } - }); - } - }); - - table.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent event) { - if (inviteStep==InvState.SELECTION) - setInviteable( (table.getSelectionCount()>0) ); - else if (inviteStep==InvState.INVITING) - cancelButton.setEnabled(isSelectionCancelable()); - else - cancelButton.setEnabled(false); - } - public void widgetDefaultSelected(SelectionEvent event) { - } - } ) ; - - cancelButton.setEnabled(false); - - // get online users from roster - if (autoinviteJID==null) - attachRosterListener(); - refreshRosterListRunASync(autoinviteJID); - - Control c=super.createContents(parent); - - getButton(IDialogConstants.OK_ID).setText("Invite"); - getButton(IDialogConstants.CANCEL_ID).setText("Close"); - setInviteable(false); - - // auto trigger automatic invite - if (autoinviteJID!=null) - performInvitation(); - - return c; - } - - protected void setInviteable(boolean b) { - getButton(IDialogConstants.OK_ID).setEnabled(b); - } - - @Override - protected void okPressed() { - performInvitation(); - } - public boolean performInvitation() { - - inviteStep=InvState.INVITING; - setInviteable(false); - cancelButton.setEnabled(true); - getButton(IDialogConstants.CANCEL_ID).setEnabled(false); - - try { - TableItem[] cursel = table.getSelection(); - - ISharedProject project = Saros.getDefault().getSessionManager().getSharedProject(); - String name = project.getProject().getName(); - - for (int i=0; i < cursel.length; i++) { - TableItem ti = cursel[i]; - Object o=ti.getData(); - - inviterdata invdat = (inviterdata)o; - invdat.outginvatationProc=project.invite(invdat.jid, name, true, this); - } - - return false; // we wanna wait (and block) until all invites are done - - } catch (Exception e) { - e.printStackTrace(); - } - - return false; - } - - // Triggers the update of the table in a GUI thread. - public void updateInvitationProgress(final JID jid) { - display.asyncExec(new Runnable() { - public void run() { - updateInvitationProgressRunASyn(jid); - }} ); - } - - /* - * Updates the invitation progress for all users in the table by refreshing - * the table. MyLabelProvider will then poll the current progresses. - */ - private void updateInvitationProgressRunASyn(JID jid) { - boolean alldone = true; - inviterdata invdat = null; - int index; - - for (index=0; index<table.getItemCount(); index++) { - - TableItem ti=table.getItem(index); - Object o=ti.getData(); - invdat=(inviterdata)o; - - if (invdat.outginvatationProc!=null && - invdat.outginvatationProc.getState()!=IInvitationProcess.State.DONE && - invdat.outginvatationProc.getState()!=IInvitationProcess.State.CANCELED ) { - alldone=false; - } - - if (jid!=null && invdat.jid.equals(jid)) - tableviewer.refresh(o); - } - - // force the table to update ALL labels - if (jid==null) - tableviewer.refresh(); - - // are all invites done? - if (alldone) { -// if(invdat.outginvatationProc.getState() == IInvitationProcess.State.DONE){ -// inviteStep= InvState.SELECTION; -// } - inviteStep=InvState.DONE; - getButton(IDialogConstants.CANCEL_ID).setEnabled(true); - - } - cancelButton.setEnabled(isSelectionCancelable() && inviteStep!=InvState.DONE ); - - } - - boolean isSelectionCancelable(){ - - if (table.getSelectionCount()==0) - return false; - - TableItem[] cursel = table.getSelection(); - for (int i=0;i<cursel.length;i++) { - TableItem ti=cursel[i]; - Object o=ti.getData(); - inviterdata invdat=(inviterdata)o; - if (invdat.outginvatationProc==null || - (invdat.outginvatationProc.getState()==State.INITIALIZED || - invdat.outginvatationProc.getState()==State.SYNCHRONIZING_DONE || - invdat.outginvatationProc.getState()==State.CANCELED || - invdat.outginvatationProc.getState()==State.DONE - ) ) - return false; - } - return true; - } - - void cancelInvite() { - TableItem[] cursel = table.getSelection(); - for (int i=0;i<cursel.length;i++) { - TableItem ti=cursel[i]; - Object o=ti.getData(); - inviterdata invdat=(inviterdata)o; - if (invdat.outginvatationProc==null) - continue; - - invdat.outginvatationProc.cancel(null, false); - } - updateInvitationProgress(null); - } - - - boolean isJIDinList(ArrayList<JID> items, JID jid) { - for (int i=0;i<items.size();i++) { - - try { - JID curJID = items.get(i); - - if (curJID.equals(jid)) - return true; - - } catch(Exception e) { - System.out.println(e); - } - } - - return false; - } - - static final String[] StateNames = { - "Initialized", - "Invitation sent. Waiting for acknowledgement...", - "Filelist of inviter requested", - "Filelist of inviter sent", - "Filelist of invitee sent", - "Synchornizing project files. Transfering files...", - "Files sent. Waiting for invitee...", - "Invitiation completed", - "Invitation canceled" - }; - private String getStateDesc(IInvitationProcess.State state){ - return StateNames[state.ordinal()]; - } - - public void showErrorMessage(String errorMessage) { - ErrorMessageDialog.showErrorMessage(errorMessage); - } - - public void cancel(String errorMsg, boolean replicated) { - updateInvitationProgress(null); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.invitation.IOutgoingInvitationProcess.IInvitationUI - */ - public void runGUIAsynch(final Runnable runnable) { - - display.asyncExec(new Runnable() { - public void run() { - new Thread(runnable).start(); - }} ); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.IConnectionListener - */ - public void connectionStateChanged(XMPPConnection connection, final ConnectionState newState) { - - if (newState == ConnectionState.CONNECTED) { - roster = Saros.getDefault().getRoster(); - attachRosterListener(); - - } else if (newState == ConnectionState.NOT_CONNECTED) { - roster = null; - } - - refreshRosterListRunASync(null); - - } - - private void attachRosterListener() { - roster.addRosterListener(new RosterListener() { - public void entriesAdded(Collection<String> addresses) { - refreshRosterList(); - } - - public void entriesUpdated(Collection<String> addresses) { - refreshRosterList(); - } - - public void entriesDeleted(Collection<String> addresses) { - refreshRosterList(); - } - - public void presenceChanged(String XMPPAddress) { - refreshRosterList(); - } - - - public void presenceChanged(Presence presence) { - //TODO: new Method for Smack 3 - presenceChanged(presence.getFrom()); - - } - }); - } - - /* - * Triggers the refresh of the roster list in a GUI thread. - */ - private void refreshRosterList() { - if (inviteStep!=InvState.SELECTION) - return; - - display.asyncExec(new Runnable() { - public void run() { - refreshRosterListRunASync(null); - }} ); - } - - /* - * Clears and re-filles the table with all online users from my roster. - * Selections are preserved. - */ - private void refreshRosterListRunASync(JID toselect) { - ArrayList<JID> curselA = new ArrayList<JID>(); - int[] curselNew=null; - - // save selection - TableItem[] curselTIs = table.getSelection(); - for (int i=0;i<curselTIs.length;i++) - curselA.add( ((inviterdata)curselTIs[i].getData()).jid ); - - input.clear(); - table.removeAll(); - - if (roster==null) - return; - - //TODO: Änderung für smack 3 -// Iterator iter = roster.getEntries(); - Collection<RosterEntry> users = roster.getEntries(); - int index=-1; -// while (iter.hasNext()) { -// RosterEntry entry = (RosterEntry) iter.next(); - for(RosterEntry entry : users){ - - String username = entry.getUser(); - Presence presence = roster.getPresence(username); - - User user = Saros.getDefault().getSessionManager(). - getSharedProject().getParticipant(new JID(entry.getUser())); - /*TODO: Änderung: presence.type available hinzugefügt. - * Es ist hier jedoch zu prüfen, inwieweit auch offline user eingeladen werden könnten. - * */ - if (presence != null && presence.getType().equals(Presence.Type.available)&& user==null ) - { - inviterdata invdat = new inviterdata(); - invdat.jid= new JID(entry.getUser()); - invdat.name=entry.getName(); - invdat.outginvatationProc=null; - - input.add(invdat); - index++; - - if ( (autoinviteJID!=null && invdat.jid.equals(autoinviteJID) ) || - (autoinviteJID==null && isJIDinList(curselA, invdat.jid) ) ) - { - int curselOld[]=table.getSelectionIndices(); - curselNew=new int[curselOld.length+1]; - System.arraycopy(curselOld, 0, curselNew, 0, curselOld.length); - curselNew[curselNew.length-1]=index; - } - } - } - - tableviewer.refresh(); - - if (curselNew!=null) - table.setSelection(curselNew); - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/PreferencePage.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/PreferencePage.java deleted file mode 100644 index 2c6f923687469d85cf31fbe5288be9aac03b474d..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/PreferencePage.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui; - -import org.eclipse.jface.preference.BooleanFieldEditor; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.StringFieldEditor; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -import de.fu_berlin.inf.dpp.PreferenceConstants; -import de.fu_berlin.inf.dpp.Saros; - -/** - * Contains the basic preferences for Saros. - * - * @author rdjemili - */ -public class PreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { - - public PreferencePage() { - super(GRID); - setPreferenceStore(Saros.getDefault().getPreferenceStore()); - setDescription("Your settings for Jabber."); - } - - @Override - public void createFieldEditors() { - addField(new StringFieldEditor(PreferenceConstants.SERVER, "Server:", - getFieldEditorParent())); - - addField(new StringFieldEditor(PreferenceConstants.USERNAME, "Username:", - getFieldEditorParent())); - - StringFieldEditor passwordField = new StringFieldEditor(PreferenceConstants.PASSWORD, - "Password:", getFieldEditorParent()); - passwordField.getTextControl(getFieldEditorParent()).setEchoChar('*'); - addField(passwordField); - - addField(new BooleanFieldEditor(PreferenceConstants.AUTO_CONNECT, - "Automatically connect on startup.", getFieldEditorParent())); - - addField(new BooleanFieldEditor(PreferenceConstants.AUTO_FOLLOW_MODE, - "Start in Follow Mode.", getFieldEditorParent())); - } - - /* - * @see org.eclipse.ui.IWorkbenchPreferencePage - */ - public void init(IWorkbench workbench) { - } -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/RosterView.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/RosterView.java deleted file mode 100644 index 58dba47cf99dd15a054274061f7e2a3137d469c1..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/RosterView.java +++ /dev/null @@ -1,502 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui; - -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.part.ViewPart; -import org.jivesoftware.smack.Roster; -import org.jivesoftware.smack.RosterEntry; -import org.jivesoftware.smack.RosterGroup; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.packet.Presence; -import org.jivesoftware.smack.packet.RosterPacket; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.Saros.ConnectionState; -import de.fu_berlin.inf.dpp.net.IConnectionListener; -import de.fu_berlin.inf.dpp.net.internal.RosterListenerImpl; -import de.fu_berlin.inf.dpp.ui.actions.ConnectDisconnectAction; -import de.fu_berlin.inf.dpp.ui.actions.DeleteContactAction; -import de.fu_berlin.inf.dpp.ui.actions.InviteAction; -import de.fu_berlin.inf.dpp.ui.actions.NewContactAction; -import de.fu_berlin.inf.dpp.ui.actions.RenameContactAction; -import de.fu_berlin.inf.dpp.ui.actions.SkypeAction; - -/** - * This view displays the roster (also known as contact list) of the local user. - * - * @author rdjemili - */ -public class RosterView extends ViewPart implements IConnectionListener, IRosterTree { - private TreeViewer viewer; - - private Roster roster; - - private XMPPConnection connection; - - // actions - private Action messagingAction; - - private Action inviteAction; - - private RenameContactAction renameContactAction; - - private DeleteContactAction deleteContactAction; - - private SkypeAction skypeAction; - - /** - * An item of the roster tree. Can be either a group or a single contact. - * - * @author rdjemili - */ - private interface TreeItem { - - /** - * @return all child items of this tree item. - */ - Object[] getChildren(); - } - - /** - * A group item which holds a number of users. - */ - private class GroupItem implements TreeItem { - private RosterGroup group; - - public GroupItem(RosterGroup group) { - this.group = group; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ui.RosterView.TreeItem - */ - public Object[] getChildren() { - return RosterView.getChildren(group.getEntries()); - } - - @Override - public String toString() { - return group.getName(); - } - } - - /** - * A group item that holds all users that don't belong to another group. - */ - private class UnfiledGroupItem implements TreeItem { - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ui.RosterView.TreeItem - */ - public Object[] getChildren() { - return RosterView.getChildren(roster.getUnfiledEntries()); - } - - @Override - public String toString() { - return "Buddies"; - } - } - - /** - * Provide tree content. - */ - private class TreeContentProvider implements IStructuredContentProvider, ITreeContentProvider { - - /* - * @see org.eclipse.jface.viewers.IContentProvider - */ - public void inputChanged(Viewer v, Object oldInput, Object newInput) { - } - - /* - * @see org.eclipse.jface.viewers.IContentProvider - */ - public void dispose() { - } - - /* - * @see org.eclipse.jface.viewers.IStructuredContentProvider - */ - public Object[] getElements(Object parent) { - if (parent.equals(getViewSite()) && roster != null) { - List<TreeItem> groups = new LinkedList<TreeItem>(); - //TODO: Änderung für Smack 3 - for(RosterGroup rg : roster.getGroups()){ - GroupItem item = new GroupItem(rg); - groups.add(item); - } - - -// for (Iterator it = roster.getGroups(); it.hasNext();) { -// GroupItem item = new GroupItem((RosterGroup) it.next()); -// groups.add(item); -// } - - groups.add(new UnfiledGroupItem()); - - return groups.toArray(); - } - - return new Object[0]; - } - - /* - * @see org.eclipse.jface.viewers.ITreeContentProvider - */ - public Object getParent(Object child) { - return null; // TODO - } - - /* - * @see org.eclipse.jface.viewers.ITreeContentProvider - */ - public Object[] getChildren(Object parent) { - if (parent instanceof TreeItem) { - return ((TreeItem) parent).getChildren(); - } - - return new Object[0]; - } - - /* - * @see org.eclipse.jface.viewers.ITreeContentProvider - */ - public boolean hasChildren(Object parent) { - if (parent instanceof TreeItem) { - Object[] children = ((TreeItem) parent).getChildren(); - return children.length > 0; - } - - return false; - } - } - - /** - * Shows user name and state in parenthesis. - */ - private class ViewLabelProvider extends LabelProvider { - private Image groupImage = SarosUI.getImage("icons/group.png"); - - private Image personImage = SarosUI.getImage("icons/user.png"); - - @Override - public String getText(Object obj) { - if (obj instanceof RosterEntry) { - RosterEntry entry = (RosterEntry) obj; - - String label = entry.getName(); - - // show JID if entry has no nickname - if (label == null) - label = entry.getUser(); - - // append presence information if available - Presence presence = roster.getPresence(entry.getUser()); - if (presence != null) { - label = label + " (" + presence.getType() + ")"; - } - - return label; - } - - return obj.toString(); - } - - @Override - public Image getImage(Object element) { - return element instanceof RosterEntry ? personImage : groupImage; - } - } - - /** - * A sorter that orders by presence and then by name. - */ - private class NameSorter extends ViewerSorter { - @Override - public int compare(Viewer viewer, Object elem1, Object elem2) { - - // sort by presence - if (elem1 instanceof RosterEntry) { - RosterEntry entry1 = (RosterEntry) elem1; - - if (elem2 instanceof RosterEntry) { - RosterEntry entry2 = (RosterEntry) elem2; - - String user1 = entry1.getUser(); - boolean presence1 = roster.getPresence(user1) != null; - - String user2 = entry2.getUser(); - boolean presence2 = roster.getPresence(user2) != null; - - if (presence1 && !presence2) { - return -1; - } else if (!presence1 && presence2) { - return 1; - } - } - } - - // otherwise use default order - return super.compare(viewer, elem1, elem2); - } - } - - /** - * Creates an roster view.. - */ - public RosterView() { - } - - /** - * This is a callback that will allow us to create the viewer and initialize - * it. - */ - public void createPartControl(Composite parent) { - viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - viewer.setContentProvider(new TreeContentProvider()); - viewer.setLabelProvider(new ViewLabelProvider()); - viewer.setSorter(new NameSorter()); - viewer.setInput(getViewSite()); - viewer.expandAll(); - - makeActions(); - hookContextMenu(); - hookDoubleClickAction(); - contributeToActionBars(); - updateEnablement(); - - Saros saros = Saros.getDefault(); - saros.addListener(this); - - connectionStateChanged(saros.getConnection(), saros.getConnectionState()); - } - - /** - * Passing the focus request to the viewer's control. - */ - public void setFocus() { - viewer.getControl().setFocus(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.IConnectionListener - */ - public void connectionStateChanged(XMPPConnection connection, final ConnectionState newState) { - if (newState == ConnectionState.CONNECTED) { -// roster = Saros.getDefault().getRoster(); - roster = connection.getRoster(); - this.connection = connection; - attachRosterListener(); - - } else if (newState == ConnectionState.NOT_CONNECTED) { - roster = null; - } - - refreshRosterTree(true); - - Display.getDefault().asyncExec(new Runnable() { - public void run() { - updateStatusLine(newState); - updateEnablement(); - } - }); - } - - public static Object[] getChildren(Collection<RosterEntry> entries){ - //TODO: new method for smack 3 - - List<RosterEntry> users = new LinkedList<RosterEntry>(); - - for(RosterEntry entry : entries){ - if (entry.getType() == RosterPacket.ItemType.both || - entry.getType() == RosterPacket.ItemType.to) { - users.add(entry); - } - } - - return users.toArray(); - } - - /** - * Needs to called from an UI thread. - */ - private void updateEnablement() { - viewer.getControl().setEnabled(Saros.getDefault().isConnected()); - } - - /** - * Needs to called from an UI thread. - */ - private void updateStatusLine(final ConnectionState newState) { - IStatusLineManager statusLine = getViewSite().getActionBars().getStatusLineManager(); - statusLine.setMessage(SarosUI.getDescription(newState)); - } - - private void attachRosterListener() { - roster.addRosterListener(new RosterListenerImpl(connection,this)); - -// roster.addRosterListener(new RosterListener() { -// public void entriesAdded(Collection<String> addresses) { -// for (Iterator<String> it = addresses.iterator(); it.hasNext();) { -// String address = it.next(); -// RosterEntry entry = roster.getEntry(address); -// //When the entry is only from the other user, then send a subscription request -// if (entry != null && entry.getType() == RosterPacket.ItemType.from) { -// try { -// System.out.println("Creating entry to: " + entry.getUser()); -// connection.getRoster().createEntry(entry.getUser(), entry.getUser(), null); -// } catch (XMPPException e) { -// e.printStackTrace(); -// } -// } -// } -// -// refreshRosterTree(true); -// } -// -// public void entriesUpdated(Collection<String> addresses) { -// refreshRosterTree(false); -// } -// -// public void entriesDeleted(Collection<String> addresses) { -// refreshRosterTree(false); -// } -// -// public void presenceChanged(String XMPPAddress) { -// refreshRosterTree(true); -// } -// -// -// public void presenceChanged(Presence presence) { -// //TODO: new Method for Smack 3 -// presenceChanged(presence.getFrom()); -// -// } -// }); - } - - /** - * Refreshes the roster tree. - * - * @param updateLabels - * <code>true</code> if item labels (might) have changed. - * <code>false</code> otherwise. - */ - public void refreshRosterTree(final boolean updateLabels) { - if (viewer.getControl().isDisposed()) - return; - - Display.getDefault().asyncExec(new Runnable() { - public void run() { - viewer.refresh(updateLabels); - viewer.expandAll(); - } - }); - } - - private void hookContextMenu() { - MenuManager menuMgr = new MenuManager("#PopupMenu"); - menuMgr.setRemoveAllWhenShown(true); - menuMgr.addMenuListener(new IMenuListener() { - public void menuAboutToShow(IMenuManager manager) { - RosterView.this.fillContextMenu(manager); - } - }); - - Menu menu = menuMgr.createContextMenu(viewer.getControl()); - - viewer.getControl().setMenu(menu); - getSite().registerContextMenu(menuMgr, viewer); - } - - private void hookDoubleClickAction() { - viewer.addDoubleClickListener(new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent event) { - if (messagingAction.isEnabled()) { - messagingAction.run(); - } - } - }); - } - - private void contributeToActionBars() { - IActionBars bars = getViewSite().getActionBars(); - - IMenuManager menuManager = bars.getMenuManager(); - menuManager.add(inviteAction); - // menuManager.add(new TestJoinWizardAction()); - menuManager.add(new Separator()); - - IToolBarManager toolBarManager = bars.getToolBarManager(); - toolBarManager.add(new ConnectDisconnectAction()); - toolBarManager.add(new NewContactAction()); - } - - private void fillContextMenu(IMenuManager manager) { - manager.add(skypeAction); - manager.add(inviteAction); - manager.add(new Separator()); - manager.add(renameContactAction); - manager.add(deleteContactAction); - - // Other plug-ins can contribute there actions here - manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - } - - private void makeActions() { - skypeAction = new SkypeAction(viewer); - inviteAction = new InviteAction(viewer); - renameContactAction = new RenameContactAction(viewer); - deleteContactAction = new DeleteContactAction(viewer); - } -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/SarosUI.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/SarosUI.java deleted file mode 100644 index 0d19dfbfd1a60c0564453c628eddbe76083d2a46..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/SarosUI.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui; - -import org.eclipse.core.filebuffers.IDocumentSetupParticipant; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.internal.ui.JavaPlugin; -import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider; -import org.eclipse.jdt.internal.ui.javaeditor.JavaDocumentSetupParticipant; -import org.eclipse.jdt.ui.text.IJavaPartitions; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.editors.text.ForwardingDocumentProvider; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.Saros.ConnectionState; -import de.fu_berlin.inf.dpp.editor.internal.SharedDocumentProvider; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISessionManager; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.ui.wizards.JoinSessionWizard; -import de.fu_berlin.inf.dpp.ui.wizards.WizardDialogAccessable; - -public class SarosUI implements ISessionListener { - - private static final String SESSION_VIEW = "de.fu_berlin.inf.dpp.ui.SessionView"; - - private static final String ROSTER_VIEW = "de.fu_berlin.inf.dpp.ui.RosterView"; - - public SarosUI(ISessionManager sessionManager) { - setupCompilationUnitDocumentProvider(); - sessionManager.addSessionListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void invitationReceived(final IIncomingInvitationProcess process) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - try { - Shell shell = Display.getDefault().getActiveShell(); - JoinSessionWizard jsw = new JoinSessionWizard(process); - WizardDialogAccessable wd= - new WizardDialogAccessable(shell, jsw ); - jsw.setWizardDlg(wd); - process.setInvitationUI(jsw.getInvitationUI()); - wd.open(); - } catch (Exception e) { - Saros.getDefault().getLog().log( - new Status(IStatus.ERROR, Saros.SAROS, IStatus.ERROR, - "Error while joining a session", e)); - } - } - }); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - try { - // Create Session View - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); - window.getActivePage().showView(SESSION_VIEW, null, IWorkbenchPage.VIEW_CREATE); - } catch (PartInitException e) { - Saros.getDefault().getLog().log( - new Status(IStatus.ERROR, Saros.SAROS, IStatus.ERROR, - "Could not create Session View", e)); - } - - try { - // Open Roster so that a participant can be invited - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); - window.getActivePage() - .showView(ROSTER_VIEW, null, IWorkbenchPage.VIEW_ACTIVATE); - } catch (PartInitException e) { - Saros.getDefault().getLog().log( - new Status(IStatus.ERROR, Saros.SAROS, IStatus.ERROR, - "Could not activate Roster View", e)); - } - - } - }); - } - - /** - * @param state - * @return a nice string description of the given state, which can be used - * to be shown in labels (e.g. CONNECTING becomes "Connecting.."). - */ - public static String getDescription(ConnectionState state) { - switch (state) { - case NOT_CONNECTED: - return "Not connected"; - case CONNECTING: - return "Connecting..."; - case CONNECTED: - return "Connected (as " + Saros.getDefault().getConnection().getUser() + ")"; - case DISCONNECTING: - return "Disconnecting..."; - case ERROR: - return "Error (" + Saros.getDefault().getConnectionError()+ ")"; - } - - return ""; - } - - public static Composite createLabelComposite(Composite parent, String text) { - Composite composite = new Composite(parent, SWT.NONE); - - FillLayout layout = new FillLayout(SWT.NONE); - layout.marginHeight = 20; - composite.setLayout(layout); - - Label label = new Label(composite, SWT.NONE); - label.setText(text); - - return composite; - } - - public static Image getImage(String path) { - return new Image(Display.getDefault(), SarosUI.getImageDescriptor(path).getImageData()); - } - - /** - * Returns an image descriptor for the image file at the given plug-in - * relative path. - * - * @param path - * the path - * @return the image descriptor - */ - public static ImageDescriptor getImageDescriptor(String path) { - return AbstractUIPlugin.imageDescriptorFromPlugin("de.fu_berlin.inf.dpp", path); - } - - @SuppressWarnings("restriction") - private void setupCompilationUnitDocumentProvider() { // UGLY HACK - CompilationUnitDocumentProvider cuProvider = (CompilationUnitDocumentProvider) JavaPlugin - .getDefault().getCompilationUnitDocumentProvider(); - - SharedDocumentProvider sharedProvider = new SharedDocumentProvider(); - - IDocumentSetupParticipant setupParticipant = new JavaDocumentSetupParticipant(); - ForwardingDocumentProvider parentProvider = new ForwardingDocumentProvider( - IJavaPartitions.JAVA_PARTITIONING, setupParticipant, sharedProvider); - - cuProvider.setParentDocumentProvider(parentProvider); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/SessionView.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/SessionView.java deleted file mode 100644 index 3e6f041772a63879052753181d2c9961dbe884ea..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/SessionView.java +++ /dev/null @@ -1,342 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui; - -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.IColorProvider; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableFontProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.editors.text.EditorsUI; -import org.eclipse.ui.part.ViewPart; -import org.eclipse.ui.texteditor.AnnotationPreference; -import org.eclipse.ui.texteditor.AnnotationPreferenceLookup; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.editor.annotations.SelectionAnnotation; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISessionManager; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; -import de.fu_berlin.inf.dpp.ui.actions.FollowModeAction; -import de.fu_berlin.inf.dpp.ui.actions.GiveDriverRoleAction; -import de.fu_berlin.inf.dpp.ui.actions.LeaveSessionAction; -import de.fu_berlin.inf.dpp.ui.actions.OpenInviteInterface; -import de.fu_berlin.inf.dpp.ui.actions.RemoveAllDriverRoleAction; -import de.fu_berlin.inf.dpp.ui.actions.TakeDriverRoleAction; - - -public class SessionView extends ViewPart - implements ISessionListener, IPropertyChangeListener { - - private TableViewer viewer; - - private ISharedProject sharedProject; - - private GiveDriverRoleAction giveDriverRoleAction; - - private TakeDriverRoleAction takeDriverRoleAction; - - private IPreferenceStore store = null; - - - private class SessionContentProvider implements IStructuredContentProvider, - ISharedProjectListener { - - private TableViewer tableViewer; - - public void inputChanged(Viewer v, Object oldInput, Object newInput) { - if (oldInput != null) { - ISharedProject oldProject = (ISharedProject) oldInput; - oldProject.removeListener(this); - } - - sharedProject = (ISharedProject) newInput; - if (sharedProject != null) { - sharedProject.addListener(this); - } - - tableViewer = (TableViewer) v; - tableViewer.refresh(); - - updateEnablement(); - } - - public Object[] getElements(Object parent) { - if (sharedProject != null) { - return sharedProject.getParticipants().toArray(); - } - - return new Object[] {}; - } - - public void driverChanged(JID driver, boolean replicated) { - refreshTable(); - } - - public void userJoined(JID user) { - refreshTable(); - } - - public void userLeft(JID user) { - refreshTable(); - } - - public void dispose() { - } - - private void refreshTable() { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - tableViewer.refresh(); - } - }); - } - } - - private class SessionLabelProvider extends LabelProvider - implements ITableLabelProvider, IColorProvider, ITableFontProvider { - - private Image userImage = SarosUI.getImage("icons/user.png"); - private Image driverImage = SarosUI.getImage("icons/user_edit.png"); - private Font boldFont=null; - - public String getColumnText(Object obj, int index) { - User participant = (User) obj; - - StringBuffer sb = new StringBuffer(participant.getJid().getName()); -// if (participant.equals(sharedProject.getDriver())) { - if(sharedProject.isDriver(participant)){ - - sb.append(" (Driver)"); - } - - return sb.toString(); - } - - @Override - public Image getImage(Object obj) { - User user = (User) obj; - if(sharedProject.isDriver(user)){ - return driverImage; - } -// return user.equals(sharedProject.getDriver()) ? driverImage : userImage; - return userImage; - } - - public Image getColumnImage(Object obj, int index) { - return getImage(obj); - } - - // TODO getting current color doesnt uses when default was changed. - public Color getBackground(Object element) { - User user = (User) element; - - if (user.getJid().equals( Saros.getDefault().getMyJID() )) - return null; - - int colorid=user.getColorID(); - String mytype=SelectionAnnotation.TYPE + "." + new Integer(colorid+1).toString(); - - AnnotationPreferenceLookup lookup= org.eclipse.ui.editors.text.EditorsUI.getAnnotationPreferenceLookup(); - AnnotationPreference ap = lookup.getAnnotationPreference(mytype); - if (ap==null) - return null; - - IPreferenceStore store = EditorsUI.getPreferenceStore(); - RGB rgb = PreferenceConverter.getColor(store, ap.getColorPreferenceKey()); - - return new Color(Display.getDefault(), rgb); - - - } - - public Color getForeground(Object element) { - return null; - } - - public Font getFont(Object element, int columnIndex) { - if (boldFont==null) { - Display disp = viewer.getControl().getDisplay(); - FontData[] data = disp.getSystemFont().getFontData(); - for (FontData fontData : data) { - fontData.setStyle(SWT.BOLD); - } - boldFont = new Font(disp, data); - } - - User user = (User) element; - if (user.getJid().equals( Saros.getDefault().getMyJID() )) - return boldFont; - return null; - } - - @Override - public void dispose() { - if (boldFont!=null) { - boldFont.dispose(); - boldFont=null; - } - - super.dispose(); - } - } - - /** - * The constructor. - */ - public SessionView() { - store = EditorsUI.getPreferenceStore(); - store.addPropertyChangeListener(this); - } - - @Override - protected void finalize() throws Throwable { - store.removePropertyChangeListener(this); - super.finalize(); - } - - public void sessionStarted(final ISharedProject session) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - viewer.setInput(session); - } - }); - } - - public void sessionEnded(ISharedProject session) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - viewer.setInput(null); - } - }); - } - - public void invitationReceived(IIncomingInvitationProcess process) { - // ignore - } - - /** - * This is a callback that will allow us to create the viewer and initialize - * it. - */ - public void createPartControl(Composite parent) { - viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - viewer.setContentProvider(new SessionContentProvider()); - viewer.setLabelProvider(new SessionLabelProvider()); - viewer.setInput(null); - - giveDriverRoleAction = new GiveDriverRoleAction(viewer); - takeDriverRoleAction = new TakeDriverRoleAction(viewer); - - contributeToActionBars(); - hookContextMenu(); - attachSessionListener(); - updateEnablement(); - - setPartName("Shared Project Session"); - } - - /** - * Passing the focus request to the viewer's control. - */ - public void setFocus() { - viewer.getControl().setFocus(); - } - - /** - * Needs to called from the UI thread. - */ - private void updateEnablement() { - viewer.getControl().setEnabled(sharedProject != null); - } - - private void attachSessionListener() { - ISessionManager sessionManager = Saros.getDefault().getSessionManager(); - - sessionManager.addSessionListener(this); - if (sessionManager.getSharedProject() != null) { - viewer.setInput(sessionManager.getSharedProject()); - } - } - - private void contributeToActionBars() { - IActionBars bars = getViewSite().getActionBars(); - IToolBarManager toolBar = bars.getToolBarManager(); - - toolBar.add(new OpenInviteInterface()); - toolBar.add(new RemoveAllDriverRoleAction()); - toolBar.add(new FollowModeAction()); - toolBar.add(new LeaveSessionAction()); - } - - private void hookContextMenu() { - MenuManager menuMgr = new MenuManager("#PopupMenu"); - menuMgr.setRemoveAllWhenShown(true); - menuMgr.addMenuListener(new IMenuListener() { - public void menuAboutToShow(IMenuManager manager) { - fillContextMenu(manager); - } - }); - - Menu menu = menuMgr.createContextMenu(viewer.getControl()); - - viewer.getControl().setMenu(menu); - getSite().registerContextMenu(menuMgr, viewer); - } - - private void fillContextMenu(IMenuManager manager) { - manager.add(giveDriverRoleAction); - manager.add(takeDriverRoleAction); - - // Other plug-ins can contribute there actions here - manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - } - - public void propertyChange(PropertyChangeEvent event) { - viewer.refresh(); - - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/ConnectDisconnectAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/ConnectDisconnectAction.java deleted file mode 100644 index 0977526ff336bb8fd7d09e61f6672c090c3cdd3a..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/ConnectDisconnectAction.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.jivesoftware.smack.XMPPConnection; - -import de.fu_berlin.inf.dpp.PreferenceConstants; -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.Saros.ConnectionState; -import de.fu_berlin.inf.dpp.net.IConnectionListener; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -public class ConnectDisconnectAction extends Action implements IConnectionListener { - - private IPropertyChangeListener propertyListener; - - public ConnectDisconnectAction() { - updateStatus(); - Saros.getDefault().addListener(this); - - propertyListener = new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals(PreferenceConstants.USERNAME)) { - updateStatus(); - } - } - }; - Saros.getDefault().getPreferenceStore().addPropertyChangeListener(propertyListener); - } - - @Override - public void run() { - new Thread(new Runnable() { - public void run() { - Saros saros = Saros.getDefault(); - boolean reconnect=false; - if (saros.getConnectionState() == Saros.ConnectionState.ERROR) - reconnect=true; - - if (saros.isConnected()) { - saros.disconnect(null); - } else { - saros.connect(reconnect); - } - } - }).start(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.IConnectionListener - */ - public void connectionStateChanged(XMPPConnection connection, ConnectionState newState) { - updateStatus(); - } - - private void updateStatus() { - ConnectionState state = Saros.getDefault().getConnectionState(); - - switch (state) { - case CONNECTED: - case CONNECTING: - setImageDescriptor(SarosUI.getImageDescriptor("/icons/connect.png")); - break; - - case ERROR: - case NOT_CONNECTED: - case DISCONNECTING: - setImageDescriptor(SarosUI.getImageDescriptor("/icons/disconnect.png")); - break; - } - - String username = Saros.getDefault().getPreferenceStore().getString( - PreferenceConstants.USERNAME); - - setEnabled(state == ConnectionState.CONNECTED - || ((state == ConnectionState.NOT_CONNECTED || state == ConnectionState.ERROR) && (username != null && username - .length() > 0))); - updateText(); - } - - private void updateText() { - ConnectionState state = Saros.getDefault().getConnectionState(); - String text = SarosUI.getDescription(state); - - setText(text); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/DeleteContactAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/DeleteContactAction.java deleted file mode 100644 index 1ccf0634dc648e9b73370976bc012e5994db7897..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/DeleteContactAction.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.actions.SelectionProviderAction; -import org.jivesoftware.smack.RosterEntry; -import org.jivesoftware.smack.XMPPException; - -import de.fu_berlin.inf.dpp.Saros; - -public class DeleteContactAction extends SelectionProviderAction { - private RosterEntry rosterEntry; - - public DeleteContactAction(ISelectionProvider provider) { - super(provider, "Delete"); - selectionChanged((IStructuredSelection)provider.getSelection()); - - setToolTipText("Set the nickname of this contact."); - - IWorkbench workbench = Saros.getDefault().getWorkbench(); - setImageDescriptor(workbench.getSharedImages().getImageDescriptor( - ISharedImages.IMG_TOOL_DELETE)); - } - - @Override - public void run() { - - Shell shell = Display.getDefault().getActiveShell(); - if (shell == null || rosterEntry == null) - return; - - if (MessageDialog.openQuestion(shell, "Confirm Delete", - "Are you sure you want to delete contact '" + rosterEntry.getName() + "' ('" - + rosterEntry.getUser() + "')?")) { - - try { - Saros.getDefault().removeContact(rosterEntry); - } catch (XMPPException e) { - e.printStackTrace(); - } - } - } - - @Override - public void selectionChanged(IStructuredSelection selection) { - Object selected = selection.getFirstElement(); - - if (selection.size() == 1 && selected instanceof RosterEntry) { - rosterEntry = (RosterEntry) selected; - setEnabled(true); - } else { - rosterEntry = null; - setEnabled(false); - } - - // TODO disable if user == self - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/FollowModeAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/FollowModeAction.java deleted file mode 100644 index ccb1b7ad164b708fa5dc4c91008fdac610dff5bc..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/FollowModeAction.java +++ /dev/null @@ -1,62 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.action.Action; - -import de.fu_berlin.inf.dpp.PreferenceConstants; -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.editor.EditorManager; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -public class FollowModeAction extends Action implements ISessionListener { - - private boolean isFollowMode = false; - - public FollowModeAction() { - super(); - setImageDescriptor(SarosUI.getImageDescriptor("/icons/monitor_add.png")); - setToolTipText("Enable/disable follow mode"); - - Saros.getDefault().getSessionManager().addSessionListener(this); - updateEnablement(); - } - - @Override - public void run() { - setFollowMode(!getFollowMode()); - } - - public boolean getFollowMode() { - return isFollowMode; - } - - public void setFollowMode(boolean isFollowMode) { - this.isFollowMode = isFollowMode; - EditorManager.getDefault().setEnableFollowing(isFollowMode); - } - - public void sessionStarted(ISharedProject session) { - // Automatically start follow mode at the beginning of a session if - // Auto-Follow-Mode is enabled. - if (Saros.getDefault().getPreferenceStore() - .getBoolean(PreferenceConstants.AUTO_FOLLOW_MODE)) { - setFollowMode(true); - } - updateEnablement(); - } - - public void sessionEnded(ISharedProject session) { - updateEnablement(); - } - - public void invitationReceived(IIncomingInvitationProcess process) { - // ignore - } - - private void updateEnablement() { - setEnabled(Saros.getDefault().getSessionManager().getSharedProject() != null); - setChecked(getFollowMode()); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/GiveDriverRoleAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/GiveDriverRoleAction.java deleted file mode 100644 index 9a8bd7a80d59fd179535aef4764ff5c1cce566c7..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/GiveDriverRoleAction.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.actions.SelectionProviderAction; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -public class GiveDriverRoleAction extends SelectionProviderAction implements - ISharedProjectListener, ISessionListener { - - private User selectedUser; - - public GiveDriverRoleAction(ISelectionProvider provider) { - super(provider, "Give driver role"); - setImageDescriptor(SarosUI.getImageDescriptor("icons/user_edit.png")); - setToolTipText("Give the driver role to this user"); - - Saros.getDefault().getSessionManager().addSessionListener(this); - updateEnablemnet(); - } - - @Override - public void run() { - ISharedProject project = Saros.getDefault().getSessionManager().getSharedProject(); - project.setDriver(selectedUser, false); - } - - @Override - public void selectionChanged(IStructuredSelection selection) { - selectedUser = (selection.size() == 1) ? (User) selection.getFirstElement() : null; - - updateEnablemnet(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - session.addListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - session.removeListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess process) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void driverChanged(JID driver, boolean replicated) { - updateEnablemnet(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void userJoined(JID user) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void userLeft(JID user) { - // ignore - } - - private void updateEnablemnet() { - ISharedProject project = Saros.getDefault().getSessionManager().getSharedProject(); - - boolean enabled = (project != null && selectedUser != null && project.isHost() && !project.isDriver(selectedUser)); - setEnabled(enabled); -// setEnabled(project != null && (project.isDriver() /*|| project.isHost()*/) -// && selectedUser != null && !project.getDriver().equals(selectedUser)); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/InviteAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/InviteAction.java deleted file mode 100644 index 58d4674d6556d32395ae1907cf4dc58cae4d8976..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/InviteAction.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.actions.SelectionProviderAction; -import org.jivesoftware.smack.RosterEntry; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISessionManager; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -/** - * @author rdjemili - */ -public class InviteAction extends SelectionProviderAction implements ISessionListener { - - private RosterEntry selectedEntry; - - public InviteAction(ISelectionProvider provider) { - super(provider, "Invite user to shared project.."); - selectionChanged((IStructuredSelection)provider.getSelection()); - - setToolTipText("Start a IM messaging session with this user"); - setImageDescriptor(SarosUI.getImageDescriptor("icons/transmit_blue.png")); - - Saros.getDefault().getSessionManager().addSessionListener(this); - } - - @Override - public void run() { - JID jid = new JID(selectedEntry.getUser()); - ISessionManager sessionManager = Saros.getDefault().getSessionManager(); - ISharedProject project = sessionManager.getSharedProject(); - - project.startInvitation(jid); - } - - @Override - public void selectionChanged(IStructuredSelection selection) { - if (selection.size() == 1 && selection.getFirstElement() instanceof RosterEntry) { - selectedEntry = (RosterEntry) selection.getFirstElement(); - } else { - selectedEntry = null; - } - - updateEnablement(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - updateEnablement(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - updateEnablement(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess process) { - // ignore - } - - private void updateEnablement() { - JID jid = (selectedEntry==null)?null:new JID(selectedEntry.getUser()); - - setEnabled(getSharedProject() != null && selectedEntry != null && - getSharedProject().getParticipant(jid)==null - && (getSharedProject().isHost() || getSharedProject().isDriver()) ); - } - - private ISharedProject getSharedProject() { - return Saros.getDefault().getSessionManager().getSharedProject(); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/JumpToDriverPositionAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/JumpToDriverPositionAction.java deleted file mode 100644 index 44a056abb0ee2b982d2f7768028e3a96248ef2b2..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/JumpToDriverPositionAction.java +++ /dev/null @@ -1,61 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.action.Action; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.editor.EditorManager; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -public class JumpToDriverPositionAction extends Action implements ISessionListener { - - public JumpToDriverPositionAction() { - setToolTipText("Jump to position of driver."); - setImageDescriptor(SarosUI.getImageDescriptor("icons/table_edit.png")); - - Saros.getDefault().getSessionManager().addSessionListener(this); - updateEnablement(); - } - - @Override - public void run() { - EditorManager.getDefault().openDriverEditor(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - updateEnablement(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - updateEnablement(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess process) { - // ignore - } - - private void updateEnablement() { - setEnabled(getSharedProject() != null); - } - - private ISharedProject getSharedProject() { - return Saros.getDefault().getSessionManager().getSharedProject(); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/LeaveSessionAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/LeaveSessionAction.java deleted file mode 100644 index 9d036b3f107b7deda4534b47b6ab828a5bd550e9..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/LeaveSessionAction.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.action.Action; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISessionManager; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -/** - * Leaves the current Saros session. Is deactivated if there is no running - * session. - * - * @author rdjemili - */ -public class LeaveSessionAction extends Action implements ISessionListener { - - public LeaveSessionAction() { - setToolTipText("Leave the session"); - setImageDescriptor(SarosUI.getImageDescriptor("/icons/door_open.png")); - - getSessionManager().addSessionListener(this); - updateEnablement(); - } - - @Override - public void run() { - try { - getSessionManager().leaveSession(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - updateEnablement(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - updateEnablement(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess process) { - // ignore - } - - private void updateEnablement() { - setEnabled(getSessionManager().getSharedProject() != null); - } - - private static ISessionManager getSessionManager() { - return Saros.getDefault().getSessionManager(); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/NewAccountAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/NewAccountAction.java deleted file mode 100644 index 9dff36fb908d841fa357333c30a8764735b2ec49..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/NewAccountAction.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.ui.wizards.CreateAccountWizard; - -public class NewAccountAction implements IWorkbenchWindowActionDelegate { - private IWorkbenchWindow window; - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate - */ - public void run(IAction action) { - try { - Shell shell = window.getShell(); - new WizardDialog(shell, new CreateAccountWizard(true, true, true)).open(); - } catch (Exception e) { - Saros.log("Could not create new Account.", e); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IWorkbenchWindowActionDelegate - */ - public void init(IWorkbenchWindow window) { - this.window = window; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate - */ - public void selectionChanged(IAction action, ISelection selection) { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IWorkbenchWindowActionDelegate - */ - public void dispose() { - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/NewContactAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/NewContactAction.java deleted file mode 100644 index 58220551dd1fe6b8f6307fe32722d578e6ec6634..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/NewContactAction.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.jivesoftware.smack.XMPPConnection; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.Saros.ConnectionState; -import de.fu_berlin.inf.dpp.net.IConnectionListener; -import de.fu_berlin.inf.dpp.ui.SarosUI; -import de.fu_berlin.inf.dpp.ui.wizards.AddContactWizard; - -public class NewContactAction extends Action implements IConnectionListener { - - public NewContactAction() { - setToolTipText("Add a new contact"); - setImageDescriptor(SarosUI.getImageDescriptor("/icons/user_add.png")); - - Saros.getDefault().addListener(this); - updateEnablement(); - } - - @Override - public void run() { - Shell shell = Display.getDefault().getActiveShell(); - new WizardDialog(shell, new AddContactWizard()).open(); - } - - public void connectionStateChanged(XMPPConnection connection, ConnectionState newState) { - updateEnablement(); - } - - private void updateEnablement() { - setEnabled(Saros.getDefault().isConnected()); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/NewSessionAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/NewSessionAction.java deleted file mode 100644 index ac7b02b83a3ba96f53cd2c041ab02a7ee0f0c67c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/NewSessionAction.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; -import org.jivesoftware.smack.XMPPException; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.project.ISessionManager; - -/** - * Start to share a project (a "session"). - * - * @author rdjemili - * - */ -public class NewSessionAction implements IObjectActionDelegate { - - private IProject selectedProject; - - /* - * (non-Javadoc) Defined in IActionDelegate - */ - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - } - - /* - * (non-Javadoc) Defined in IActionDelegate - */ - public void run(IAction action) { - try { - ISessionManager sm = Saros.getDefault().getSessionManager(); - sm.startSession(selectedProject); - } catch (final XMPPException e) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - ErrorDialog.openError(Display.getDefault().getActiveShell(), - "Error Starting Session", "Session could not be started", new Status( - Status.ERROR, "de.fu_berlin.inf.dpp", Status.ERROR, e.getMessage(), e)); - } - }); - } - } - - /* - * (non-Javadoc) Defined in IActionDelegate - */ - public void selectionChanged(IAction action, ISelection selection) { - selectedProject = getProject(selection); - - ISessionManager sm = Saros.getDefault().getSessionManager(); - boolean running = sm.getSharedProject() != null; - boolean connected = Saros.getDefault().isConnected(); - - // TODO This action should rather connect if not already connected - // instead of being disabled. - - action.setEnabled(connected && !running && selectedProject != null - && selectedProject.isAccessible()); - } - - private IProject getProject(ISelection selection) { - Object element = ((IStructuredSelection) selection).getFirstElement(); - if (element instanceof IProject) { - return (IProject) element; - } else if (element instanceof IJavaProject) { - return ((IJavaProject) element).getProject(); - } - - return null; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/OpenInviteInterface.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/OpenInviteInterface.java deleted file mode 100644 index 1fa096fa3c20ebae5af7b3e18102f81b93e9c9a3..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/OpenInviteInterface.java +++ /dev/null @@ -1,59 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.action.Action; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -public class OpenInviteInterface extends Action implements ISharedProjectListener,ISessionListener { - - public OpenInviteInterface() { - super(); - setImageDescriptor(SarosUI.getImageDescriptor("/icons/invites.png")); - setToolTipText("Open invitation interface"); - - Saros.getDefault().getSessionManager().addSessionListener(this); - updateEnablement(); - } - - @Override - public void run() { - Saros.getDefault().getSessionManager().getSharedProject().startInvitation(null); - } - - public void sessionStarted(ISharedProject session) { - session.addListener(this); - updateEnablement(); - } - - public void sessionEnded(ISharedProject session) { - session.removeListener(this); - updateEnablement(); - } - - public void invitationReceived(IIncomingInvitationProcess process) { - // ignore - } - - private void updateEnablement() { - ISharedProject project = Saros.getDefault().getSessionManager().getSharedProject(); - setEnabled(project != null && project.isDriver() ); - } - - public void driverChanged(JID driver, boolean replicated) { - updateEnablement(); - } - - public void userJoined(JID user) { - // ignore - } - - public void userLeft(JID user) { - // ignore - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/RemoveAllDriverRoleAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/RemoveAllDriverRoleAction.java deleted file mode 100644 index ab4b8003d02639f2fb79af530070c4862568028b..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/RemoveAllDriverRoleAction.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.action.Action; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.User.UserRole; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; -import de.fu_berlin.inf.dpp.ui.SarosUI; -/** - * this action remove all remote driver from project. Only the project host has - * the driver role after this action is executed. - * @author orieger - * - */ -public class RemoveAllDriverRoleAction extends Action implements ISharedProjectListener, - ISessionListener { - - public RemoveAllDriverRoleAction() { - super("Take remote user driver roles"); - setImageDescriptor(SarosUI.getImageDescriptor("icons/user_edit.png")); - setToolTipText("Take remote driver roles"); - - Saros.getDefault().getSessionManager().addSessionListener(this); - updateEnablement(); - } - - @Override - public void run() { -// getSharedProject().setDriver(getSharedProject().getHost(), false); - ISharedProject project = Saros.getDefault().getSessionManager().getSharedProject(); - for(User user : project.getParticipants()){ - - if(user.getUserRole() == UserRole.DRIVER && !project.getHost().equals(user)){ - project.removeDriver(user, false); - } - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - session.addListener(this); - updateEnablement(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - session.removeListener(this); - updateEnablement(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess process) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void driverChanged(JID driver, boolean replicated) { - updateEnablement(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void userJoined(JID user) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void userLeft(JID user) { - // ignore - } - - private void updateEnablement() { - ISharedProject project = getSharedProject(); - boolean enabled = (project != null && project.isHost()); - setEnabled(enabled); -// setEnabled(project != null && project.isHost() && !project.isDriver()); - } - - private ISharedProject getSharedProject() { - return Saros.getDefault().getSessionManager().getSharedProject(); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/RenameContactAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/RenameContactAction.java deleted file mode 100644 index d8bd59649bacc53e62cb061f45b0fdc523e379a7..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/RenameContactAction.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.dialogs.IInputValidator; -import org.eclipse.jface.dialogs.InputDialog; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.actions.SelectionProviderAction; -import org.jivesoftware.smack.RosterEntry; - -/** - * Renames the nickname of the selected roster entry. - * - * @author rdjemili - */ -public class RenameContactAction extends SelectionProviderAction { - private class InputValidator implements IInputValidator { - public String isValid(String newText) { - return null; - } - } - - private RosterEntry rosterEntry; - - public RenameContactAction(ISelectionProvider provider) { - super(provider, "Rename..."); - selectionChanged((IStructuredSelection)provider.getSelection()); - - setToolTipText("Set the nickname of this contact."); - } - - @Override - public void run() { - Shell shell = Display.getDefault().getActiveShell(); - if (shell == null || rosterEntry == null) - return; - - InputDialog dialog = new InputDialog(shell, "Set new nickname", - "Enter the new nickname of this contact '" + rosterEntry.getName() + "' ('" - + rosterEntry.getUser() + "'):", rosterEntry.getName(), new InputValidator()); - - if (dialog.open() == InputDialog.OK) { - String name = (dialog.getValue().length() == 0) ? "" : dialog.getValue(); - rosterEntry.setName(name); - } - } - - @Override - public void selectionChanged(IStructuredSelection selection) { - Object selected = selection.getFirstElement(); - - if (selection.size() == 1 && selected instanceof RosterEntry) { - rosterEntry = (RosterEntry) selected; - setEnabled(true); - } else { - rosterEntry = null; - setEnabled(false); - } - - // TODO disable if user == self - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/SkypeAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/SkypeAction.java deleted file mode 100644 index 59d194d278fa193a8604cda514930bdd9a4b45c8..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/SkypeAction.java +++ /dev/null @@ -1,56 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.text.Region; -import org.eclipse.jface.text.hyperlink.URLHyperlink; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.actions.SelectionProviderAction; -import org.jivesoftware.smack.RosterEntry; - -import de.fu_berlin.inf.dpp.SkypeManager; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -/** - * A action for skyping other users. - * - * @author rdjemili - */ -public class SkypeAction extends SelectionProviderAction { - private String skypeURL; - - public SkypeAction(ISelectionProvider provider) { - super(provider, "Skype this user"); - setEnabled(false); - - setToolTipText("Start a Skype-VoIP session with this user"); - setImageDescriptor(SarosUI.getImageDescriptor("icons/telephone.png")); - } - - @Override - public void run() { - if (skypeURL == null) - return; - - URLHyperlink link = new URLHyperlink(new Region(0, 0), skypeURL); - link.open(); - } - - @Override - public void selectionChanged(IStructuredSelection selection) { - final Object item = selection.getFirstElement(); - - if (selection.size() != 1 || !(item instanceof RosterEntry)) { - setEnabled(false); - - } else { - new Thread(new Runnable() { - public void run() { - setEnabled(false); - SkypeManager sm = SkypeManager.getDefault(); - skypeURL = sm.getSkypeURL((RosterEntry) item); - setEnabled(skypeURL != null); - } - }).start(); - } - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/TakeDriverRoleAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/TakeDriverRoleAction.java deleted file mode 100644 index ddca1f014efc3b3f4b6848b4e58e2521e83924b9..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/TakeDriverRoleAction.java +++ /dev/null @@ -1,109 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.actions.SelectionProviderAction; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -public class TakeDriverRoleAction extends SelectionProviderAction implements -ISharedProjectListener, ISessionListener { - private User selectedUser; - - public TakeDriverRoleAction(ISelectionProvider provider) { - super(provider, "Take driver role"); - setImageDescriptor(SarosUI.getImageDescriptor("icons/user.png")); - setToolTipText("Take the driver role from this user."); - - Saros.getDefault().getSessionManager().addSessionListener(this); - updateEnablemnet(); - } - - @Override - public void run() { - ISharedProject project = Saros.getDefault().getSessionManager().getSharedProject(); -// project.setDriver(selectedUser, false); - project.removeDriver(selectedUser, false); - } - - @Override - public void selectionChanged(IStructuredSelection selection) { - selectedUser = (selection.size() == 1) ? (User) selection.getFirstElement() : null; - - updateEnablemnet(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - session.addListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - session.removeListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess process) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void driverChanged(JID driver, boolean replicated) { - updateEnablemnet(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void userJoined(JID user) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void userLeft(JID user) { - // ignore - } - - private void updateEnablemnet() { - ISharedProject project = Saros.getDefault().getSessionManager().getSharedProject(); - - boolean enabled = (project != null - && selectedUser != null - && project.isHost() - && !project.getHost().equals(selectedUser) - && project.isDriver(selectedUser)); - setEnabled(enabled); -// setEnabled(project != null && (project.isDriver() /*|| project.isHost()*/) -// && selectedUser != null && !project.getDriver().equals(selectedUser)); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/decorators/SharedProjectDecorator.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/decorators/SharedProjectDecorator.java deleted file mode 100644 index 96c8c7bc9b7571842948f78eb298001ad1cce93d..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/decorators/SharedProjectDecorator.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.decorators; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IDecoration; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.ILightweightLabelDecorator; -import org.eclipse.jface.viewers.LabelProviderChangedEvent; -import org.eclipse.swt.widgets.Display; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.editor.EditorManager; -import de.fu_berlin.inf.dpp.editor.ISharedEditorListener; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISessionManager; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -/** - * Decorates Shared Project files. - * - * @see ILightweightLabelDecorator - */ -public class SharedProjectDecorator implements ILightweightLabelDecorator, ISessionListener, - ISharedEditorListener { - - private ImageDescriptor activeDescriptor = SarosUI.getImageDescriptor("icons/bullet_green.png"); // NON-NLS-1 - - private ImageDescriptor passiveDescriptor = SarosUI - .getImageDescriptor("icons/bullet_yellow.png"); // NON-NLS-1 - - private ISharedProject sharedProject; - - private List<ILabelProviderListener> listeners = new ArrayList<ILabelProviderListener>(); - - public SharedProjectDecorator() { - ISessionManager sessionManager = Saros.getDefault().getSessionManager(); - sessionManager.addSessionListener(this); - - if (sessionManager.getSharedProject() != null) { - sessionStarted(sessionManager.getSharedProject()); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate - */ - public void decorate(Object element, IDecoration decoration) { - if (sharedProject == null) - return; - - IFile file = (IFile) element; // enablement ensures that we only get - // IFile's - if (!sharedProject.getProject().equals(file.getProject())) - return; - - IPath path = file.getProjectRelativePath(); - if (path != null) { - EditorManager editorManager = EditorManager.getDefault(); - if (path.equals(editorManager.getActiveDriverEditor())) { - decoration.addOverlay(activeDescriptor, IDecoration.TOP_LEFT); - } else if (editorManager.getDriverEditors().contains(path)) { - decoration.addOverlay(passiveDescriptor, IDecoration.TOP_LEFT); - } - } - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener - */ - public void addListener(ILabelProviderListener listener) { - listeners.add(listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() - */ - public void dispose() { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty - */ - public boolean isLabelProperty(Object element, String property) { - return false; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener - */ - public void removeListener(ILabelProviderListener listener) { - listeners.remove(listener); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener#sessionStarted - */ - public void sessionStarted(ISharedProject session) { - sharedProject = session; - EditorManager.getDefault().addSharedEditorListener(this); - - updateDecorators(null); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener#sessionEnded - */ - public void sessionEnded(ISharedProject session) { - if (sharedProject != null) - EditorManager.getDefault().removeSharedEditorListener(this); - - sharedProject = null; - updateDecorators(null); - } - - public void invitationReceived(IIncomingInvitationProcess process) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProjectListener - */ - public void activeDriverEditorChanged(IPath path, boolean replicated) { - updateDecorators(null); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProjectListener - */ - public void driverEditorRemoved(IPath path, boolean replicated) { - updateDecorators(null); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProjectListener - */ - public void driverEditorSaved(IPath path, boolean replicated) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.ISharedEditorListener - */ - public void followModeChanged(boolean enabled) { - // ignore - } - - private void updateDecorators(final Object[] updateElements) { - // Set<IFile> changedFiles = new HashSet<IFile>(); - // - // if (sharedProject != null) { - // if (sharedProject.getActiveDriverEditor() != null) { - // activeFile = sharedProject.getProject().getFile( - // sharedProject.getActiveDriverEditor()); - // - // } else if (sharedProject.getDriverEditors() != null) { - // passiveFiles = - // } - // } - // - // final Object[] updateElements; - // if (activeDriverFile == null) { - // updateElements = new Object[]{activeFile}; - // } else if (activeFile == null) { - // updateElements = new Object[]{activeDriverFile}; - // } else { - // updateElements = new Object[]{activeDriverFile, activeFile}; - // } - // - // activeDriverFile = activeFile; - - Display.getDefault().asyncExec(new Runnable() { - public void run() { - LabelProviderChangedEvent event = new LabelProviderChangedEvent( - SharedProjectDecorator.this, updateElements); - - for (ILabelProviderListener listener : listeners) { - listener.labelProviderChanged(event); - } - } - }); - } -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/AddContactWizard.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/AddContactWizard.java deleted file mode 100644 index 2377ad20a5111563a31780f7e2593cdd36a8e653..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/AddContactWizard.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.wizards; - -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.net.JID; - -public class AddContactWizard extends Wizard { - - private class AddContactPage extends WizardPage { - private Text idText; - - private Text nicknameText; - - protected AddContactPage() { - super("create"); - - setTitle("New Contact"); - setDescription("Add a new contact to your Jabber roster"); - } - - public void createControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - - composite.setLayout(new GridLayout(2, false)); - - Label idLabel = new Label(composite, SWT.NONE); - idLabel.setText("Jabber ID"); - - idText = new Text(composite, SWT.BORDER); - idText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - - Label nicknameLabel = new Label(composite, SWT.NONE); - nicknameLabel.setText("Nickname"); - - nicknameText = new Text(composite, SWT.BORDER); - nicknameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - - hookListeners(); - updateNextEnablement(); - - setControl(composite); - } - - public JID getJID() { - return new JID(idText.getText()); - } - - public String getNickname() { - return nicknameText.getText(); - } - - private void hookListeners() { - ModifyListener listener = new ModifyListener() { - public void modifyText(ModifyEvent e) { - updateNextEnablement(); - } - }; - - idText.addModifyListener(listener); - nicknameText.addModifyListener(listener); - } - - private void updateNextEnablement() { - boolean done = idText.getText().length() > 0 && nicknameText.getText().length() > 0; - - setPageComplete(done); - } - } - - private AddContactPage page = new AddContactPage(); - - public AddContactWizard() { - setWindowTitle("New Contact"); - setHelpAvailable(false); - } - - @Override - public void addPages() { - addPage(page); - } - - @Override - public boolean performFinish() { - try { - Saros.getDefault().addContact(page.getJID(), page.getNickname(), null); - return true; - - } catch (Exception e) { - page.setMessage(e.getMessage(), IMessageProvider.ERROR); - e.printStackTrace(); - } - - return false; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/ConfigurationWizard.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/ConfigurationWizard.java deleted file mode 100644 index 3d449c687b50d78fb24f8fb2c8a39d16159dbb9c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/ConfigurationWizard.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.wizards; - -import java.util.LinkedList; -import java.util.List; - -import org.eclipse.jface.wizard.Wizard; - -/** - * A wizard to configure Saros. - * - */ -public class ConfigurationWizard extends Wizard { - - public ConfigurationWizard() { - setWindowTitle("Saros Configuration"); - setHelpAvailable(false); - setNeedsProgressMonitor(true); - - wizards.add(new RegisterAccountPage(false, false, true)); - wizards.add(new NetworkSettingsPage()); - } - - List<IWizardPage2> wizards = new LinkedList<IWizardPage2>(); - - @Override - public void addPages() { - for (IWizardPage2 wizard : wizards){ - addPage(wizard); - } - } - - @Override - public boolean performFinish() { - - for (IWizardPage2 wizard : wizards){ - if (!wizard.performFinish()){ - getContainer().showPage(wizard); - return false; - } - } - - return true; - } - - @Override - public boolean performCancel() { - return true; - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/CreateAccountWizard.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/CreateAccountWizard.java deleted file mode 100644 index 66f0882c7441696ae666fbba162793d700564153..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/CreateAccountWizard.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * (c) Christopher Oezbek - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.wizards; - -import org.eclipse.jface.wizard.Wizard; - -/** - * An wizard that is used to create Jabber accounts. - * - * @author rdjemili - * @author coezbek - */ -public class CreateAccountWizard extends Wizard { - - private RegisterAccountPage page; - - public CreateAccountWizard(boolean createAccount, boolean showStoreInPrefsButton, boolean storeInPrefsDefault) { - - if (createAccount){ - setWindowTitle("Create New User Account"); - } else { - setWindowTitle("Enter User Account"); - } - page = new RegisterAccountPage(createAccount, showStoreInPrefsButton, storeInPrefsDefault); - setHelpAvailable(false); - setNeedsProgressMonitor(true); - } - - public String getServer() { - return server; - } - - public String getUsername() { - return username; - } - - public String getPassword() { - return password; - } - - String server, password, username; - - @Override - public void addPages() { - addPage(page); - } - - @Override - public boolean performFinish() { - if (page.performFinish()){ - server = page.getServer(); - username = page.getUsername(); - password = page.getPassword(); - - return true; - } else { - return false; - } - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/EnterNamePage.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/EnterNamePage.java deleted file mode 100644 index 4153f6c25915304c4905a2b7dcf281b765c475fb..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/EnterNamePage.java +++ /dev/null @@ -1,428 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.wizards; - -import java.lang.reflect.InvocationTargetException; -import java.util.logging.Level; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.dialogs.ContainerSelectionDialog; - -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess.State; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess.TransferMode; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -/** - * A wizard page that allows to enter the new project name or to choose to - * overwrite the project selected by the {@link ProjectSelectionPage}. - */ -class EnterNamePage extends WizardPage { - - private JoinSessionWizard joinSessionWizard; - - private Label newProjectNameLabel; - private Button projCopy; - private Text newProjectNameText; - private Button copyCheckbox; - private Text copyToBeforeUpdateText; - - private Button projUpd; - private Text updateProjectText; - private Button browseUpdateProjectButton; - - private Label updateProjectStatusResult; - private Label updateProjectNameLabel; - private Button scanWorkspaceProjectsButton; - - /* project for update or base project for copy into new project */ - private IProject similarProject; - - protected EnterNamePage(JoinSessionWizard joinSessionWizard) { - super("namePage"); - this.joinSessionWizard = joinSessionWizard; - setPageComplete(false); - - setTitle("Select local project."); - - setConnectionStatus(); - } - - protected void setUpdateProject(IProject project) { - this.similarProject = project; - - if (project == null) { - - updateProjectStatusResult - .setText("No matching project found. Project download will start from scratch."); - - } else { - - updateProjectStatusResult.setText("Your project " - + project.getName() - + " matches with " - + JoinSessionWizardUtils.getMatch(this.joinSessionWizard.process - .getRemoteFileList(), project) + "% accuracy.\n" - + "This fact will used to shorten the process of " - + "downloading the remote project."); - - updateProjectText.setText(similarProject.getName()); - - } - updatePageComplete(); - } - - /** - * get transfer mode and set header information of the wizard. - */ - private void setConnectionStatus() { - if (this.joinSessionWizard.process.getTransferMode() == TransferMode.IBB) { - setDescription("Attention: No direct connection avialable!" + '\n' - + "Suggestion: Update an existing project or copy resources from another project."); - setImageDescriptor(SarosUI.getImageDescriptor("icons/ibb_connection.png")); - } else { - setDescription("P2P Connection with Jingle available.\nThis means that sharing a project from scratch will be fast."); - setImageDescriptor(SarosUI.getImageDescriptor("icons/jingle_connection.png")); - } - } - - /** - * create components of create new project area for enternamepage wizard. - * - * @param workArea - * composite of appropriate wizard - */ - private void createNewProjectGroup(Composite workArea) { - - Composite projectGroup = new Composite(workArea, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - layout.makeColumnsEqualWidth = false; - layout.marginWidth = 0; - projectGroup.setLayout(layout); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalIndent = 10; - - projectGroup.setLayoutData(data); - - newProjectNameLabel = new Label(projectGroup, SWT.NONE); - newProjectNameLabel.setText("Project name"); - - newProjectNameText = new Text(projectGroup, SWT.BORDER); - newProjectNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL - | GridData.GRAB_HORIZONTAL)); - newProjectNameText.setFocus(); - newProjectNameText.setText(JoinSessionWizardUtils - .findProjectNameProposal(this.joinSessionWizard.process.getProjectName())); - } - - /** - * create components of update area for enternamepage wizard. - * - * @param workArea - * composite of appropriate wizard - */ - private void createUpdateProjectGroup(Composite workArea) { - - Composite projectGroup = new Composite(workArea, SWT.NONE); - - GridLayout layout = new GridLayout(); - layout.numColumns = 4; - layout.makeColumnsEqualWidth = false; - layout.marginWidth = 0; - projectGroup.setLayout(layout); - - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalIndent = 10; - projectGroup.setLayoutData(data); - - updateProjectNameLabel = new Label(projectGroup, SWT.NONE); - updateProjectNameLabel.setText("Project name"); - updateProjectNameLabel.setEnabled(false); - - updateProjectText = new Text(projectGroup, SWT.BORDER); - updateProjectText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL - | GridData.GRAB_HORIZONTAL)); - updateProjectText.setFocus(); - updateProjectText.setEnabled(false); - updateProjectText.setText(""); - - browseUpdateProjectButton = new Button(projectGroup, SWT.PUSH); - browseUpdateProjectButton.setText("Browse"); - setButtonLayoutData(browseUpdateProjectButton); - browseUpdateProjectButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - IProject project = getProjectDialog("Select project for update."); - if (project != null) { - updateProjectText.setText(project.getName()); - } - } - }); - - Composite optionsGroup = new Composite(workArea, SWT.NONE); - layout = new GridLayout(); - layout.numColumns = 2; - layout.marginLeft = 20; - layout.makeColumnsEqualWidth = false; - layout.marginWidth = 0; - - optionsGroup.setLayout(layout); - optionsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - copyCheckbox = new Button(optionsGroup, SWT.CHECK); - copyCheckbox.setText("Create copy for working distributed. New project name:"); - copyCheckbox.setSelection(false); - copyCheckbox.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateEnabled(); - } - }); - - copyToBeforeUpdateText = new Text(optionsGroup, SWT.BORDER); - copyToBeforeUpdateText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL - | GridData.GRAB_HORIZONTAL)); - copyToBeforeUpdateText.setFocus(); - copyToBeforeUpdateText.setText(JoinSessionWizardUtils - .findProjectNameProposal(joinSessionWizard.process.getProjectName())); - - Composite scanGroup = new Composite(workArea, SWT.NONE); - layout = new GridLayout(); - layout.numColumns = 2; - layout.makeColumnsEqualWidth = false; - layout.marginWidth = 10; - scanGroup.setLayout(layout); - data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_VERTICAL); - data.verticalIndent = 10; - data.horizontalIndent = 10; - scanGroup.setLayoutData(data); - - scanWorkspaceProjectsButton = new Button(scanGroup, SWT.PUSH); - scanWorkspaceProjectsButton.setText("Scan workspace"); - scanWorkspaceProjectsButton.setToolTipText("Scan workspace for similar projects."); - setButtonLayoutData(scanWorkspaceProjectsButton); - - scanWorkspaceProjectsButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - setUpdateProject(JoinSessionWizardUtils.getBestScanMatch(joinSessionWizard.process)); - } - }); - - updateProjectStatusResult = new Label(scanGroup, SWT.NONE); - updateProjectStatusResult.setText("No scan results."); - updateProjectStatusResult.setLayoutData(new GridData(GridData.FILL_HORIZONTAL - | GridData.GRAB_VERTICAL)); - } - - /** - * browse dialog to select project for copy. - */ - public IProject getProjectDialog(String title) { - ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), null, false, - title); - - dialog.open(); - Object[] result = dialog.getResult(); - - if (result == null && result.length == 0) { - return null; - } - - return ((IResource) result[0]).getProject(); - } - - protected void createScanStatusProject(Composite workArea) { - - - } - - protected void requestRemoteFileList() { - try { - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) { - EnterNamePage.this.joinSessionWizard.process.requestRemoteFileList(monitor); - } - }); - } catch (InvocationTargetException e) { - JoinSessionWizard.log.log(Level.WARNING, "Exception while requesting remote file list", - e); - } catch (InterruptedException e) { - JoinSessionWizard.log.log(Level.FINE, - "Request of remote file list canceled/interrupted", e); - } - } - - public void createControl(Composite parent) { - - if (joinSessionWizard.process.getState() == State.CANCELED) - return; - - /* wait for getting project file list. */ - requestRemoteFileList(); - - if (joinSessionWizard.process.getRemoteFileList() == null) - getShell().close(); - - Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new GridLayout()); - GridData gridData = new GridData(GridData.FILL_VERTICAL); - gridData.verticalIndent = 20; - composite.setLayoutData(gridData); - - projCopy = new Button(composite, SWT.RADIO); - projCopy.setText("Create new project"); - projCopy.setSelection(true); - - createNewProjectGroup(composite); - - projUpd = new Button(composite, SWT.RADIO); - projUpd.setText("Use existing project"); - - createUpdateProjectGroup(composite); - - attachListeners(); - setControl(composite); - - updateEnabled(); - } - - public boolean isUpdateSelected() { - return projUpd.getSelection(); - } - - private void attachListeners() { - - ModifyListener m = new ModifyListener() { - public void modifyText(ModifyEvent e) { - updatePageComplete(); - } - }; - - newProjectNameText.addModifyListener(m); - updateProjectText.addModifyListener(m); - copyToBeforeUpdateText.addModifyListener(m); - - SelectionAdapter s = new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateEnabled(); - } - }; - - projCopy.addSelectionListener(s); - - s.widgetSelected(null); - } - - public void setPageCompleteTargetProject(String newText) { - - if (newText.length() == 0) { - setMessage(null); - setErrorMessage("Please set a project name"); - setPageComplete(false); - } else { - if (JoinSessionWizardUtils.projectIsUnique(newText)) { - setMessage(null); - setErrorMessage(null); - setPageComplete(true); - } else { - setMessage(null); - setErrorMessage("A project with this name already exists"); - setPageComplete(false); - } - } - } - - protected void updateEnabled() { - - boolean updateSelected = !projCopy.getSelection(); - boolean copySelected = copyCheckbox.getSelection(); - - newProjectNameText.setEnabled(!updateSelected); - newProjectNameLabel.setEnabled(!updateSelected); - - updateProjectText.setEnabled(updateSelected); - browseUpdateProjectButton.setEnabled(updateSelected); - updateProjectNameLabel.setEnabled(updateSelected); - copyCheckbox.setEnabled(updateSelected); - copyToBeforeUpdateText.setEnabled(updateSelected && copySelected); - scanWorkspaceProjectsButton.setEnabled(updateSelected); - updateProjectStatusResult.setEnabled(updateSelected); - - updatePageComplete(); - } - - protected void updatePageComplete() { - - if (!isUpdateSelected()) { - - setPageCompleteTargetProject(newProjectNameText.getText()); - - } else { - String newText = updateProjectText.getText(); - - if (newText.length() == 0) { - setMessage(null); - setErrorMessage("Please set a project name to update from or press 'Scan Workspace' to find best matching existing project"); - setPageComplete(false); - - } else { - if (!JoinSessionWizardUtils.projectIsUnique(newText)) { - - if (copyCheckbox.getSelection()) { - setPageCompleteTargetProject(copyToBeforeUpdateText.getText()); - } else { - setMessage(null); - setErrorMessage(null); - setPageComplete(true); - } - - } else { - setMessage(null); - setErrorMessage("No project exists with this name to update from"); - setPageComplete(false); - } - } - } - } - - public String getTargetProjectName() { - if (isUpdateSelected()) { - - if (copyCheckbox.getSelection()) { - return copyToBeforeUpdateText.getText(); - } else { - return null; - } - } else { - return newProjectNameText.getText(); - } - } - - public IProject getSourceProject() { - - if (isUpdateSelected()) { - if (copyCheckbox.getSelection()) { - return ResourcesPlugin.getWorkspace().getRoot().getProject( - copyToBeforeUpdateText.getText()); - } else { - return ResourcesPlugin.getWorkspace().getRoot().getProject( - updateProjectText.getText()); - } - } else { - return null; - } - } -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/IWizardPage2.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/IWizardPage2.java deleted file mode 100644 index 44dc94206747c0c63bf8cac1e519e153100d9de7..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/IWizardPage2.java +++ /dev/null @@ -1,9 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.wizards; - -import org.eclipse.jface.wizard.IWizardPage; - -public interface IWizardPage2 extends IWizardPage { - - public boolean performFinish(); - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/JoinSessionWizard.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/JoinSessionWizard.java deleted file mode 100644 index f01a6841727747fb2c5e1ca16ee1919acb571a2b..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/JoinSessionWizard.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.wizards; - -import java.lang.reflect.InvocationTargetException; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; - -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess.IInvitationUI; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess.State; -import de.fu_berlin.inf.dpp.net.JID; - -/** - * A wizard that guides the user through an incoming invitiation process. - * - * Todo: - * - * o Automatically switch to follow mode - * - * o Suggest if the project is a CVS project that the user checks it out and - * offers an option to transfer the settings - * - * @author rdjemili - */ -public class JoinSessionWizard extends Wizard { - - static Logger log = Logger.getLogger(JoinSessionWizard.class.getName()); - - ShowDescriptionPage descriptionPage; - - EnterNamePage namePage; - - WizardDialogAccessable myWizardDlg; - - IIncomingInvitationProcess process; - - Display current; - - public JoinSessionWizard(IIncomingInvitationProcess process) { - this.process = process; - - current = Display.getCurrent(); - - setWindowTitle("Session Invitation"); - setHelpAvailable(false); - setNeedsProgressMonitor(true); - } - - public IInvitationUI getInvitationUI() { - return new IInvitationUI(){ - - public void cancel(final String errorMsg, final boolean replicated) { - current.asyncExec(new Runnable() { - public void run() { - - if (errorMsg != null){ - MessageDialog.openError(getShell(), "Invitation aborted", - "Could not complete invitation because an error occurred (" + errorMsg + ")"); - } else { - // errorMsg == null means canceled either by us or peer - if (replicated){ - MessageDialog.openInformation(getShell(), "Invitation cancelled", - "Invitation was cancelled by peer."); - } - } - myWizardDlg.close(); - } - }); - } - - public void runGUIAsynch(Runnable runnable) { - // ignored, not needed atm - } - - public void updateInvitationProgress(JID jid) { - // ignored, not needed atm - } - }; - } - - @Override - public void createPageControls(Composite pageContainer) { - descriptionPage.createControl(pageContainer); - // create namePage lazily - } - - @Override - public void addPages() { - descriptionPage = new ShowDescriptionPage(this); - namePage = new EnterNamePage(this); - - addPage(descriptionPage); - addPage(namePage); - } - - @Override - public boolean performFinish() { - - if (process.getState() == State.CANCELED) - return true; - - final IProject source = namePage.getSourceProject(); - final String target = namePage.getTargetProjectName(); - - try { - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { - - process.accept(source, target, monitor); - } - }); - } catch (InvocationTargetException e) { - log.log(Level.WARNING, "Exception while requesting remote file list", e); - } catch (InterruptedException e) { - log.log(Level.FINE, "Request of remote file list canceled/interrupted", e); - } - - return true; - } - - @Override - public boolean performCancel() { - process.cancel(null, false); - - return super.performCancel(); - } - - public void setWizardDlg(WizardDialogAccessable wd) { - myWizardDlg = wd; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/JoinSessionWizardUtils.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/JoinSessionWizardUtils.java deleted file mode 100644 index 73cebc02dc89096db303b0877a53386f85edc9f3..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/JoinSessionWizardUtils.java +++ /dev/null @@ -1,176 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.wizards; - -import java.lang.reflect.InvocationTargetException; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.widgets.Display; - -import de.fu_berlin.inf.dpp.FileList; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; - -public class JoinSessionWizardUtils { - - private static Logger log = Logger.getLogger(JoinSessionWizardUtils.class.getName()); - - public static class ScanRunner implements Runnable { - - public ScanRunner(IIncomingInvitationProcess invitationProcess){ - this.invitationProcess = invitationProcess; - } - - IIncomingInvitationProcess invitationProcess; - - boolean running; - - IProject project; - - public void run() { - running = true; - - ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getDefault() - .getActiveShell()); - try { - dialog.run(true, false, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) { - - monitor.beginTask("Scanning workspace projects ... ", - IProgressMonitor.UNKNOWN); - project = getLocalProject(invitationProcess.getRemoteFileList(), monitor); - monitor.done(); - running = false; - } - - }); - } catch (InvocationTargetException e) { - log.log(Level.WARNING, "", e); - e.printStackTrace(); - } catch (InterruptedException e) { - log.log(Level.WARNING, "", e); - e.printStackTrace(); - } - } - } - - /** - * Run the scan for the best matching project as a blocking operation. - */ - public static IProject getBestScanMatch(IIncomingInvitationProcess invitationProcess) { - - ScanRunner runner = new ScanRunner(invitationProcess); - - Display.getDefault().syncExec(runner); - - return runner.project; - } - - public static int getMatch(FileList remoteFileList, IProject project) { - try { - return remoteFileList.match(new FileList(project)); - } catch (CoreException e) { - log.log(Level.FINE, "Couldn't calculate match for project " + project, e); - - return -1; - } - } - - /** - * Return the best match among all project from workspace with the given - * remote file list or null if no best match could be found. - * - * To be considered a match, projects have to match at least 80%. - */ - public static IProject getLocalProject(FileList remoteFileList, IProgressMonitor monitor) { - - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IProject[] projects = workspace.getRoot().getProjects(); - - IProject bestMatch = null; - - // A match needs to be at least 80% for us to consider. - int bestMatchScore = 80; - - for (int i = 0; i < projects.length; i++) { - monitor.worked(1); - if (!projects[i].isOpen()) - continue; - - int matchScore = getMatch(remoteFileList, projects[i]); - - if (matchScore > bestMatchScore) { - bestMatchScore = matchScore; - bestMatch = projects[i]; - } - } - - return bestMatch; - } - - public static boolean projectIsUnique(String name) { - - // Then check with all the projects - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IProject[] projects = workspace.getRoot().getProjects(); - - return projectIsUnique(name, projects); - } - - public static IProject getProjectForName(String name){ - return ResourcesPlugin.getWorkspace().getRoot().getProject(name); - } - - public static boolean projectIsUnique(String name, IProject[] projects) { - - for (int i = 0; i < projects.length; i++) { - IProject p = projects[i]; - if (p.getName().equals(name)) - return false; - } - return true; - } - - public static String findProjectNameProposal(String projectName) { - - // Start with the projects name - String projectProposal = projectName; - - // Then check with all the projects - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IProject[] projects = workspace.getRoot().getProjects(); - - if (projectIsUnique(projectProposal, projects)) { - return projectProposal; - - } else { - // Name is already in use! - Pattern p = Pattern.compile("^(.*)(\\d+)$"); - Matcher m = p.matcher(projectProposal); - - int i; - // Check whether the name ends in a number or not - if (m.find()) { - projectProposal = m.group(1).trim(); - i = Integer.parseInt(m.group(2)); - } else { - i = 2; - } - - // Then find the next available number - while (!projectIsUnique(projectProposal + " " + i, projects)) { - i++; - } - - return projectProposal + " " + i; - } - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/NetworkSettingsPage.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/NetworkSettingsPage.java deleted file mode 100644 index 80802d0681e6ca7d65d5967d1942e68a1e0171ca..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/NetworkSettingsPage.java +++ /dev/null @@ -1,121 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.wizards; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -import de.fu_berlin.inf.dpp.PreferenceConstants; -import de.fu_berlin.inf.dpp.Saros; - -/** - * A Wizard Page for entering the Port Configuration. - * - * @author rdjemili - * - */ -public class NetworkSettingsPage extends WizardPage implements IWizardPage2 { - - protected NetworkSettingsPage() { - super("networksettings"); - } - private Text portText, skypeText; - private Button autoText; - - public void createControl(Composite parent) { - - Composite root = new Composite(parent, SWT.NONE); - - root.setLayout(new GridLayout(2, false)); - - setTitle("Configure Network Settings"); - setDescription("Configure your network settings for use with Saros"); - - Label portDescription = new Label(root, SWT.NONE); - GridData twoColumn = new GridData(); - twoColumn.horizontalSpan = 2; - portDescription.setLayoutData(twoColumn); - portDescription.setText("Choose your incoming port and configure your firewall to accept incoming connections over this port."); - - Label serverLabel = new Label(root, SWT.NONE); - serverLabel.setText("Port:"); - - portText = new Text(root, SWT.BORDER); - portText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - - Label autoConnectDesc = new Label(root, SWT.NONE); - autoConnectDesc.setLayoutData(twoColumn); - autoConnectDesc.setText("Should Saros automatically connect on Eclipse startup?"); - - new Label(root, SWT.NONE); - - autoText = new Button(root, SWT.CHECK | SWT.LEFT); - autoText.setText("Startup automatically."); - - Label skypeDesc = new Label(root, SWT.NONE); - skypeDesc.setLayoutData(twoColumn); - skypeDesc.setText("Saros can send your Skype username to your peer if you provide it here"); - - Label skype = new Label(root, SWT.NONE); - skype.setText("Skype Username:"); - skypeText = new Text(root, SWT.BORDER); - skypeText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - - - // Set initial values - IPreferenceStore preferences = Saros.getDefault().getPreferenceStore(); - portText.setText(String.valueOf(preferences.getInt(PreferenceConstants.FILE_TRANSFER_PORT))); - autoText.setSelection(preferences.getBoolean(PreferenceConstants.AUTO_CONNECT)); - skypeText.setText(preferences.getString(PreferenceConstants.SKYPE_USERNAME)); - - ModifyListener m = new ModifyListener() { - public void modifyText(ModifyEvent e) { - update(); - } - }; - - portText.addModifyListener(m); - - autoText.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - update(); - } - }); - - - skypeText.addModifyListener(m); - - update(); - - setControl(root); - } - - private void update() { - try { - Integer.parseInt(portText.getText()); - setPageComplete(true); - setErrorMessage(null); - } catch (Exception e){ - setPageComplete(false); - setErrorMessage("Port should a number (for instance 7777)"); - } - } - - public boolean performFinish() { - IPreferenceStore preferences = Saros.getDefault().getPreferenceStore(); - preferences.setValue(PreferenceConstants.FILE_TRANSFER_PORT, portText.getText()); - preferences.setValue(PreferenceConstants.AUTO_CONNECT, autoText.getSelection()); - preferences.setValue(PreferenceConstants.SKYPE_USERNAME, skypeText.getText()); - - return true; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/PrivacyPage.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/PrivacyPage.java deleted file mode 100644 index d60cf2877a458ded91b2a434651608ecf7e4ade2..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/PrivacyPage.java +++ /dev/null @@ -1,39 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.wizards; - -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; - -public class PrivacyPage extends WizardPage implements IWizardPage2 { - - protected PrivacyPage() { - super("PrivacyPage"); - } - - public void createControl(Composite parent) { - - Composite root = new Composite(parent, SWT.NONE); - - root.setLayout(new GridLayout(2, false)); - - setTitle("Configure Privacy Setting"); - setDescription("Saros is a research project and we are very interested in understanding how people use distributed pair programming."); - - - // Of course we respect your privacy and give you full control over which information you would like to share. - Label portDescription = new Label(root, SWT.NONE); - GridData twoColumn = new GridData(); - twoColumn.horizontalSpan = 3; - portDescription.setLayoutData(twoColumn); - portDescription.setText("Share aggregated anonymous data"); - - setControl(root); - } - - public boolean performFinish() { - return true; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/PropertyConfigurationWizard.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/PropertyConfigurationWizard.java deleted file mode 100644 index ac663a128635611adec368114d7c5c033eaa93fb..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/PropertyConfigurationWizard.java +++ /dev/null @@ -1,28 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.wizards; - -import org.eclipse.jface.wizard.Wizard; - -public class PropertyConfigurationWizard extends Wizard { - - public PropertyConfigurationWizard() { - setWindowTitle("Saros Configuration"); - setHelpAvailable(false); - setNeedsProgressMonitor(true); - } - - private NetworkSettingsPage firewallPage; - - @Override - public void addPages() { - firewallPage = new NetworkSettingsPage(); - addPage(firewallPage); - } - - @Override - public boolean performFinish() { - return firewallPage.performFinish(); - } - - - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/RegisterAccountPage.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/RegisterAccountPage.java deleted file mode 100644 index 0cfb4868c952d45eb1c472a8e8326335ec2e57e8..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/RegisterAccountPage.java +++ /dev/null @@ -1,295 +0,0 @@ -/** - * - */ -package de.fu_berlin.inf.dpp.ui.wizards; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.DialogPage; -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.jivesoftware.smack.XMPPException; - -import de.fu_berlin.inf.dpp.PreferenceConstants; -import de.fu_berlin.inf.dpp.Saros; - -public class RegisterAccountPage extends WizardPage implements IWizardPage2 { - - private Text serverText; - - private Text userText; - - private Text passwordText; - - private Text repeatPasswordText; - - private Button prefButton; - - private boolean createAccount; - - private boolean showPrefButton; - - private boolean storePreferences; - - public RegisterAccountPage() { - this(true, true, true); - } - - public RegisterAccountPage(boolean createAccount, boolean showPrefButton, boolean storePreferences) { - super("create"); - this.createAccount = createAccount; - this.showPrefButton = showPrefButton; - this.storePreferences = storePreferences; - } - - public void createControl(Composite parent) { - Composite root = new Composite(parent, SWT.NONE); - - root.setLayout(new GridLayout(2, false)); - - if (createAccount) { - setTitle("Create New User Account"); - setDescription("Create a new user account for a Jabber server"); - } else { - setTitle("Enter User Account"); - setDescription("Enter your account information and Jabber server"); - } - - Label serverLabel = new Label(root, SWT.NONE); - serverLabel.setText("Jabber Server"); - - serverText = new Text(root, SWT.BORDER); - serverText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - serverText.setText("jabber.org"); - - Label userLabel = new Label(root, SWT.NONE); - userLabel.setText("Username"); - - userText = new Text(root, SWT.BORDER); - userText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - - Label pwLabel = new Label(root, SWT.NONE); - pwLabel.setText("Password"); - - passwordText = new Text(root, SWT.BORDER); - passwordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - passwordText.setEchoChar('*'); - - Label rpwLabel = new Label(root, SWT.NONE); - rpwLabel.setText("Repeat Password"); - - repeatPasswordText = new Text(root, SWT.BORDER); - repeatPasswordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - repeatPasswordText.setEchoChar('*'); - - if (showPrefButton) { - prefButton = new Button(root, SWT.CHECK | SWT.SEPARATOR); - prefButton.setSelection(storePreferences); - prefButton.setText("Store the new configuration in your preferences."); - prefButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); - } - - if (!createAccount) { - - Button createAccountButton = new Button(root, SWT.NONE); - createAccountButton.setText("Create Account"); - createAccountButton.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - } - - public void widgetSelected(SelectionEvent e) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - try { - Shell shell = Display.getDefault().getActiveShell(); - - CreateAccountWizard wizard = new CreateAccountWizard(true, false, false); - boolean success = Window.OK == new WizardDialog(shell, wizard).open(); - - if (success){ - RegisterAccountPage.this.passwordText.setText(wizard.getPassword()); - RegisterAccountPage.this.repeatPasswordText.setText(wizard.getPassword()); - RegisterAccountPage.this.serverText.setText(wizard.getServer()); - RegisterAccountPage.this.userText.setText(wizard.getUsername()); - } - - } catch (Exception e) { - Saros.getDefault().getLog().log( - new Status(IStatus.ERROR, Saros.SAROS, IStatus.ERROR, - "Error while running enter account wizard", e)); - } - } - }); - } - }); - } - - setInitialValues(); - - hookListeners(); - updateNextEnablement(); - - setControl(root); - } - - public String getServer() { - return serverText.getText(); - } - - public String getUsername() { - return userText.getText(); - } - - public String getPassword() { - return passwordText.getText(); - } - - public boolean isStoreInPreferences() { - if (showPrefButton) { - return prefButton.getSelection(); - } - return storePreferences; - } - - private void hookListeners() { - ModifyListener listener = new ModifyListener() { - public void modifyText(ModifyEvent e) { - updateNextEnablement(); - } - }; - - serverText.addModifyListener(listener); - userText.addModifyListener(listener); - passwordText.addModifyListener(listener); - repeatPasswordText.addModifyListener(listener); - if (showPrefButton) { - prefButton.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - // do nothing - } - - public void widgetSelected(SelectionEvent e) { - IPreferenceStore preferences = Saros.getDefault().getPreferenceStore(); - if (preferences.getString(PreferenceConstants.USERNAME).length() != 0 - && prefButton.getSelection()) { - setMessage( - "Storing the configuration will override the existing settings.", - DialogPage.WARNING); - } else { - setMessage(null); - } - } - - }); - } - } - - private void updateNextEnablement() { - - boolean passwordsMatch = passwordText.getText().equals(repeatPasswordText.getText()); - boolean done = serverText.getText().length() > 0 && userText.getText().length() > 0 - && passwordText.getText().length() > 0 && passwordsMatch; - - if (passwordsMatch) { - setErrorMessage(null); - } else { - setErrorMessage("Passwords don't match."); - } - - setPageComplete(done); - } - - public void setInitialValues() { - IPreferenceStore preferences = Saros.getDefault().getPreferenceStore(); - serverText.setText(preferences.getDefaultString(PreferenceConstants.SERVER)); - if (showPrefButton) { - prefButton - .setSelection(preferences.getString(PreferenceConstants.USERNAME).length() == 0); - } - } - - public boolean performFinish() { - - if (createAccount) { - - final String server = getServer(); - final String username = getUsername(); - final String password = getPassword(); - final boolean storeInPreferences = isStoreInPreferences(); - - try { - getContainer().run(false, false, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { - try { - Saros.getDefault().createAccount(server, username, password, monitor); - - if (storeInPreferences) { - IPreferenceStore preferences = Saros.getDefault() - .getPreferenceStore(); - preferences.setValue(PreferenceConstants.SERVER, server); - preferences.setValue(PreferenceConstants.USERNAME, username); - preferences.setValue(PreferenceConstants.PASSWORD, password); - } - - } catch (final XMPPException e) { - throw new InvocationTargetException(e); - } - } - }); - - } catch (InvocationTargetException e) { - String s = ((XMPPException)e.getCause()).getXMPPError().getMessage(); - - if (s == null && ((XMPPException)e.getCause()).getXMPPError().getCode() == 409){ - s = "Account already exists"; - } - - setMessage(e.getCause().getMessage() + ": " + (s != null ? s : "No Explanation"), IMessageProvider.ERROR); - return false; - - } catch (InterruptedException e) { - setMessage(e.getCause().getMessage(), IMessageProvider.ERROR); - return false; - } - - return true; - } - - else { - if (isStoreInPreferences()) { - - final String server = getServer(); - final String username = getUsername(); - final String password = getPassword(); - - IPreferenceStore preferences = Saros.getDefault().getPreferenceStore(); - preferences.setValue(PreferenceConstants.SERVER, server); - preferences.setValue(PreferenceConstants.USERNAME, username); - preferences.setValue(PreferenceConstants.PASSWORD, password); - } - return true; - } - } - -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/ShowDescriptionPage.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/ShowDescriptionPage.java deleted file mode 100644 index eeeb77c66d44c24a6147bb1ebd2d7768901efa1c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/ShowDescriptionPage.java +++ /dev/null @@ -1,53 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.wizards; - -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -import de.fu_berlin.inf.dpp.ui.SarosUI; - -/** - * A wizard page that displays the name of the inviter and the description - * provided with the invitation. - */ -class ShowDescriptionPage extends WizardPage { - - private JoinSessionWizard joinSessionWizard; - - protected ShowDescriptionPage(JoinSessionWizard joinSessionWizard) { - super("firstPage"); - this.joinSessionWizard = joinSessionWizard; - - setTitle("Session Invitation"); - setDescription("You have been invited to join on a session for a " - + "shared project. Click next if you want to accept the invitation."); - setImageDescriptor(SarosUI.getImageDescriptor("icons/start_invitation.png")); - } - - public void createControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new GridLayout(2, false)); - - Label inviterLabel = new Label(composite, SWT.NONE); - inviterLabel.setText("Inviter"); - - Text inviterText = new Text(composite, SWT.READ_ONLY | SWT.SINGLE | SWT.BORDER); - - inviterText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); - inviterText.setText(joinSessionWizard.process.getPeer().getBase()); - - Label descriptionLabel = new Label(composite, SWT.NONE); - descriptionLabel.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, false, false)); - descriptionLabel.setText("Project"); - - Text descriptionText = new Text(composite, SWT.READ_ONLY | SWT.BORDER); - descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - descriptionText.setText(joinSessionWizard.process.getDescription()); - - setControl(composite); - } -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/WizardDialogAccessable.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/WizardDialogAccessable.java deleted file mode 100644 index 4ae01a1336d411158f9d34e28710b0e18a15e893..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/WizardDialogAccessable.java +++ /dev/null @@ -1,29 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.wizards; - -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Shell; - -public class WizardDialogAccessable extends WizardDialog { - public WizardDialogAccessable(Shell parentShell, IWizard newWizard){ - super(parentShell,newWizard); - } - - public Button getWizardButton(int id){ - return getButton(id); - } - - public void setWizardButtonLabel(int id, String label) { - Button btn = getButton(id); - if (btn!=null) - btn.setText(label); - } - - public void setWizardButtonEnabled(int id, boolean enabled) { - Button btn = getButton(id); - if (btn!=null) - btn.setEnabled(enabled); - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/FileUtil.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/FileUtil.java deleted file mode 100644 index b4b64a440ea431496ba4d47614faf78d0decca65..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/FileUtil.java +++ /dev/null @@ -1,55 +0,0 @@ -package de.fu_berlin.inf.dpp.util; - -import java.io.IOException; -import java.io.InputStream; -import java.util.zip.Adler32; -import java.util.zip.CheckedInputStream; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; - -/** - * this class get files or contents and check for identicalness. - * @author orieger - * - */ -public class FileUtil { - - /** - * calculate checksum for given file - * @param file - * @return checksum of file or -1 if checksum calculation has been failed. - */ - public static Long checksum(IFile file) { - InputStream contents = null; - - try { - // Adler-32 checksum - contents = file.getContents(); - CheckedInputStream cis = new CheckedInputStream(contents, new Adler32()); - - byte[] tempBuf = new byte[128]; - while (cis.read(tempBuf) >= 0) { - } - long checksum = cis.getChecksum().getValue(); - return new Long(checksum); - - } catch (IOException e) { - e.printStackTrace(); - - } catch (CoreException e) { - e.printStackTrace(); - - } finally { - try { - if (contents != null) - contents.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - return new Long(-1); - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/FileZipper.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/FileZipper.java deleted file mode 100644 index dc750313af7f17a9304d8eb4a7c25708bcdd0516..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/FileZipper.java +++ /dev/null @@ -1,218 +0,0 @@ -package de.fu_berlin.inf.dpp.util; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.util.Enumeration; -import java.util.List; -import java.util.zip.Adler32; -import java.util.zip.CheckedInputStream; -import java.util.zip.CheckedOutputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; -import java.util.zip.ZipInputStream; -import java.util.zip.ZipOutputStream; - -import org.apache.log4j.Logger; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; - -/** - * This class contains method to write file into and read file out of zip - * archive. - * - * @author orieger - * - */ -public class FileZipper { - - private static Logger logger = Logger.getLogger(FileZipper.class); - - public static void createZipArchive() throws Exception { - - File dir = new File("/home/troll/test_archiv"); - // archive müssen rekursiv ausgelesen werden. - File[] files = (dir.listFiles()); - - CheckedOutputStream cos = new CheckedOutputStream(new FileOutputStream( - "/home/troll/archive.zip"), new Adler32()); - ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(cos)); - - FileInputStream fis; - File f; - int i; - - // for(String path : files){ - for (File path : files) { - - logger.debug("compress file: " + path.toString()); - - f = new File(path.getPath()); - if (f.exists()) { - - if (f.isDirectory()) { - addFolder("",f, zos); - } else { - addFile("", f, zos); - } - - - } else { - new FileNotFoundException(path.getName()); - } - - } - zos.close(); - // checksum - logger.debug("checksum: " + cos.getChecksum().getValue()); - } - - private static void addFile(String path, File file, - ZipOutputStream zos) throws Exception { - FileInputStream fis = null; - int i; - - /* Pfad übergeben*/ - ZipEntry e = new ZipEntry(path + File.separator +file.getName()); - zos.putNextEntry(e); - - - fis = new FileInputStream(file); - while ((i = fis.read()) != -1) { - zos.write(i); - } - - zos.closeEntry(); - } - - private static void addFolder(String path, File file, ZipOutputStream zos) throws Exception{ - - File[] files = file.listFiles(); - for(File f : files){ - if(f.isDirectory()){ - logger.debug("compress folder: " + file.getName()); - addFolder(path + File.separator + file.getName(), f, zos); - } - else{ - logger.debug("compress file : "+file.getName() + " path "+path); - addFile(path + File.separator + file.getName(),f,zos); - } - } - - } - - public static void readZipArchive(String archive) throws Exception { - CheckedInputStream cis = new CheckedInputStream(new FileInputStream( - archive), new Adler32()); - ZipInputStream zis = new ZipInputStream(cis); - - String outputFolder = "/home/troll/test_archiv_output"; - new File(outputFolder).delete(); - - // entpacke archiv - ZipEntry entry; - int i = 0; - while ((entry = zis.getNextEntry()) != null) { - logger.debug("unzip file: " + entry.getName()); - // zu entpackende Datei im Zielverzeichnis anlegen - File directory = new File(entry.getName()); - directory.mkdirs(); -// FileOutputStream fos = new FileOutputStream(new File( -// "/home/troll/test_archiv_output", entry.getName())); - FileOutputStream fos = new FileOutputStream(entry.getName()); - - while ((i = zis.read()) != -1) { - fos.write(i); - } - fos.close(); - zis.closeEntry(); - } - logger.debug("checksum: " + cis.getChecksum().getValue()); - zis.close(); - } - - - public static void createProjectZipArchive(List<IPath> files, String descPath, IProject project) - throws Exception { - CheckedOutputStream cos = new CheckedOutputStream(new FileOutputStream( - descPath), new Adler32()); - ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(cos)); - - File f; - - for (IPath path : files) { - logger.debug("compress file: " + path); - - f = project.getFile(path).getLocation().toFile(); - if (f.exists()) { - - /* create project path in folder structure. */ - String[] structure = path.segments(); - String path_structure = ""; - for(int j = 0; j< structure.length-1; j++){ - - String s = structure[j]; - path_structure += s + File.separator; - } - - addFile(path_structure,f,zos); - - } else { - new FileNotFoundException(path.toString()); - } - - } - zos.close(); - // checksum - logger.debug("checksum: " + cos.getChecksum().getValue()); -// return cos.getChecksum().getValue(); - } - - public static void readInputStreamsProjectArchive(File file) throws Exception{ - ZipFile zip = new ZipFile(file); - Enumeration<ZipEntry> entries = (Enumeration<ZipEntry>) zip.entries(); - while(entries.hasMoreElements()){ - ZipEntry entry = entries.nextElement(); - System.out.println(entry.getName()); - - } - } - - public static void readProjectZipArchive() throws Exception { - - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IProject project = root.getProject("Projectname"); - Path p = new Path(""); - project.getFile(p); - - CheckedInputStream cis = new CheckedInputStream(new FileInputStream( - "./archive.zip"), new Adler32()); - ZipInputStream zis = new ZipInputStream(cis); - - // entpacke archiv - ZipEntry entry; - int i = 0; - while ((entry = zis.getNextEntry()) != null) { - - logger.debug("unzip file: " + entry.getName()); - // zu entpackende Datei im Zielverzeichnis anlegen - FileOutputStream fos = new FileOutputStream(new File( - "zielverzeichns", entry.getName())); - while ((i = zis.read()) != -1) { - fos.write(i); - } - fos.close(); - zis.closeEntry(); - } - logger.debug("checksum: " + cis.getChecksum().getValue()); - zis.close(); - } - - - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/PacketProtokollLogger.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/PacketProtokollLogger.java deleted file mode 100644 index a70f6b9a60bce0c677f6721777c6c17759fee0d4..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/PacketProtokollLogger.java +++ /dev/null @@ -1,60 +0,0 @@ -package de.fu_berlin.inf.dpp.util; - -import org.apache.log4j.FileAppender; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.PatternLayout; -import org.jivesoftware.smack.packet.Message; - -import de.fu_berlin.inf.dpp.Saros; - -public class PacketProtokollLogger { - - private static Logger logger; - - /* Singleton Pattern. */ - private static PacketProtokollLogger connectionLogger; - - private PacketProtokollLogger(){ - logger = Logger.getLogger("Connection Logger"); - initLogger(); - } - - public static PacketProtokollLogger getInstance(){ - if(connectionLogger == null){ - connectionLogger = new PacketProtokollLogger(); - } - return connectionLogger; - } - - public static void initLogger(){ - try { - PatternLayout layout = new PatternLayout( "%d{ISO8601} %-5p %m%n" ); -// DailyRollingFileAppender fileAppender = new DailyRollingFileAppender( layout, "ConnectionDatei"+Saros.getDefault().getMyJID().getName()+".log", "'.'yyyy-MM-dd_HH-mm" ); - FileAppender fileAppender = new FileAppender( layout, "ConnectionDatei"+Saros.getDefault().getMyJID().getName()+".log", false); - logger.addAppender( fileAppender ); - logger.setLevel( Level.ALL ); - } catch( Exception ex ) { - System.out.println( ex ); - } - } - - /** - * log time in millis and message properties of outgoing message. - * @param msg sended message - */ - public void sendPacket(Message msg){ -// Date send = Calendar.getInstance().getTime(); -// logger.info(msg.getFrom()+" "+msg.getThread()+" send : "+DateFormat.getDateTimeInstance().format(send)); -// logger.info(Saros.getDefault().getMyJID().getName()+" send : "+msg.getPacketID()); - } - - /** - * log time in millis and message properties of incomming message. - * @param msg received message. - */ - public void receivePacket(Message msg){ - -// logger.info(Saros.getDefault().getMyJID().getName()+" receive : "+msg.getPacketID()); - } -}