[sip-comm-cvs] CVS update: /sip-communicator/src/net/java/sip/communicator/

emcho at dev.java.net emcho at dev.java.net
Wed May 26 11:09:11 CEST 2004


User: emcho   
Date: 04/05/26 02:09:11

Modified:
 /sip-communicator/src/net/java/sip/communicator/
  SimpleContactList.java, SipCommunicator.java

Log:
 Ongoing work on simple

File Changes:

Directory: /sip-communicator/src/net/java/sip/communicator/
===========================================================

File [changed]: SimpleContactList.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/SimpleContactList.java?r1=1.4&r2=1.5
Delta lines:  +105 -3
---------------------
--- SimpleContactList.java	13 Apr 2004 00:53:50 -0000	1.4
+++ SimpleContactList.java	26 May 2004 09:09:08 -0000	1.5
@@ -61,8 +61,8 @@
 import net.java.sip.communicator.gui.imp.*;
 import net.java.sip.communicator.sip.simple.*;
 import net.java.sip.communicator.common.*;
-import net.java.sip.communicator.sip.simple.event.NotificationListener;
-import net.java.sip.communicator.sip.simple.event.NotificationReceivedEvent;
+import net.java.sip.communicator.sip.simple.event.*;
+import net.java.sip.communicator.sip.*;
 
 /**
  * <p>Title: SIP Communicator</p>
@@ -73,7 +73,7 @@
  * @version 1.0
  */
 public class SimpleContactList extends ContactListModel
-    implements NotificationListener
+    implements ContactListChangeListener
 {
     private static final Console console = Console.getConsole(SimpleContactList.class);
 
@@ -237,6 +237,108 @@
         ContactGroup[] path   = evt.getSourceLocation();
         int childIndex = path[path.length -1].getChildIndex(source.getPresenceUri());
         fireTreeNodesChanged(source, path, new int[]{childIndex}, new Object[]{source});
+    }
+
+    /**
+     * Notifies the communications part of of the application that the user
+     * wishes to add the contact described by <code>request</code> to their
+     * contact list.
+     *
+     * @param request request that contains details about the contact the the
+     *   user wishes to add to their contact list.
+     */
+    public void requestContactAddition(ContactAdditionRequest request)
+    {
+        try {
+            //create a contact group location array
+            ContactGroup path[] = new ContactGroup[request.getLocation().length];
+            System.arraycopy(request.getLocation(), 0, path, 0, path.length);
+
+            //append a URI scheme.
+            String presentity = request.getContactIdentifier();
+            if(presentity.indexOf(':') == -1)
+                presentity = "pres:" + presentity;
+
+            contactListController.requestContactAddition(
+                path,
+                presentity,
+                request.getAlias(),
+                request.getNotes());
+        }
+        catch (CommunicationsException ex) {
+            console.showException("Failed to add contact for user "
+                                  + request.getAlias()
+                                  + ", "
+                                  + request.getContactIdentifier(),
+                                  ex);
+        }
+    }
+
+    /**
+     * Called when a new contact has been added to the contact list.
+     * @param evt the event object describing the contact addition.
+     */
+    public void contactAdded(ContactAddedEvent evt)
+    {
+        //The node where the children are being added.
+       ContactGroup parent = evt.getSourceLocation()[evt.getSourceLocation().length - 1];
+
+       //The path to parent;
+       ContactGroup[] pathToParent = new ContactGroup[evt.getSourceLocation().length - 1];
+       System.arraycopy(evt.getSourceLocation(), 0, pathToParent, 0, pathToParent.length);
+
+        super.fireTreeNodesInserted( parent,
+                                     pathToParent,
+                                     new int[] {evt.getIndex()},
+                                     new Contact[] {evt.getSourceContact()});
+
+    }
+
+    /**
+     * Notifies the communications part of of the application that the user
+     * wishes to remove the contact described by <code>request</code> from their
+     * contact list.
+     *
+     * @param request request that contains details about the contact the the
+     *   user wishes to add to their contact list.
+     */
+    public void requestContactRemoval(ContactRemovalRequest request)
+    {
+        try {
+            //create a contact group location array
+            ContactGroup path[] = new ContactGroup[request.getLocation().length];
+            System.arraycopy(request.getLocation(), 0, path, 0, path.length);
+
+            contactListController.requestContactRemoval(
+                path,
+                (Contact)request.getContact());
+        }
+        catch (CommunicationsException ex) {
+            console.showException("Failed to remove contact for user "
+                                  + request.getContact().toString(),
+                                  ex);
+        }
+    }
+
+
+    /**
+     * Called when a contact has been removed from the contact list.
+     * @param evt the event object describing the contact addition.
+     */
+    public void contactRemoved(ContactRemovedEvent evt)
+    {
+        //The node where the children are being added.
+       ContactGroup parent = evt.getSourceLocation()[evt.getSourceLocation().length - 1];
+
+       //The path to parent;
+       ContactGroup[] pathToParent = new ContactGroup[evt.getSourceLocation().length - 1];
+       System.arraycopy(evt.getSourceLocation(), 0, pathToParent, 0, pathToParent.length);
+
+        super.fireTreeNodesRemoved( parent,
+                                     pathToParent,
+                                     new int[] {evt.getIndex()},
+                                     new Contact[] {evt.getSourceContact()});
+
     }
 
 }

