Package org.zoolu.sip.header

Examples of org.zoolu.sip.header.ContactHeader


         for (Enumeration e=location_service.getUserContactURLs(user); e.hasMoreElements(); )
         {  String url=(String)e.nextElement();
            int expires=(int)(location_service.getUserContactExpirationDate(user,url).getTime()-System.currentTimeMillis())/1000;
            if (expires>0)
            {  // not expired
               ContactHeader ch=new ContactHeader(location_service.getUserContactNameAddress(user,url));
               ch.setExpires(expires);
               v.addElement(ch);
            }
         }
         if (v.size()>0) resp.setContacts(new MultipleHeader(v));
         return resp;
      }
      // else    

      Vector contacts=msg.getContacts().getHeaders();
      int result=200;
      Message resp=MessageFactory.createResponse(msg,result,SipResponses.reasonOf(result),null)

      ContactHeader contact_0=new ContactHeader((Header)contacts.elementAt(0));
      if (contact_0.isStar())
      {  printLog("DEBUG: ContactHeader is star",LogLevel.LOW);
         Vector resp_contacts=new Vector();
         for (Enumeration e=location_service.getUserContactURLs(user); e.hasMoreElements();)
         {  String url=(String)(e.nextElement());
            NameAddress name_address=location_service.getUserContactNameAddress(user,url);
            // update db
            location_service.removeUserContact(user,url);
            printLog("contact removed: "+url,LogLevel.LOW);
            if (exp_secs>0)
            {  Date exp_date=new Date(System.currentTimeMillis()+((long)exp_secs)*1000);
               location_service.addUserContact(user,name_address,exp_date);
               //DateFormat df=new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss 'GMT'",Locale.ITALIAN);
               //printLog("contact added: "+url+"; expire: "+df.format(location_service.getUserContactExpire(user,url)),LogLevel.LOW);
               printLog("contact added: "+url+"; expire: "+DateFormat.formatEEEddMMM(location_service.getUserContactExpirationDate(user,url)),LogLevel.LOW);
            }
            ContactHeader contact_i=new ContactHeader(name_address.getAddress());
            contact_i.setExpires(exp_secs);
            resp_contacts.addElement(contact_i);
         }
         if (resp_contacts.size()>0) resp.setContacts(new MultipleHeader(resp_contacts));
      }
      else
      Vector resp_contacts=new Vector();
         for (int i=0; i<contacts.size(); i++)    
         {  ContactHeader contact_i=new ContactHeader((Header)contacts.elementAt(i));
            NameAddress name_address=contact_i.getNameAddress();    
            String url=name_address.getAddress().toString();    
            int exp_secs_i=exp_secs;
            if (contact_i.hasExpires())
            {  exp_secs_i=contact_i.getExpires();
            }
            // limit the expire value
            if (exp_secs_i<0) exp_secs_i=0;
            else
            if (exp_secs_i>server_profile.expires) exp_secs_i=server_profile.expires;
                       
            // update db
            location_service.removeUserContact(user,url);
            if (exp_secs_i>0)
            {  Date exp_date=new Date(System.currentTimeMillis()+((long)exp_secs)*1000);
               location_service.addUserContact(user,name_address,exp_date);
               printLog("registration of user "+user+" updated",LogLevel.HIGH);
            }          
            contact_i.setExpires(exp_secs_i);
            resp_contacts.addElement(contact_i);
         }
         if (resp_contacts.size()>0) resp.setContacts(new MultipleHeader(resp_contacts));
      }

View Full Code Here


   /** Adds a new contact.
     * @param contact the contact address (NameAddress)
     * @param expire the expire value (Date)
     * @return this object */
   public UserBindingInfo addContact(NameAddress contact, Date expire)
   {  contact_list.put(contact.getAddress().toString(),(new ContactHeader(contact)).setExpires(expire));
      return this;
   }
View Full Code Here

  
   /** Gets expiration date.
     * @param url the contact url (String)
     * @return the expire Date */
   public Date getExpirationDate(String url)
   {  ContactHeader contact=(ContactHeader)contact_list.get(url);
      //System.out.println("DEBUG: UserBindingInfo: ContactHeader: "+contact.toString());
      //System.out.println("DEBUG: UserBindingInfo: expires param: "+contact.getParameter("expires"));
      if (contact_list.containsKey(url)) return ((ContactHeader)contact_list.get(url)).getExpiresDate();
      else return null;
   }
View Full Code Here

   /** Gets the String value of this Object.
     * @return the String value */
   public String toString()
   {  String str="To: "+name+"\r\n";
      for (Enumeration i=getContacts(); i.hasMoreElements(); )
      {  ContactHeader ch=(ContactHeader)contact_list.get(i.nextElement());
         str+=ch.toString();
      }
      return str;
   }
View Full Code Here

TOP

Related Classes of org.zoolu.sip.header.ContactHeader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.