1 29 38 39 package org.planetamessenger.plugin; 40 41 import java.util.*; 42 43 44 45 public class JPlugin implements JPluginBase { 46 47 static public final int STATUS_OFFLINE = 0; 49 static public final int STATUS_ONLINE = 1; 50 static public final int STATUS_FREE_CHAT = 2; 51 static public final int STATUS_INVISIBLE = 3; 52 static public final int STATUS_AWAY = 4; 53 static public final int STATUS_BUSY = 5; 54 static public final int STATUS_IDLE = 6; 55 static public final int STATUS_DND = 7; 56 static public final int STATUS_ON_PHONE = 8; 57 static public final int STATUS_ON_LUNCH = 9; 58 static public final int STATUS_ON_VACATION = 10; 59 static public final int STATUS_NOT_AT_HOME = 11; 60 static public final int STATUS_NOT_AT_DESK = 12; 61 static public final int STATUS_NOT_IN_OFFICE = 13; 62 static public final int STATUS_NOT_IN_LIST = 14; 63 static public final int STATUS_CUSTOM = 15; 64 static public final int STATUS_URL = 98; 65 static public final int STATUS_MESSAGE = 99; 66 static public final int STATUS_LAST = 99; 67 68 static public final int PRIVACY_UNBLOCK_USER = 0; 69 static public final int PRIVACY_BLOCK_USER = 1; 70 static public final int PRIVACY_PERMIT_STATUS = 2; 71 static public final int PRIVACY_DENY_STATUS = 3; 72 73 private JUserInfo userInfo = null; 74 private JPlugin selfObject = null; 75 private ArrayList<JPluginEngineListener> pluginEngineListener = null; 76 private ArrayList<JUserRegistrationListener> registrationListener = null; 77 private ArrayList<JMessengerEventListener> messengerEventListener = null; 78 private JKernelAPIListener kernelManager = null; 79 private HashMap<Object , JPlanetaMessengerStatus> hPluginStatus = null; 80 private JPluginProperties pluginProperties = null; 81 private JPluginCapabilities pluginCapabilities = JPluginCapabilities.getDefault(); 82 private boolean bDestroying = false; 83 84 85 88 public JPlugin() { 89 90 } 91 92 98 public synchronized final void addPluginEngineListener( JPluginEngineListener listener ) { 99 100 pluginEngineListener.add( listener ); 101 } 102 103 108 public synchronized final void removePluginEngineListener( JPluginEngineListener listener ) { 109 110 pluginEngineListener.remove( listener ); 111 } 112 113 117 public synchronized final void addKernelAPIListener( JKernelAPIListener listener ) { 118 119 kernelManager = listener; 120 } 121 122 127 public synchronized final void removeKernelAPIListener( JKernelAPIListener listener ) { 128 129 kernelManager = null; 130 } 131 132 135 public synchronized final JKernelAPIListener getKernelManager() { 136 137 return kernelManager; 138 } 139 140 144 public synchronized void addMessengerEventListener( JMessengerEventListener listener ) { 145 146 messengerEventListener.add( listener ); 147 } 148 149 153 public synchronized void removeMessengerEventListener( JMessengerEventListener listener ) { 154 155 messengerEventListener.remove( listener ); 156 } 157 158 163 public synchronized final void addRegistrationEngineListener( JUserRegistrationListener listener ) { 164 165 registrationListener.add( listener ); 166 } 167 168 173 public synchronized final void removeRegistrationEngineListener( JUserRegistrationListener listener ) { 174 175 registrationListener.remove( listener ); 176 } 177 178 183 public synchronized final void removeAllRegistrationEngineListener() { 184 185 registrationListener.clear(); 186 } 187 188 194 public final void setUserInfo( JUserInfo userInfo ) { 195 196 this.userInfo = userInfo; 197 } 198 199 209 protected final void addStatus( int nPlanetaMessengerStatus, Object objPluginStatus ) { 210 211 synchronized( hPluginStatus ) { 212 hPluginStatus.put( objPluginStatus, new JPlanetaMessengerStatus( nPlanetaMessengerStatus, objPluginStatus ) ); 213 } 214 } 215 216 221 protected final int translateStatusFromPlugin( Object objPluginStatus ) { 222 223 synchronized( hPluginStatus ) { 224 JPlanetaMessengerStatus status = ( hPluginStatus != null ? ( ( JPlanetaMessengerStatus ) hPluginStatus.get( objPluginStatus ) ) : null ); 225 226 return ( ( status != null ) ? status.getPlanetaMessengerStatus() : STATUS_OFFLINE ); 227 } 228 } 229 230 235 protected final Object translateStatusToPlugin( int nPlanetaMessengertStatus ) { 236 237 JPlanetaMessengerStatus status = null; 238 239 240 synchronized( hPluginStatus ) { 241 242 Iterator<JPlanetaMessengerStatus> itStatus = hPluginStatus.values().iterator(); 243 244 245 while( itStatus.hasNext() ) { 246 status = itStatus.next(); 247 if( status.getPlanetaMessengerStatus() == nPlanetaMessengertStatus ) 248 break; 249 } 250 } 251 252 return ( status != null ? status.getPluginStatus() : null ); 253 } 254 255 259 public final HashMap getAllPluginStatus() { 260 261 synchronized( hPluginStatus ) { 262 return ( HashMap ) hPluginStatus.clone(); 263 } 264 } 265 266 273 public final void fireOnCreate( JPluginProperties pluginProperties ) { 274 275 this.pluginProperties = pluginProperties; 276 hPluginStatus = new HashMap<Object , JPlanetaMessengerStatus>(); 277 messengerEventListener = new ArrayList<JMessengerEventListener>(); 278 pluginEngineListener = new ArrayList<JPluginEngineListener>(); 279 registrationListener = new ArrayList<JUserRegistrationListener>(); 280 selfObject = this; 281 bDestroying = false; 282 283 addStatus( STATUS_MESSAGE, new Integer ( STATUS_MESSAGE ) ); 284 addStatus( STATUS_URL, new Integer ( STATUS_URL ) ); 285 286 onCreate(); 287 } 288 289 294 public void onCreate() { 295 296 } 297 298 302 public final void fireOnDestroy() { 303 304 bDestroying = true; 306 307 fireOnLogout(); 309 } 310 311 316 public void onDestroy() { 317 318 } 319 320 324 public final void fireOnLogin() { 325 326 final ArrayList<JPluginEngineListener> clonePluginEngineListener; 327 328 329 synchronized( this ) { 330 clonePluginEngineListener = ( ArrayList<JPluginEngineListener> ) pluginEngineListener.clone(); 331 } 332 333 if( userInfo.getLoginStatus() != STATUS_OFFLINE ) { 334 335 if( clonePluginEngineListener.size() > 0 ) { 337 for( int nCount = 0; nCount < clonePluginEngineListener.size(); nCount++ ) 338 ( ( JPluginEngineListener ) clonePluginEngineListener.get( nCount ) ).onPluginConnectionStatusChanged( this, JPluginEngineListener.CONNECTING ); 339 } 340 341 Thread runner = new Thread ( new Runnable () { 342 343 public void run() { 344 345 ArrayList<JMessengerEventListener> clone; 346 347 synchronized( selfObject ) { 348 clone = ( ArrayList<JMessengerEventListener> ) messengerEventListener.clone(); 349 } 350 351 if( clone.size() > 0 ) { 353 for( int nCount = 0; nCount < clone.size(); nCount++ ) 354 ( ( JMessengerEventListener ) clone.get( nCount ) ).onLogin( selfObject.userInfo.getLoginStatus() ); 355 } 356 357 if( clonePluginEngineListener.size() > 0 ) { 359 for( int nCount = 0; nCount < clonePluginEngineListener.size(); nCount++ ) 360 ( ( JPluginEngineListener ) clonePluginEngineListener.get( nCount ) ).onPluginStatusChanged( selfObject, selfObject.userInfo.getLoginStatus() ); 361 } 362 } 363 } ); 364 365 runner.start(); 366 } 367 else { 368 if( clonePluginEngineListener.size() > 0 ) { 370 for( int nCount = 0; nCount < clonePluginEngineListener.size(); nCount++ ) 371 ( ( JPluginEngineListener ) clonePluginEngineListener.get( nCount ) ).onPluginConnectionStatusChanged( this, JPluginEngineListener.DISCONNECTED ); 372 } 373 } 374 } 375 376 381 public final void fireOnLoginAccepted() { 382 383 ArrayList<JPluginEngineListener> clonePluginEngineListener; 384 385 386 synchronized( this ) { 387 clonePluginEngineListener = ( ArrayList<JPluginEngineListener> ) pluginEngineListener.clone(); 388 } 389 390 if( clonePluginEngineListener.size() > 0 ) { 392 for( int nCount = 0; nCount < clonePluginEngineListener.size(); nCount++ ) 393 ( ( JPluginEngineListener ) clonePluginEngineListener.get( nCount ) ).onPluginConnectionStatusChanged( this, JPluginEngineListener.CONNECTED ); 394 } 395 } 396 397 402 public final void fireOnLoginFailed() { 403 404 ArrayList<JPluginEngineListener> clonePluginEngineListener; 405 406 407 synchronized( this ) { 408 clonePluginEngineListener = ( ArrayList<JPluginEngineListener> ) pluginEngineListener.clone(); 409 } 410 411 if( clonePluginEngineListener.size() > 0 ) { 413 for( int nCount = 0; nCount < clonePluginEngineListener.size(); nCount++ ) 414 ( ( JPluginEngineListener ) clonePluginEngineListener.get( nCount ) ).onPluginConnectionStatusChanged( this, JPluginEngineListener.DISCONNECTED ); 415 } 416 } 417 418 422 public final void fireOnLogout() { 423 424 Thread runner = new Thread ( new Runnable () { 425 426 public void run() { 427 428 ArrayList<JMessengerEventListener> clone; 429 ArrayList<JPluginEngineListener> clonePluginEngineListener; 430 JPlugin selfObjectCopy = selfObject; 431 432 433 437 if( selfObjectCopy == null ) 438 return; 439 440 synchronized( selfObjectCopy ) { 441 clone = ( ArrayList<JMessengerEventListener> ) messengerEventListener.clone(); 442 clonePluginEngineListener = ( ArrayList<JPluginEngineListener> ) pluginEngineListener.clone(); 443 getKernelManager().getContactListManager().setAllItemsStatus( selfObjectCopy, STATUS_OFFLINE ); 444 445 if( selfObjectCopy.bDestroying ) 447 selfObject = null; 448 } 449 450 if( selfObjectCopy.isConnected() ) { 451 if( clone.size() > 0 ) { 453 for( int nCount = 0; nCount < clone.size(); nCount++ ) 454 ( ( JMessengerEventListener ) clone.get( nCount ) ).onLogout(); 455 } 456 } 457 458 if( clonePluginEngineListener.size() > 0 ) { 460 for( int nCount = 0; nCount < clonePluginEngineListener.size(); nCount++ ) 461 ( ( JPluginEngineListener ) clonePluginEngineListener.get( nCount ) ).onPluginConnectionStatusChanged( selfObjectCopy, JPluginEngineListener.DISCONNECTED ); 462 } 463 464 if( selfObjectCopy.bDestroying ) { 466 synchronized( selfObjectCopy ) { 467 synchronized( hPluginStatus ) { 468 hPluginStatus.clear(); 469 } 470 messengerEventListener.clear(); 471 pluginEngineListener.clear(); 472 registrationListener.clear(); 473 userInfo.destroy(); 474 messengerEventListener = null; 475 pluginEngineListener = null; 476 registrationListener = null; 477 hPluginStatus = null; 478 pluginProperties = null; 479 userInfo = null; 480 bDestroying = false; 481 onDestroy(); 482 } 483 } 484 } 485 } ); 486 487 runner.start(); 488 } 489 490 498 public final boolean fireOnSendMessage( final java.lang.String strToUser, final java.lang.String msg ) { 499 500 boolean bRet = false; 501 502 503 if( isConnected() ) { 504 505 boolean bCanSendOfflineMsg = getPluginCapabilities().getBool( JPluginCapabilities.CAPABILITY_OFFLINE_MESSAGE ); 506 JContactListItem contactItem = ( JContactListItem ) getKernelManager().getContactListManager().getContactList( selfObject ).get( strToUser ); 507 int nMsgType = ( contactItem.getStatus() == STATUS_OFFLINE ? JMessengerEventListener.MESSAGE_TYPE_OFFLINE : JMessengerEventListener.MESSAGE_TYPE_ONLINE ); 508 509 if( !bCanSendOfflineMsg && ( nMsgType == JMessengerEventListener.MESSAGE_TYPE_OFFLINE ) ) 511 bRet = false; 512 else 513 bRet = true; 514 515 Thread runner = new Thread ( new Runnable () { 516 517 public void run() { 518 519 ArrayList<JMessengerEventListener> clone; 520 ArrayList<JPluginEngineListener> clonePluginEngineListener; 521 522 synchronized( selfObject ) { 523 clone = ( ArrayList<JMessengerEventListener> ) messengerEventListener.clone(); 524 clonePluginEngineListener = ( ArrayList<JPluginEngineListener> ) pluginEngineListener.clone(); 525 } 526 527 if( clone.size() > 0 ) { 529 530 boolean bCanSendOfflineMsg = selfObject.getPluginCapabilities().getBool( JPluginCapabilities.CAPABILITY_OFFLINE_MESSAGE ); 531 JContactListItem contactItem = ( JContactListItem ) selfObject.getKernelManager().getContactListManager().getContactList( selfObject ).get( strToUser ); 532 int nMsgType = ( contactItem.getStatus() == STATUS_OFFLINE ? JMessengerEventListener.MESSAGE_TYPE_OFFLINE : JMessengerEventListener.MESSAGE_TYPE_ONLINE ); 533 534 if( ( bCanSendOfflineMsg && ( nMsgType == JMessengerEventListener.MESSAGE_TYPE_OFFLINE ) ) || 536 ( nMsgType == JMessengerEventListener.MESSAGE_TYPE_ONLINE ) ) { 537 for( int nCount = 0; nCount < clone.size(); nCount++ ) 538 ( ( JMessengerEventListener ) clone.get( nCount ) ).onSendMessage( strToUser, msg, nMsgType ); 539 } 540 else { 541 for( int nCount = 0; nCount < clonePluginEngineListener.size(); nCount++ ) 542 ( ( JPluginEngineListener ) clonePluginEngineListener.get( nCount ) ).onCapabilityNotFound( selfObject, JPluginEngineListener.CAPABILITY_OFFLINE_MESSAGES ); 543 } 544 } 545 } 546 } ); 547 548 runner.start(); 549 } 550 551 return bRet; 552 } 553 554 562 public final void fireOnReceiveMessage( java.lang.String strFromUser, java.util.GregorianCalendar date, java.lang.String strMessage ) { 563 564 synchronized( this ) { 565 getKernelManager().getContactListManager().saveMessage( this, strFromUser, STATUS_MESSAGE, strMessage ); 566 } 567 } 568 569 575 public final void fireOnPluginStatusChanged( final int nStatus ) { 576 577 if( isConnected() ) { 578 Thread runner = new Thread ( new Runnable () { 579 580 public void run() { 581 582 ArrayList<JMessengerEventListener> clone; 583 584 synchronized( selfObject ) { 585 clone = ( ArrayList<JMessengerEventListener> ) messengerEventListener.clone(); 586 } 587 588 if( clone.size() > 0 ) { 590 for( int nCount = 0; nCount < clone.size(); nCount++ ) 591 ( ( JMessengerEventListener ) clone.get( nCount ) ).onPluginStatusChanged( nStatus ); 592 } 593 } 594 } ); 595 596 runner.start(); 597 } 598 } 599 600 606 public final void fireOnBuddyDetails( final java.lang.String strUserId ) { 607 608 if( isConnected() ) { 609 Thread runner = new Thread ( new Runnable () { 610 611 public void run() { 612 613 ArrayList<JMessengerEventListener> clone; 614 615 synchronized( selfObject ) { 616 clone = ( ArrayList<JMessengerEventListener> ) messengerEventListener.clone(); 617 } 618 619 if( clone.size() > 0 ) { 621 for( int nCount = 0; nCount < clone.size(); nCount++ ) 622 ( ( JMessengerEventListener ) clone.get( nCount ) ).onBuddyDetails( strUserId ); 623 } 624 } 625 } ); 626 627 runner.start(); 628 } 629 } 630 631 638 public final void fireOnBuddyStatusChanged( java.lang.String strUserId, int nNewStatus ) { 639 640 synchronized( this ) { 641 if( isConnected() ) 642 getKernelManager().getContactListManager().setItemStatus( this, strUserId, nNewStatus ); 643 } 644 } 645 646 654 public final void fireOnBuddyRequestAuthorization( java.lang.String strUserId, java.lang.String strNickName ) { 655 656 if( isConnected() ) { 657 658 boolean bAuthorized = getKernelManager().getContactListManager().onBuddyRequestAuthorization( strUserId, strNickName ); 659 ArrayList<JMessengerEventListener> clone; 660 661 662 synchronized( this ) { 663 clone = ( ArrayList<JMessengerEventListener> ) messengerEventListener.clone(); 664 } 665 666 if( clone.size() > 0 ) { 668 for( int nCount = 0; nCount < clone.size(); nCount++ ) { 669 if( bAuthorized ) 670 ( ( JMessengerEventListener ) clone.get( nCount ) ).onAuthorizeBuddy( strUserId ); 671 else 672 ( ( JMessengerEventListener ) clone.get( nCount ) ).onUnauthorizeBuddy( strUserId ); 673 } 674 } 675 } 676 } 677 678 682 public final void fireOnAddUserToContactList( final java.lang.String strUserId ) { 683 684 if( isConnected() ) { 685 Thread runner = new Thread ( new Runnable () { 686 687 public void run() { 688 689 ArrayList<JMessengerEventListener> clone; 690 691 692 synchronized( selfObject ) { 693 clone = ( ArrayList<JMessengerEventListener> ) messengerEventListener.clone(); 694 } 695 696 selfObject.getKernelManager().getContactListManager().addToContactList( selfObject, strUserId, strUserId ); 698 699 if( clone.size() > 0 ) 700 for( int nCount = 0; nCount < clone.size(); nCount++ ) 701 ( ( JMessengerEventListener ) clone.get( nCount ) ).onAddUserToContactList( strUserId ); 702 703 selfObject.fireOnBuddyDetails( strUserId ); 704 } 705 } ); 706 707 runner.start(); 708 } 709 } 710 711 717 public final boolean fireOnRemoveUserFromContactList( final java.lang.String strUserId ) { 718 719 boolean bCanRemoveContactWhenDisconnected = getPluginCapabilities().getBool( JPluginCapabilities.CAPABILITY_REMOVE_CONTACT_WHEN_DISCONNECTED ); 720 final ArrayList<JPluginEngineListener> clonePluginEngineListener; 721 722 723 synchronized( this ) { 724 clonePluginEngineListener = ( ArrayList<JPluginEngineListener> ) pluginEngineListener.clone(); 725 } 726 727 if( isConnected() ) { 728 Thread runner = new Thread ( new Runnable () { 729 730 public void run() { 731 732 JContactListListener listener = selfObject.getKernelManager().getContactListManager(); 733 ArrayList<JMessengerEventListener> clone; 734 735 736 if( listener != null ) 737 listener.removeFromContactList( selfObject, strUserId ); 738 739 synchronized( selfObject ) { 740 clone = ( ArrayList<JMessengerEventListener> ) messengerEventListener.clone(); 741 } 742 743 if( clone.size() > 0 ) { 745 for( int nCount = 0; nCount < clone.size(); nCount++ ) 746 ( ( JMessengerEventListener ) clone.get( nCount ) ).onRemoveUserFromContactList( strUserId ); 747 } 748 } 749 } ); 750 751 runner.start(); 752 } 753 else { 754 for( int nCount = 0; nCount < clonePluginEngineListener.size(); nCount++ ) 755 ( ( JPluginEngineListener ) clonePluginEngineListener.get( nCount ) ).onCapabilityNotFound( selfObject, JPluginEngineListener.CAPABILITY_REMOVE_CONTACTS_WHEN_OFFLINE ); 756 757 return false; 758 } 759 760 return true; 761 } 762 763 770 public final void fireOnRequestAuthorization( final java.lang.String strUserId, final java.lang.String strNickName ) { 771 772 if( isConnected() ) { 773 Thread runner = new Thread ( new Runnable () { 774 775 public void run() { 776 777 ArrayList<JMessengerEventListener> clone; 778 779 780 synchronized( selfObject ) { 781 clone = ( ArrayList<JMessengerEventListener> ) messengerEventListener.clone(); 782 } 783 784 if( clone.size() > 0 ) { 786 for( int nCount = 0; nCount < clone.size(); nCount++ ) 787 ( ( JMessengerEventListener ) clone.get( nCount ) ).onRequestAuthorization( strUserId, strNickName ); 788 } 789 } 790 } ); 791 792 runner.start(); 793 } 794 } 795 796 805 public final void fireOnRegisterExistingUser( final java.lang.String strNickName, final java.lang.String strUserId, final java.lang.String strPasswd ) { 806 807 Thread runner = new Thread ( new Runnable () { 808 809 public void run() { 810 811 ArrayList<JMessengerEventListener> clone; 812 813 synchronized( selfObject ) { 814 clone = ( ArrayList<JMessengerEventListener> ) messengerEventListener.clone(); 815 } 816 817 if( clone.size() > 0 ) { 819 for( int nCount = 0; nCount < clone.size(); nCount++ ) 820 ( ( JMessengerEventListener ) clone.get( nCount ) ).onRegisterExistingUser( strNickName, strUserId, strPasswd ); 821 } 822 } 823 } ); 824 825 runner.start(); 826 } 827 828 832 public final void fireOnRegisterUserSucessfull() { 833 834 Thread runner = new Thread ( new Runnable () { 835 836 public void run() { 837 838 ArrayList<JUserRegistrationListener> clone; 839 840 synchronized( selfObject ) { 841 clone = ( ArrayList<JUserRegistrationListener> ) registrationListener.clone(); 842 } 843 844 if( clone.size() > 0 ) { 846 for( int nCount = 0; nCount < clone.size(); nCount++ ) 847 ( ( JUserRegistrationListener ) clone.get( nCount ) ).onRegisterUserSucessfull(); 848 } 849 } 850 } ); 851 852 runner.start(); 853 } 854 855 859 public final void fireOnRegisterUserFailed() { 860 861 Thread runner = new Thread ( new Runnable () { 862 863 public void run() { 864 865 ArrayList<JUserRegistrationListener> clone; 866 867 synchronized( selfObject ) { 868 clone = ( ArrayList<JUserRegistrationListener> ) registrationListener.clone(); 869 } 870 871 if( clone.size() > 0 ) { 873 for( int nCount = 0; nCount < clone.size(); nCount++ ) 874 ( ( JUserRegistrationListener ) clone.get( nCount ) ).onRegisterUserFailed(); 875 } 876 } 877 } ); 878 879 runner.start(); 880 } 881 882 891 public final void fireOnRegisterNewUser( final java.lang.String strNickName, final java.lang.StringBuffer strNewUserId, final java.lang.String strPasswd ) { 892 893 Thread runner = new Thread ( new Runnable () { 894 895 public void run() { 896 897 ArrayList<JMessengerEventListener> clone; 898 899 synchronized( selfObject ) { 900 clone = ( ArrayList<JMessengerEventListener> ) messengerEventListener.clone(); 901 } 902 903 if( clone.size() > 0 ) { 905 for( int nCount = 0; nCount < clone.size(); nCount++ ) 906 ( ( JMessengerEventListener ) clone.get( nCount ) ).onRegisterNewUser( strNickName, strNewUserId, strPasswd ); 907 } 908 } 909 } ); 910 911 runner.start(); 912 } 913 914 918 public final void fireOnUnregisterUser() { 919 920 Thread runner = new Thread ( new Runnable () { 921 922 public void run() { 923 924 ArrayList<JMessengerEventListener> clone; 925 926 synchronized( selfObject ) { 927 clone = ( ArrayList<JMessengerEventListener> ) messengerEventListener.clone(); 928 } 929 930 if( clone.size() > 0 ) { 932 for( int nCount = 0; nCount < clone.size(); nCount++ ) 933 ( ( JMessengerEventListener ) clone.get( nCount ) ).onUnregisterUser(); 934 } 935 } 936 } ); 937 938 runner.start(); 939 } 940 941 945 public final void fireOnUnregisterUserSuccessfull() { 946 947 Thread runner = new Thread ( new Runnable () { 948 949 public void run() { 950 951 ArrayList<JUserRegistrationListener> clone; 952 953 synchronized( selfObject ) { 954 clone = ( ArrayList<JUserRegistrationListener> ) registrationListener.clone(); 955 } 956 957 if( clone.size() > 0 ) { 959 for( int nCount = 0; nCount < clone.size(); nCount++ ) 960 ( ( JUserRegistrationListener ) clone.get( nCount ) ).onUnregisterUserSucessfull(); 961 } 962 } 963 } ); 964 965 runner.start(); 966 } 967 968 973 public final void fireOnChangePassword( final java.lang.String strNewPasswd ) { 974 975 Thread runner = new Thread ( new Runnable () { 976 977 public void run() { 978 979 ArrayList<JMessengerEventListener> clone; 980 981 synchronized( selfObject ) { 982 clone = ( ArrayList<JMessengerEventListener> ) messengerEventListener.clone(); 983 } 984 985 if( clone.size() > 0 ) { 987 for( int nCount = 0; nCount < clone.size(); nCount++ ) 988 ( ( JMessengerEventListener ) clone.get( nCount ) ).onChangePassword( strNewPasswd ); 989 } 990 } 991 } ); 992 993 runner.start(); 994 } 995 996 1001 public final void fireOnPasswordChangedSuccessfull( final String strNewPasswd ) { 1002 1003 Thread runner = new Thread ( new Runnable () { 1004 1005 public void run() { 1006 1007 ArrayList<JUserRegistrationListener> clone; 1008 1009 synchronized( selfObject ) { 1010 clone = ( ArrayList<JUserRegistrationListener> ) registrationListener.clone(); 1011 } 1012 1013 if( clone.size() > 0 ) { 1015 for( int nCount = 0; nCount < clone.size(); nCount++ ) 1016 ( ( JUserRegistrationListener ) clone.get( nCount ) ).onPasswordChangedSuccessfull( strNewPasswd ); 1017 } 1018 } 1019 } ); 1020 1021 runner.start(); 1022 } 1023 1024 1028 public final void fireOnPasswordChangedFailed() { 1029 1030 Thread runner = new Thread ( new Runnable () { 1031 1032 public void run() { 1033 1034 ArrayList<JUserRegistrationListener> clone; 1035 1036 synchronized( selfObject ) { 1037 clone = ( ArrayList<JUserRegistrationListener> ) registrationListener.clone(); 1038 } 1039 1040 if( clone.size() > 0 ) { 1042 for( int nCount = 0; nCount < clone.size(); nCount++ ) 1043 ( ( JUserRegistrationListener ) clone.get( nCount ) ).onPasswordChangedFailed(); 1044 } 1045 } 1046 } ); 1047 1048 runner.start(); 1049 } 1050 1051 1059 public final void fireOnChangePrivacy( final java.lang.Object [] aContactList ) { 1060 1061 if( isConnected() ) { 1062 Thread runner = new Thread ( new Runnable () { 1063 1064 public void run() { 1065 1066 ArrayList<JMessengerEventListener> clone; 1067 JContactListItem contactItem; 1068 JContactListItem modifiedItem; 1069 boolean bModified; 1070 boolean bNeedUpdateContactListUI = false; 1071 1072 1073 synchronized( selfObject ) { 1074 clone = ( ArrayList<JMessengerEventListener> ) messengerEventListener.clone(); 1075 } 1076 1077 if( clone.size() > 0 ) { 1079 for( int nCount = 0; nCount < clone.size(); nCount++ ) 1080 for( int nCountItem = 0; nCountItem < aContactList.length; nCountItem++ ) { 1081 bModified = false; 1082 modifiedItem = ( JContactListItem ) aContactList[nCountItem]; 1083 contactItem = ( JContactListItem ) getKernelManager().getContactListManager().getContactList( selfObject ).get( modifiedItem.getUserId() ); 1084 1085 1100 1101 if( modifiedItem.getBlocked() != contactItem.getBlocked() ) { 1103 int nPrivacyType = PRIVACY_UNBLOCK_USER; 1104 1105 if( modifiedItem.getBlocked() ) 1106 nPrivacyType = PRIVACY_BLOCK_USER; 1107 1108 contactItem.setBlocked( modifiedItem.getBlocked() ); 1109 bModified = true; 1110 bNeedUpdateContactListUI = true; 1111 1112 ( ( JMessengerEventListener ) clone.get( nCount ) ).onChangePrivacy( modifiedItem.getUserId(), nPrivacyType ); 1113 } 1114 1115 if( bModified ) 1117 getKernelManager().getContactListManager().updatePrivacy( contactItem ); 1118 } 1119 1120 for( int nCount = 0; nCount < clone.size(); nCount++ ) 1122 ( ( JMessengerEventListener ) clone.get( nCount ) ).onPrivacyChanged(); 1123 1124 if( bNeedUpdateContactListUI ) 1126 getKernelManager().getContactListManager().updateUI(); 1127 } 1128 } 1129 } ); 1130 1131 runner.start(); 1132 } 1133 } 1134 1135 1138 public final void fireOnUserTyping( String strUserId ) { 1139 1140 } 1141 1142 1147 public final void fireOnPluginPropertiesUpdated() { 1148 1149 if( isConnected() ) { 1150 Thread runner = new Thread ( new Runnable () { 1151 1152 public void run() { 1153 1154 ArrayList<JMessengerEventListener> clone; 1155 1156 synchronized( selfObject ) { 1157 clone = ( ArrayList<JMessengerEventListener> ) messengerEventListener.clone(); 1158 } 1159 1160 if( clone.size() > 0 ) { 1162 for( int nCount = 0; nCount < clone.size(); nCount++ ) 1163 ( ( JMessengerEventListener ) clone.get( nCount ) ).onPluginPropertiesUpdated(); 1164 } 1165 } 1166 } ); 1167 1168 runner.start(); 1169 } 1170 } 1171 1172 1177 public boolean isConnected() { 1178 1179 return false; 1180 } 1181 1182 1186 public final JPluginProperties getPluginProperties() { 1187 1188 return ( JPluginProperties ) pluginProperties.clone(); 1189 } 1190 1191 1196 protected final void setPluginCapabilities( JPluginCapabilities pluginCapabilities ) { 1197 1198 this.pluginCapabilities = pluginCapabilities; 1199 } 1200 1201 1204 public final JPluginCapabilities getPluginCapabilities() { 1205 1206 return ( JPluginCapabilities ) ( pluginCapabilities != null ? pluginCapabilities.clone() : JPluginCapabilities.getDefault() ); 1207 } 1208 1209 1213 public final String getUserId() { 1214 1215 return ( userInfo != null ? userInfo.getUserId() : null ); 1216 } 1217 1218 1221 public final String getPassword() { 1222 1223 return ( userInfo != null ? userInfo.getPassword() : null ); 1224 } 1225 1226 1231 public final void setAliasName( java.lang.String strAliasName ) { 1232 1233 if( userInfo != null ) 1234 userInfo.setAliasName( strAliasName ); 1235 } 1236 1237 1240 public final String getAliasName() { 1241 1242 return ( userInfo != null ? userInfo.getAliasName() : null ); 1243 } 1244 1245 1252 public JPluginObjectBase getPreferencesContainer() { 1253 1254 return null; 1255 } 1256 1257 1264 public boolean equals( Object obj ) { 1265 1266 Integer iPluginId; 1267 1268 1269 if( obj != null ) 1270 iPluginId = ( ( obj instanceof Integer ) ? ( Integer ) obj : new Integer ( ( ( JPlugin ) obj ).pluginProperties.getPluginId() ) ); 1271 else 1272 iPluginId = new Integer ( -1 ); 1273 1274 if( iPluginId.intValue() == pluginProperties.getPluginId() ) 1275 return true; 1276 else 1277 return false; 1278 } 1279 1280 1285 public java.lang.String toString() { 1286 1287 return pluginProperties.getName() + " V " + pluginProperties.getVersion(); 1288 } 1289} 1290 1291 | Popular Tags |