Hi all,
I've been away on business and unsubscribed for awhile, so I'm just getting
back into this and probably missed some great conversations and programming
tips. Oh well, no time now to catch up!
Here is my current programming challenge. I need my vertical market
application to modify the currently selected but inactive (not on-line)
network connection phone number before opening a dial-up network connection.
In this case we need to simply add a "9," or "1-" or "9,1-" or nothing at
all to the phone number. Instead of forcing our non-techie end user to go
out to the preferences panel and possibly mess things up, it is so much
better just to offer check boxes right then and there.
What I am doing is using the NetLibIFSettingGet()/...Set() API calls to
effect this. It seem works in the emulator (Palm IIIx and V), on a real Palm
III, and the Symbol SPT-1500. However, the new SPT-1700 is oblivious to my
attempts to adjust the phone number. It looks like it gets set, but when it
actually dials the network connection, it uses the phone number from the
Preferences panel. Very, very frustrating.
I'm wondering if it is an OS version issue. The Palm III is running OS 3.0.
The emulated Palm IIIx and V are running OS 3.1. The SPT-1700 is running OS
3.2, and that's the one that's acting funny.
Now for the gory details... here is my code to change the number for the
connection "HSA Server" before opening a connection: (sorry for the ugly
formatting via e-mail - I've tried to snip out the boring stuff)
----- warning - gory code begins here -----
// this is the name of our network connection
// from the Network Prefs panel
#define SERVICE_NAME "HSA Server"
Err Network_SetPhone(Boolean bDial9, Boolean bDial1)
{
//
// (snip) bunch of variable declarations (really!)
//
// get the network library reference
err = SysLibFind("Net.lib", &netlib);
ErrFatalDisplayIf(err, "Can not find net library.");
// This next part seems to work perfectly
// loop through the network "connections" to find the one we like
// BTW - iInterface starts out 0 from the initializations up top
do
{
err = NetLibIFGet(netlib, iInterface, &dwCreator, &wInstance);
// is this the one we want? then break out of loop
if (!err)
{
wBufLen = sizeof(szServiceName);
err = NetLibIFSettingGet(netlib, dwCreator, wInstance,
netIFSettingServiceName, szServiceName, &wBufLen);
if (!err && 0==StrCompare(szServiceName, SERVICE_NAME))
break;
}
iInterface++;
} while (!err);
// (snip) - pop up alert and bail if we couldn't find the one we wanted
// at this point dwCreator and wInstance reference
// our "HSA Server" connection settings
// get the length of the current phone number
wBufLen = 0;
NetLibIFSettingGet(netlib, dwCreator, wInstance, netIFSettingModemPhone,
NULL, &wBufLen);
ErrFatalDisplayIf(!wBufLen, "0 length phone setting.");
wBufLen += 4;
// we may end up prefixing up to four characters, worse case: "9,1-"
szPhone = MemPtrNew(wBufLen);
szNewPhone = MemPtrNew(wBufLen);
// (snip) - some error checking
// now get the actual phone number
err = NetLibIFSettingGet(netlib, dwCreator, wInstance,
netIFSettingModemPhone, szPhone, &wBufLen);
// (snip) more error checking...
// (snip) - and a miracle happens, we add/remove special dialing codes here
// so now szNewPhone contains what we want to dial, szPhone still
// has the original number
// and this alert indeed displays the new phone number as retrieved
// from the network settings and modified above
FrmCustomAlert(MsgBoxAlert, "(1) szNewPhone =", szNewPhone, "");
// now let's set the new phone number
err = NetLibIFSettingSet(netlib, dwCreator, wInstance,
netIFSettingModemPhone, szNewPhone, StrLen(szNewPhone) + 1);
ErrFatalDisplayIf(err, "Could not set phone");
// debug only - let's re-get the phone and make sure it was set
// (snip) minor gymnastics with wBufLen to make sure it reflects reality
err = NetLibIFSettingGet(netlib, dwCreator, wInstance,
netIFSettingModemPhone, szPhone, &wBufLen);
// and yes, this alert displays the new phone number as well,
// so it did get set.. this works on all of the devices I've tested
FrmCustomAlert(MsgBoxAlert, "(2) szPhone =", szPhone, "");
// here, I'm now opening the network library now so it
// dials the connection. All of the devices except the 1700 dial
// the new phone number! The 1700 dials the phone number
// from the Preferences panel. Argh! This is crazy!
// free the strings
if (szNewPhone)
MemPtrFree(szNewPhone);
if (szPhone)
MemPtrFree(szPhone);
return 0;
}
----- end of gory code -----
OK, ok, I know any normal application shouldn't mess with one's network
settings like this. However, this being a vertical market solution, we've
had to do a lot of non-standard things to make the device as a whole usable
in an industrial environment by oftentimes less-than-computer-literate
users.
So far, I gather what I'm doing here are "legal" PalmOS API calls. It's not
like I'm writing directly to the network prefs database (my Plan A until I
thought I had this Set/Get API figured out). But is there something I'm just
leaving out, and the pre 3.2 OS'es let me get away with it, but 3.2 itself
does not like? I hope it IS something I'm doing wrong and not a bug in the
Symbol 1700 ROM. Deadlines are looming!! Eeek!
If we can't figure this one out, I'm going to try a plan B, which is to
create four network configurations, each with a different variation of the
phone number prefixes. I will then attempt to set the new default interface
(connection) rather than modify the phone number, but I have a feeling the
1700 still won't listen. It's worth a try, though.
Thank you,
Geoff Shepherd
Hayton Systems+Applications
[EMAIL PROTECTED]
http://www.haytonsystems.com