1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
// $Id$
#include "stdafx.h"
#include "NamingViewer.h"
#include "ViewIORDialog.h"
#include "tao/IIOP_Profile.h"
#include "tao/Stub.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// ViewIORDialog dialog
ViewIORDialog::ViewIORDialog(CORBA::ORB_ptr pORB, CORBA::Object_ptr pObject, CWnd* pParent /*=NULL*/)
: CDialog(ViewIORDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(ViewIORDialog)
m_TypeID = _T("");
m_IOR = _T("");
//}}AFX_DATA_INIT
m_pORB = pORB;
if(pObject)
{
m_Object = CORBA::Object::_duplicate(pObject);
}
CORBA::String_var IOR = pORB->object_to_string(pObject);
m_IOR = IOR;
}
void ViewIORDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(ViewIORDialog)
DDX_Control(pDX, IDC_PROFILES, m_Profiles);
DDX_Text(pDX, IDC_TYPE_ID, m_TypeID);
DDX_Text(pDX, IDC_IOR, m_IOR);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(ViewIORDialog, CDialog)
//{{AFX_MSG_MAP(ViewIORDialog)
ON_BN_CLICKED(IDC_APPLY, OnApply)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// ViewIORDialog message handlers
BOOL ViewIORDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
DecodeIOR();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void ViewIORDialog::OnApply()
{
// TODO: Add your control notification handler code here
UpdateData();
try
{
m_Object = m_pORB->string_to_object(m_IOR);
DecodeIOR();
}
catch(CORBA::Exception& ex)
{
MessageBox(ex._rep_id(), "CORBA::Exception");
}
}
void ViewIORDialog::DecodeIOR()
{
// Reset the fields
m_Profiles.DeleteAllItems();
m_TypeID = "";
UpdateData(FALSE);
// if object is nil, return out
if(CORBA::is_nil(m_Object))
{
return;
}
// Get the stub
TAO_Stub* pStub = m_Object->_stubobj();
const char* pType = pStub->type_id;
m_TypeID = pType ? pType : ""; // special case for INS objects, tao doesn't get the type id
UpdateData(FALSE);
// Iterate through each profile and add an entry to the tree control
const TAO_MProfile& BaseProfiles= pStub->base_profiles();
CORBA::ULong Count = BaseProfiles.profile_count();
for(CORBA::ULong Slot = 0; Slot < Count; Slot++)
{
const TAO_Profile* pProfile = BaseProfiles.get_profile(Slot);
HTREEITEM hProfile;
switch(pProfile->tag())
{
case 0: //IOP::TAG_INTERNET_IOP:
{
TAO_IIOP_Profile* pIIOPProfile = (TAO_IIOP_Profile*)pProfile;
CString ProfileString;
ProfileString.Format("IIOP %d.%d",
pIIOPProfile->version().major,
pIIOPProfile->version().minor);
hProfile = m_Profiles.InsertItem(ProfileString);
TAO_IIOP_Endpoint* pIIOPEndpoint =
(TAO_IIOP_Endpoint*)pIIOPProfile->endpoint ();
while(pIIOPEndpoint)
{
CString EndpointString;
EndpointString.Format("%s:%d",
pIIOPEndpoint->host(),
pIIOPEndpoint->port());
HTREEITEM hItem = m_Profiles.InsertItem(EndpointString, hProfile);
m_Profiles.EnsureVisible(hItem);
pIIOPEndpoint = (TAO_IIOP_Endpoint*)pIIOPEndpoint->next();
}
}
break;
default:
{
CString ProfileString;
char* pToString = ((TAO_Profile*)pProfile)->to_string();
ProfileString.Format("Unknown Profile (Tag=%d) %s", pProfile->tag(), pToString);
delete pToString;
hProfile = m_Profiles.InsertItem(ProfileString);
}
break;
}
}
}
|