Merge pull request #137 from ArvidNorr/choose_shortcutdev

support for preferred combo box choice added
ulab-next-nosound
jsorg71 10 years ago
commit 0d63263772

@ -242,6 +242,74 @@ xrdp_wm_ok_clicked(struct xrdp_bitmap *wnd)
return 0;
}
/**
* This is an internal function in this file used to parse the domain information
* sent from the client.
* If the information starts with '_' the domain field contains the
* IP/DNS to connect to. If the domain field contains an additional '__' the char
* that follows this '__' is an index number of a preferred combo choice.
* Valid values for this choice is 0-9. But this function will only return index
* numbers between 0 and the max number of combo items -1.
* Example: _192.168.1.2__1 result in a resultbuffer containing 192.168.1.2 and
* the return value will be 1. Meaning that index 1 is the preferred combo choice.
*
* Users can create shortcuts where this information is configured. These
* shortcuts simplifies login.
* @param orginalDomainInfo indata to this function
* @param comboMax the max number of combo choices
* @param decode if true then we perform decoding of combo choice
* @param resultBuffer must be pre allocated before calling this function.
* Holds the IP. The size of this buffer must be 256 bytes
* @return the index number of the combobox that the user prefer.
* 0 if the user does not prefer any choice.
*/
static int APP_CC xrdp_wm_parse_domain_information(char *orginalDomainInfo, int comboMax, int decode, char *resultBuffer)
{
/* If the first char in the domain name is '_' we use the domain name as IP*/
int ret = 0; // default return value
g_memset(resultBuffer, 0, 255);
if(orginalDomainInfo[0]=='_')
{
/* we try to locate a number indicating what combobox index the user prefer
* the information is loaded from domain field, from the client
* log_message(LOG_LEVEL_DEBUG, "domain contains _");
* We must use valid chars in the domain name.
* Underscore is a valid name in the domain.
* Invalid chars are ignored in microsoft client therefore we use '_' again.
* this sec '__' contains the split for index.*/
int pos = g_pos(&orginalDomainInfo[1],"__");
if(pos>0)
{
/* an index is found we try to use it
log_message(LOG_LEVEL_DEBUG, "domain contains index char __");*/
if(decode)
{
char index[2] ;
char debugstr[256] ;
g_memset(index, 0, 2) ;
int comboxindex ;
g_strncpy(index, &orginalDomainInfo[pos+3], 1); // we just accept values 0-9 (one figure)
comboxindex = g_htoi(index) ;
g_sprintf(debugstr, "Value of index (as char): %s (converted) : %d (max) : %d",index,comboxindex,comboMax-1);
log_message(LOG_LEVEL_DEBUG, debugstr);
if(comboxindex>0 && comboxindex<comboMax) // limit to max number of items in combo box
{
log_message(LOG_LEVEL_DEBUG, "domain contains a valid index number");
ret = comboxindex ; // preferred index for combo box.
}
}
// pos limit the String to only contain the IP
g_strncpy(resultBuffer, &orginalDomainInfo[1], pos);
}
else
{
//log_message(LOG_LEVEL_DEBUG, "domain does not contain _");
g_strncpy(resultBuffer, &orginalDomainInfo[1], 255);
}
}
return ret ;
}
/******************************************************************************/
static int APP_CC
xrdp_wm_show_edits(struct xrdp_wm *self, struct xrdp_bitmap *combo)
@ -269,7 +337,7 @@ xrdp_wm_show_edits(struct xrdp_wm *self, struct xrdp_bitmap *combo)
}
insert_index = list_index_of(self->login_window->child_list,
(long)combo);
(long)combo); // find combo in the list
insert_index++;
mod = (struct xrdp_mod_data *)
list_get_item(combo->data_list, combo->item_index);
@ -330,7 +398,9 @@ xrdp_wm_show_edits(struct xrdp_wm *self, struct xrdp_bitmap *combo)
/* If the first char in the domain name is '_' we use the domain name as IP*/
if(self->session->client_info->domain[0]=='_')
{
g_strncpy(b->caption1, &self->session->client_info->domain[1], 255);
char resultIP[256];
xrdp_wm_parse_domain_information(self->session->client_info->domain,combo->data_list->count,0,resultIP);
g_strncpy(b->caption1, resultIP, 255);
b->edit_pos = g_mbstowcs(0, b->caption1, 0);
}
@ -665,7 +735,12 @@ xrdp_login_wnd_create(struct xrdp_wm *self)
but->tab_stop = 1;
self->login_window->esc_button = but;
/* labels and edits */
/* labels and edits.
* parameter: 1 = decode domain field index information from client.
* We only perform this the first time for each connection.
*/
char resultIP[256]; // just a dummy place holder, we ignore
combo->item_index = xrdp_wm_parse_domain_information(self->session->client_info->domain,combo->data_list->count,1,resultIP);
xrdp_wm_show_edits(self, combo);
return 0;

Loading…
Cancel
Save