I've downloaded and succesfully compiled and run the TestServiceAPI example.
Based upon it, I've written my own code to create or update a given service
and connection, but I can't get it to work correctly.

It creates and/or modifies apparently well the preferences, but I can't get
the application to dial: the Palm complains that the "telephone number has
invalid characters or number too long". If I tap number, and do any trivial
editing (i.e, I add and remove a blank at the end of the number), I can
connect without trouble.

Here is the part of the code that sets the network settings, from a
structure that's correctly read from a Palm db:

HandleFromString is the same as in the TestServiceAPI sample code, and
MemHandleFreeIfAllocated performs a MemHandleUnlock if the handle is not
NULL.

Err CrearPreferenciasDesdeConex(t_conex *datosConexPtr,
        NetworkPreferencesType *networkPrefsPtr,
        PhonePrefType *phonePrefsPtr)
{
 UInt16 phoneLength;
 // Limpiar datos iniciales, liberando los handles que sea necesario


 // There are more stuff to set. This is the minimum to illustrate the use.
 // Please check the struct for all the members and read the table 54.1 in
the
 // SDK reference guide for more information.
 MemHandleFreeIfAllocated(networkPrefsPtr->serviceNameH);
 MemHandleFreeIfAllocated(networkPrefsPtr->usernameH);
 MemHandleFreeIfAllocated(networkPrefsPtr->passwordH);
 MemHandleFreeIfAllocated(networkPrefsPtr->connectionH);
 MemHandleFreeIfAllocated(phonePrefsPtr->phoneH);
 MemHandleFreeIfAllocated(phonePrefsPtr->prefixH);
 MemHandleFreeIfAllocated(phonePrefsPtr->callWaitingH);
 MemHandleFreeIfAllocated(phonePrefsPtr->callingCardH);

 //Network settings
 //Connection settings
 // You should be able to create new connections using the CncXXXXXXX
routine
 // ConnectionMgr.h
 networkPrefsPtr->dirty    = true; // hay que actualizar
 networkPrefsPtr->connectionH  = HandleFromString(kNombreConexion);
 networkPrefsPtr->serviceNameH  = HandleFromString(kNombreConexion);
 networkPrefsPtr->usernameH   = HandleFromString(datosConexPtr->user);
 networkPrefsPtr->passwordH   = HandleFromString(datosConexPtr->password);

 networkPrefsPtr->base.interface  = netIFCreatorPPP;
 networkPrefsPtr->base.dynamicIP  = true;
 networkPrefsPtr->base.ipAddr  = inet_network("0.0.0.0"); //set the static
IP
 networkPrefsPtr->base.primaryDNS = inet_network(datosConexPtr->DNS1);
 networkPrefsPtr->base.secondaryDNS = inet_network(datosConexPtr->DNS2);
 if ((networkPrefsPtr->base.primaryDNS | networkPrefsPtr->base.secondaryDNS)
== 0)
 {
  networkPrefsPtr->base.noDNSQuery= false;
 }
 else
 {
  networkPrefsPtr->base.noDNSQuery= true;
 }


 networkPrefsPtr->base.useModem = true;
 phoneLength = StrLen(datosConexPtr->numTelefono);
 if ((phoneLength == 0) || (StrCompare(datosConexPtr->numTelefono, "00") ==
0))
 {
  networkPrefsPtr->base.useModem = false;
 }

 networkPrefsPtr->base.useVJCompression  = true;
 networkPrefsPtr->base.establishmentTimeout = defEstablishmentTimeout;
 networkPrefsPtr->base.closeWaitTime   = maxCloseWaitTime; // default to
powerOff
 networkPrefsPtr->base.stringCount   = minRecordStrings;



 //Phone settings
 phonePrefsPtr->phoneH     = HandleFromString(datosConexPtr->numTelefono);
 phonePrefsPtr->prefixH     = HandleFromString(",");
 phonePrefsPtr->callWaitingH    = HandleFromString(",");
 phonePrefsPtr->callingCardH    = HandleFromString(",");
 phonePrefsPtr->flags.dialPrefixEnabled = false; // dial prefix string
enabled
 phonePrefsPtr->flags.callWaitingEnabled = false; // call waiting string
enabled
 phonePrefsPtr->flags.callingCardEnabled = false; // calling card string
enabled
 phonePrefsPtr->flags.pulseDial   = false; // if true, pulse dial, otherwise
touch-tone
 phonePrefsPtr->dirty     = true; // hay que actualizar

}

Thanks in advance for your help.


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to