Routing Call for lower costs
| Mon, 2006-05-22 11:06 | |
|
hi i'm developping an app which aims to lower costs of international costs. the idea is to :
-if the number is international, call the gateway first, pause and then call dialed number -if not international, don't do anything and call dialed number. At this point, the user has inserted a number ina dialog box. i have a cpp file which affects the variable iroutage the value 1 if a routing is necessary, 0 if not. the problem is that there my app never puts the gateway number first, even if i dial a int'l number. could someone please check it out and tell me if he sees smthg wrong with it? please note that the number is inserted as a descriptor, treated and analysed as a char* ,then retransformed for dialing to a descriptor. thanks Code: if (callnb->iroutage==1) { conversion en descripteur char * routednumber = strcat("+33172926584p",nbnb); TBuf8<20> MyBufS = (unsigned char *)routednumber; //8 bit descrptor TBuf16<20> MyBufW; //16 bit descriptor MyBufW.Copy(MyBufS); TRAPD(err, DialNumberL(MyBufW); ); if (err) { User::InfoPrint(_L("Error dialing")); } |
|






Forum posts: 40
why use char*? You can use the descriptors.
What happens if you try to dial the number without the 'p' and the nbnb? does it work then?
Try to add log messages to the DialNumber function and see at what point your code doesn't work.
Imzadi
Forum posts: 114
thanks for your reply
i did use descriptors afterwords and you're right, it works, even when i concatenate with descriptors (with append()) the number with the pause works.
but the problem remains in the treating of the number, symbiandoesn't seem to like it because the app in the phone crashes whenever the number treatement function is called.
this function checks if the number is international or not, and decides to route or not.
however the code is more in pure c++, it still uses char, strcat, strcmp...
here is a snipet of that code. do you think i should change all types of variables?
thanks
{
int i;
i=0;
char* entete_num1 = new char ;
char* entete_num2 = new char ;
//Traitement du TON
//numero du serveur: +33172926584
if(strncmp(this->NumAppelant,this->CodePays,3)==0)
{
//Pas de roaming
// printf("\nLe Code Pays correspond a celui du numero Appelant : Pas de Roaming !!\n\n");
if (strcmp(this->TON,"international")==0)
{
//printf ("\nRoutage vers le serveur Transatel...\n" );
iroutage=1;
return iroutage;
}
Forum posts: 40
First thing's first. Stop using char* and switch to descriptors. I know it's difficult but it's for you own good, not to mention maintining Symbian convention.
Go own and make the change and then test again. If it's still doens't work, post the (revised) code again indicate where exactly the code crash.
Imzadi
Forum posts: 114
i use Set(const TDesc16 &aDes) to give values to my ex-char*.
i replaced strcmp by CompareC: for example
i replaced strcmp(numero,entete,3) by numero.ComparceC(entete,3,NULL)
is it alright?
now thye compilation stops at errors:
"Interoptcontainer.cpp": C2143: syntax error : missing ';' before '||' at line 386
so i think that symbian doesn't recognize "||" so i'm looking for the equivalent "or" operator.
here is my updated code:
{
//****************************************************
//iroutage=1 ----> route the call
//iroutage = 0 --------> don't route the call
//***********************************************
TInt i;
i=0;
TPtrC entete_num1 ;
TPtrC entete_num2 ;
//Traitement du TON
//numero du serveur: +33172926584
if(this->NumAppelant.CompareC(this->CodePays,3,NULL)==0)
{
//Pas de roaming
if (this->TON.Compare(_L("international"))==0)
{
//printf ("\nRoutage vers le serveur Transatel...\n" );
iroutage=1;
return iroutage;
}
if (this->TON.Compare(_L("unknown"))==0)
{
//Traitement du numéro
entete_num1.Set(_L("0033"));
entete_num2.Set(_L("+33"));
TInt i = 0;
if (numero.CompareC(entete_num1,2,NULL)==0) || (numero.CompareC(entete_num2,1,NULL)==0))
{
if(numero.CompareC(entete_num1,4,NULL)==0) || (numero.CompareC(entete_num2,3,NULL)==0))
{
//printf("\nLe Numero est au format international!!\n");
// printf("\nLe Code Pays correspond a la France : Appel local !!\n");
// printf ("\nArret de l'application CPS\n Appel direct possible...\n" );
iroutage=0;
return iroutage;
}
else
{
// printf("\nLe Numero est au format international!!\n");
// printf("\nLe Code Pays ne correspond pas a la France : Appel vers l'international !!\n");
// printf ("\nRoutage vers le serveur Transatel...\n" );
iroutage=1;
return iroutage;
}
}
else
{
// printf("\nLe Numero n'est pas international!!\n");
// printf("\n Appel direct en cours.... \n" );
iroutage=0;
return iroutage;
}
}
}
else
{
iroutage=0;
return iroutage;
// printf("\nLe Code Pays ne correspond pas a celui du numero Appelant : Roaming !!\n");
// printf ("\nLe code pays est : %s\n Le numero de l'appelant est : %s\n", this->CodePays, this->NumAppelant );
// printf ("\n Arret de l'application CPS\n Appel direct possible...\n" );
}
return iroutage;
}
Forum posts: 114
my code is now totally accepted by compilation.
however, whichever number i dial (local or international) it never decides to route.
so i think the problem comes from my function which analyses the number. could someone please help me with it.
(when executed, the original c++ code analysed correctly the number, but now that i replaced char * by TPtrC, etc.. it doesn't seem to)
so to sum up, there are two functions:
TraitementNumero() which analyses the number and returns TInt iroutage which if is =1 means the call has to be routed and if =0 , no routing.
{
//****************************************************
//iroutage=1 ----> route the call
//iroutage = 0 --------> don't route the call
//numserveur is the server number
//textnumb is the dialed number by the user
//Numappelant is the caller number
//CodePays is the country code
//***********************************************
iroutage=1;
TPtrC entete_num1 ;
TPtrC entete_num2 ;
//Traitement du TON
//numero du serveur: +33172926584
if(this->NumAppelant.CompareC(this->CodePays,3,NULL)==0)
{ //Pas de roaming
if (this->TON.Compare(_L("international"))==0)
{
//printf ("\nRoutage vers le serveur Transatel...\n" );
iroutage=1;
return iroutage;
}
if (this->TON.Compare(_L("unknown"))==0)
{
//Traitement du numéro
entete_num1.Set(_L("0033"));
entete_num2.Set(_L("+33"));
if (numero.CompareC(entete_num1,2,NULL)==0 || numero.CompareC(entete_num2,1,NULL)==0)
{
if(numero.CompareC(entete_num1,4,NULL)==0 || numero.CompareC(entete_num2,3,NULL)==0)
{
//printf("\nLe Numero est au format international!!\n");
// printf("\nLe Code Pays correspond a la France : Appel local !!\n");
// printf ("\nArret de l'application CPS\n Appel direct possible...\n" );
iroutage=0;
return iroutage;
}
else if (numero.CompareC(entete_num1,4,NULL)!=0 && numero.CompareC(entete_num2,3,NULL)!=0)
{
// printf("\nLe Numero est au format international!!\n");
// printf("\nLe Code Pays ne correspond pas a la France : Appel vers l'international !!\n");
// printf ("\nRoutage vers le serveur Transatel...\n" );
iroutage=1;
return iroutage;
}
}
else if (numero.CompareC(entete_num1,2,NULL)!=0 && numero.CompareC(entete_num2,1,NULL)!=0)
{
// printf("\nLe Numero n'est pas international!!\n");
// printf("\n Appel direct en cours.... \n" );
iroutage=0;
return iroutage;
}
}
else if (this->TON.Compare(_L("unknown"))!=0)
{
iroutage=0;
return iroutage;
// printf("\nLe Code Pays ne correspond pas a celui du numero Appelant : Roaming !!\n");
// printf ("\nLe code pays est : %s\n Le numero de l'appelant est : %s\n", this->CodePays, this->NumAppelant );
// printf ("\n Arret de l'application CPS\n Appel direct possible...\n" );
}
}
else if (this->NumAppelant.CompareC(this->CodePays,3,NULL)!=0)
{
//appel international
iroutage = 1;
return iroutage;
}
return iroutage;
}
Forum posts: 114
just used Left() and = instead of strcmp.
thanks