reSIProcate/DialogUsageManager  9680
ContactInstanceRecord.cxx
Go to the documentation of this file.
00001 #include "resip/dum/ContactInstanceRecord.hxx"
00002 #include "resip/stack/Helper.hxx"
00003 #include "rutil/Timer.hxx"
00004 #include "resip/stack/SipMessage.hxx"
00005 
00006 using namespace resip;
00007 
00008 ContactInstanceRecord::ContactInstanceRecord() : 
00009    mRegExpires(0),
00010    mLastUpdated(Timer::getTimeSecs()),
00011    mRegId(0),
00012    mSyncContact(false),
00013    mUseFlowRouting(false),
00014    mUserInfo(0)
00015 {
00016 }
00017 
00018 bool
00019 ContactInstanceRecord::operator==(const ContactInstanceRecord& rhs) const
00020 {
00021    if((mRegId != 0 && !mInstance.empty()) || 
00022       (rhs.mRegId != 0 && !rhs.mInstance.empty()))
00023    {
00024       // If regId and instanceId is specified on either, then outbound RFC5626 is 
00025       // in use - match only if both instance id and reg-id match - ignore contact URI
00026       return mInstance == rhs.mInstance && 
00027              mRegId == rhs.mRegId;
00028    }
00029    else
00030    {
00031       // otherwise both instance (if specified) and contact must match
00032       return mInstance == rhs.mInstance &&
00033              mContact.uri() == rhs.mContact.uri();
00034    }
00035 }
00036 
00037 ContactInstanceRecord 
00038 ContactInstanceRecord::makeRemoveDelta(const NameAddr& contact)
00039 {
00040    ContactInstanceRecord c;
00041    c.mContact = contact;
00042    return c;
00043 }
00044 
00045 ContactInstanceRecord 
00046 ContactInstanceRecord::makeUpdateDelta(const NameAddr& contact, 
00047                                        UInt64 expires,  // absolute time in secs
00048                                        const SipMessage& msg)
00049 {
00050    ContactInstanceRecord c;
00051    c.mContact = contact;
00052    c.mRegExpires = expires;
00053    c.mReceivedFrom = msg.getSource();
00054    c.mPublicAddress = Helper::getClientPublicAddress(msg);
00055    if (msg.exists(h_Paths))
00056    {
00057       c.mSipPath = msg.header(h_Paths);
00058    }
00059    if (contact.exists(p_Instance))
00060    {
00061       c.mInstance = contact.param(p_Instance);
00062    }
00063    if (contact.exists(p_regid))
00064    {
00065       c.mRegId = contact.param(p_regid);
00066    }
00067    // !jf! need to fill in mServerSessionId here
00068    return c;
00069   
00070 }
00071 
00072