File [changed]: SipCommunicator.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/SipCommunicator.java?r1=1.16&r2=1.17
Delta lines:  +33 -12
---------------------
--- SipCommunicator.java	13 Apr 2004 13:46:28 -0000	1.16
+++ SipCommunicator.java	26 May 2004 09:09:08 -0000	1.17
@@ -203,6 +203,16 @@
                     exc);
             }
 
+            boolean startSimple = false;
+            try {
+                startSimple = Boolean.valueOf(Utils.getProperty(
+                    "net.java.sip.communicator.ENABLE_SIMPLE")).booleanValue();
+            }
+            catch (Exception ex) {
+                console.debug("Couldn't read net.java.sip.communicator.ENABLE_SIMPLE. Assuming false", ex);
+            }
+            if(startSimple)
+            {
             //get the contact list only after registering in case its stored on
             //a remote server
                 try {
@@ -213,17 +223,21 @@
                              + Utils.getProperty(
                                 "net.java.sip.communicator.sip.simple.CONTACT_LIST_FILE"));
                      simpleContactList.setRoot(cList);
-                     simpleContactList.setContactListController(sipManager.getContactListController());
+                    simpleContactList.setContactListController(sipManager.
+                        getContactListController());
 
-                    presenceStatusController = new PresenceStatusController(sipManager.getPresenceStatusManager());
+                    presenceStatusController = new PresenceStatusController(
+                        sipManager.getPresenceStatusManager());
                     guiManager.setContactListModel(simpleContactList);
 
-                    guiManager.setStatusControllerUiModel(presenceStatusController);
+                    guiManager.setStatusControllerUiModel(
+                        presenceStatusController);
 
                     //it is important that the following call comes after registering and after
                     //initialization of the presenceStatusController
-                    String initialStatus = Utils.getProperty("net.java.sip.communicator.sip.simple.LAST_SELECTED_OPEN_STATUS");
-                    if(initialStatus == null)
+                    String initialStatus = Utils.getProperty(
+                        "net.java.sip.communicator.sip.simple.LAST_SELECTED_OPEN_STATUS");
+                    if (initialStatus == null)
                         initialStatus = PresenceTuple.EXTENDED_STATUS_ONLINE;
                     presenceStatusController.requestStatusChange(initialStatus);
                 }
@@ -232,6 +246,7 @@
                     console.showException(ex);
                 }
         }
+        }
         finally {
             console.logExit();
         }
@@ -241,6 +256,12 @@
     {
         try {
             console.logEntry();
+            //timestamp the log
+            Calendar cal = GregorianCalendar.getInstance();
+            cal.setTimeInMillis(System.currentTimeMillis());
+            console.debug("Sip Communicator Session, "
+                          + cal.get(Calendar.YEAR) + "-" + cal.get(Calendar.MONTH) + "-" + cal.get(Calendar.DATE) + " " //date
+                          + cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE) + ":" + cal.get(Calendar.SECOND)); //time
 
             //dump startup properties for easier debug
             Enumeration systemProperties = System.getProperties().keys();




---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe at sip-communicator.dev.java.net
For additional commands, e-mail: cvs-help at sip-communicator.dev.java.net




More information about the commits mailing list