reSIProcate/DialogUsageManager  9680
DialogEventStateManager.hxx
Go to the documentation of this file.
00001 #if !defined(RESIP_DialogEventStateManager_HXX)
00002 #define RESIP_DialogEventStateManager_HXX
00003 
00004 #include "resip/dum/DialogEventInfo.hxx"
00005 #include "resip/dum/DialogEventHandler.hxx"
00006 #include "resip/dum/InviteSessionHandler.hxx"
00007 #include "resip/dum/Dialog.hxx"
00008 #include "resip/dum/DialogSet.hxx"
00009 
00010 namespace resip
00011 {
00012 
00017 class DialogEventStateManager
00018 {
00019    public:
00020    typedef std::vector<DialogEventInfo> DialogEventInfos;
00021    DialogEventInfos getDialogEventInfo() const;
00022 
00023    virtual ~DialogEventStateManager();
00024 
00025 private:
00026       DialogEventStateManager();
00027       
00028       void onTryingUas(Dialog& dialog, const SipMessage& invite);
00029       void onTryingUac(DialogSet& dialogSet, const SipMessage& invite);
00030       void onProceedingUac(const DialogSet& dialogSet, const SipMessage& response);
00031 
00032    //?dcm? how is direction determined when the onEarly is the first use of
00033    //this dialog?
00034       void onEarly(const Dialog& dialog, InviteSessionHandle is);
00035       
00036       void onConfirmed(const Dialog& dialog, InviteSessionHandle is);
00037       void onTerminated(const Dialog& dialog, const SipMessage& msg, InviteSessionHandler::TerminatedReason reason);
00038       
00039       void onTerminated(const DialogSet& dialogSet, const SipMessage& msg, InviteSessionHandler::TerminatedReason reason);
00040       
00041       
00042    // order by DialogSet, such that the following ordering occurs
00043    // DialogSetId          remoteTag
00044    //     a                  null
00045    //     a                   1
00046    //     a                   2
00047    //     b                   1
00048    //     b                   2
00049    class DialogIdComparator
00050    {
00051    public:
00052       bool operator()(const DialogId& x, const DialogId& y) const
00053       {
00054          if (x.getDialogSetId() == y.getDialogSetId())
00055          {
00056             return (x.getRemoteTag() < y.getRemoteTag());
00057          }
00058          return (x.getDialogSetId() < y.getDialogSetId());
00059       }
00060    };
00061 
00062    DialogEventInfo* findOrCreateDialogInfo(const Dialog& dialog);
00063 
00064    void onDialogSetTerminatedImpl(const DialogSetId& dialogSetId, const SipMessage& msg, InviteSessionHandler::TerminatedReason reason);
00065    TerminatedDialogEvent* onDialogTerminatedImpl(DialogEventInfo* eventInfo, InviteSessionHandler::TerminatedReason reason, 
00066                                                  int responseCode = 0, Uri* remoteTarget = NULL);
00067 
00068    static int getResponseCode(const SipMessage& msg);
00069    static Uri* getFrontContact(const SipMessage& msg);
00070 
00071 private:
00072 
00073    friend class DialogUsageManager;
00074    friend class ServerInviteSession;
00075    friend class ClientInviteSession;
00076    friend class InviteSession;
00077    friend class DialogSet;
00078 
00079    // disabled
00080    DialogEventStateManager(const DialogEventStateManager& orig);
00081 
00082    // .jjg. we'll only have the DialogSetId if we aren't yet in the 'early' state;
00083    // once we get to early, we'll remove the DialogSetId in favour of the DialogId.
00084    // The comparator/key of the map must have an ordering so that a key can be
00085    // contructed which points to the beginning of a dialogSet.  This could be done by
00086    // no remote tag being always, which might be the existing behaviour, but
00087    // shouldn't be relied on.
00088    std::map<DialogId, DialogEventInfo*, DialogIdComparator> mDialogIdToEventInfo;
00089 
00090    DialogEventHandler* mDialogEventHandler;
00091 };
00092 
00093 }
00094 #endif