2 #include "NamingViewer.h"
3 #include "ViewIORDialog.h"
4 #include "tao/IIOP_Profile.h"
10 static char THIS_FILE
[] = __FILE__
;
13 /////////////////////////////////////////////////////////////////////////////
14 // ViewIORDialog dialog
17 ViewIORDialog::ViewIORDialog(CORBA::ORB_ptr pORB
, CORBA::Object_ptr pObject
, CWnd
* pParent
/*=NULL*/)
18 : CDialog(ViewIORDialog::IDD
, pParent
)
20 //{{AFX_DATA_INIT(ViewIORDialog)
27 m_Object
= CORBA::Object::_duplicate(pObject
);
29 CORBA::String_var IOR
= pORB
->object_to_string(pObject
);
34 void ViewIORDialog::DoDataExchange(CDataExchange
* pDX
)
36 CDialog::DoDataExchange(pDX
);
37 //{{AFX_DATA_MAP(ViewIORDialog)
38 DDX_Control(pDX
, IDC_PROFILES
, m_Profiles
);
39 DDX_Text(pDX
, IDC_TYPE_ID
, m_TypeID
);
40 DDX_Text(pDX
, IDC_IOR
, m_IOR
);
45 BEGIN_MESSAGE_MAP(ViewIORDialog
, CDialog
)
46 //{{AFX_MSG_MAP(ViewIORDialog)
47 ON_BN_CLICKED(IDC_APPLY
, OnApply
)
51 /////////////////////////////////////////////////////////////////////////////
52 // ViewIORDialog message handlers
54 BOOL
ViewIORDialog::OnInitDialog()
56 CDialog::OnInitDialog();
58 // TODO: Add extra initialization here
60 return TRUE
; // return TRUE unless you set the focus to a control
61 // EXCEPTION: OCX Property Pages should return FALSE
64 void ViewIORDialog::OnApply()
66 // TODO: Add your control notification handler code here
70 m_Object
= m_pORB
->string_to_object(m_IOR
);
73 catch(CORBA::Exception
& ex
)
75 MessageBox(ACE_TEXT_CHAR_TO_TCHAR (ex
._rep_id()), ACE_TEXT ("CORBA::Exception"));
79 void ViewIORDialog::DecodeIOR()
82 m_Profiles
.DeleteAllItems();
86 // if object is nil, return out
87 if(CORBA::is_nil(m_Object
))
93 TAO_Stub
* pStub
= m_Object
->_stubobj();
94 const char* pType
= pStub
->type_id
;
95 m_TypeID
= pType
? pType
: ""; // special case for INS objects, tao doesn't get the type id
98 // Iterate through each profile and add an entry to the tree control
99 const TAO_MProfile
& BaseProfiles
= pStub
->base_profiles();
100 CORBA::ULong
const Count
= BaseProfiles
.profile_count();
101 for(CORBA::ULong Slot
= 0; Slot
< Count
; Slot
++)
103 const TAO_Profile
* pProfile
= BaseProfiles
.get_profile(Slot
);
105 switch(pProfile
->tag())
107 case 0: //IOP::TAG_INTERNET_IOP:
109 TAO_IIOP_Profile
* pIIOPProfile
= (TAO_IIOP_Profile
*)pProfile
;
110 CString ProfileString
;
111 ProfileString
.Format(ACE_TEXT ("IIOP %d.%d"),
112 pIIOPProfile
->version().major
,
113 pIIOPProfile
->version().minor
);
114 hProfile
= m_Profiles
.InsertItem(ProfileString
);
115 TAO_IIOP_Endpoint
* pIIOPEndpoint
=
116 (TAO_IIOP_Endpoint
*)pIIOPProfile
->endpoint ();
119 CString EndpointString
;
120 EndpointString
.Format(ACE_TEXT ("%s:%d"),
121 pIIOPEndpoint
->host(),
122 pIIOPEndpoint
->port());
123 HTREEITEM hItem
= m_Profiles
.InsertItem(EndpointString
, hProfile
);
124 m_Profiles
.EnsureVisible(hItem
);
125 pIIOPEndpoint
= (TAO_IIOP_Endpoint
*)pIIOPEndpoint
->next();
132 CString ProfileString
;
133 char* pToString
= ((TAO_Profile
*)pProfile
)->to_string();
134 ProfileString
.Format(ACE_TEXT ("Unknown Profile (Tag=%d) %s"), pProfile
->tag(), pToString
);
136 hProfile
= m_Profiles
.InsertItem(ProfileString
);