reSIProcate/stack  9694
Classes | Defines | Typedefs | Functions | Variables
limpc.cxx File Reference
#include <cstring>
#include <cassert>
#include <stdio.h>
#include <signal.h>
#include <iostream>
#include <cstdio>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <stdlib.h>
#include "rutil/FdPoll.hxx"
#include "rutil/Socket.hxx"
#include "rutil/Logger.hxx"
#include "resip/stack/SipStack.hxx"
#include "resip/stack/Uri.hxx"
#include "resip/stack/TuIM.hxx"
Include dependency graph for limpc.cxx:

Go to the source code of this file.

Classes

class  StdInWatcher
class  TestCallback

Defines

#define TRUE   true
#define FALSE   false
#define RESIPROCATE_SUBSYSTEM   Subsystem::SIP

Typedefs

typedef void WINDOW

Functions

WINDOWnewwin (...)
void waddstr (WINDOW *, const char *text)
char getch ()
void werase (WINDOW *)
void wrefresh (...)
void mvhline (...)
void refresh (...)
void getmaxyx (...)
void clearok (...)
void waddch (...)
void initscr (...)
void cbreak (...)
void noecho (...)
void nonl (...)
void intrflush (...)
void keypad (...)
void scrollok (...)
void wmove (...)
void mvvline (...)
static int myMain (int argc, char *argv[])
void displayPres ()
bool processStdin (Uri *dest, bool sign, bool encryp)
int main (int argc, char *argv[])

Variables

char ACS_HLINE = 1
char ACS_VLINE = 2
WINDOWstdscr = 0
static WINDOWcommandWin = 0
static WINDOWtextWin = 0
static WINDOWstatusWin = 0
static TuIMtuIM
static Uri dest

Define Documentation

#define FALSE   false

Definition at line 29 of file limpc.cxx.

Referenced by myMain().

#define RESIPROCATE_SUBSYSTEM   Subsystem::SIP

Definition at line 91 of file limpc.cxx.

#define TRUE   true

Definition at line 26 of file limpc.cxx.

Referenced by myMain(), and processStdin().


Typedef Documentation

typedef void WINDOW

Definition at line 23 of file limpc.cxx.


Function Documentation

void cbreak (   ...)

Definition at line 56 of file limpc.cxx.

Referenced by myMain().

{};
void clearok (   ...)

Definition at line 53 of file limpc.cxx.

Referenced by processStdin().

{};
void displayPres ( )

Definition at line 101 of file limpc.cxx.

References resip::Data::c_str(), resip::Uri::getAor(), resip::TuIM::getBuddyStatus(), resip::TuIM::getBuddyUri(), resip::TuIM::getNumBuddies(), statusWin, tuIM, waddstr(), werase(), and wrefresh().

Referenced by myMain(), TestCallback::presenceUpdate(), and processStdin().

{
   werase(statusWin);

   for( int i=0; i<tuIM->getNumBuddies();i++)
   {
      Uri uri = tuIM->getBuddyUri(i);
      Data status;
      bool online = tuIM->getBuddyStatus(i,&status);
      const char* stat = (online)?"online":"offline";
         
      waddstr(statusWin,uri.getAor().c_str());
      waddstr(statusWin," ");
      waddstr(statusWin,stat);
      waddstr(statusWin," ");
      waddstr(statusWin,status.c_str());
      waddstr(statusWin,"\n");
   }

   wrefresh(statusWin);  
}

Here is the call graph for this function:

char getch ( )

Definition at line 37 of file limpc.cxx.

Referenced by processStdin().

{
   char buf[1];
   int r = read(fileno(stdin),&buf,1);
   if ( r ==1 )
   {
      return buf[0];
   }
   return 0;
};
void getmaxyx (   ...)

Definition at line 52 of file limpc.cxx.

Referenced by myMain().

{};
void initscr (   ...)

Definition at line 55 of file limpc.cxx.

Referenced by myMain().

{};
void intrflush (   ...)

Definition at line 59 of file limpc.cxx.

Referenced by myMain().

{};
void keypad (   ...)

Definition at line 60 of file limpc.cxx.

Referenced by myMain().

{};
int main ( int  argc,
char *  argv[] 
)

Definition at line 471 of file limpc.cxx.

References ErrLog, and myMain().

{
#ifndef _WIN32
   if ( signal( SIGPIPE, SIG_IGN) == SIG_ERR)
   {
      cerr << "Couldn't install signal handler for SIGPIPE" << endl;
      exit(-1);
   }
#endif

   int r;
   
   try
   {
      r = myMain( argc, argv );
   }
   catch( ... )
   {
      ErrLog( << "Got a exception passed all the way to the top of limp" );
      exit(-1);
   }
   
   return r;
}

Here is the call graph for this function:

void mvhline (   ...)

Definition at line 50 of file limpc.cxx.

Referenced by myMain().

{};
void mvvline (   ...)

Definition at line 63 of file limpc.cxx.

Referenced by myMain().

{};
static int myMain ( int  argc,
char *  argv[] 
) [static]

Definition at line 498 of file limpc.cxx.

References ACS_HLINE, ACS_VLINE, resip::TuIM::addBuddy(), resip::FdPollGrp::addPollItem(), resip::TuIM::addStateAgent(), resip::SipStack::addTransport(), cbreak(), resip::Log::Cerr, commandWin, DebugLog, resip::FdPollGrp::delPollItem(), dest, displayPres(), resip::DTLS, resip::Data::Empty, resip::Data::empty(), resip::Log::Err, ErrLog, FALSE, FPEM_Read, resip::BaseSecurity::generateUserCert(), resip::Uri::getAor(), resip::Uri::getAorNoPort(), resip::SipStack::getHostname(), getmaxyx(), resip::SipStack::getPollGrp(), resip::SipStack::getSecurity(), resip::Uri::host(), resip::Log::Info, InfoLog, resip::Log::initialize(), initscr(), intrflush(), StdInWatcher::keepGoing(), keypad(), mvhline(), mvvline(), newwin(), noecho(), nonl(), resip::Uri::port(), resip::Security::preload(), resip::TuIM::process(), resip::SipStack::process(), refresh(), resip::TuIM::registerAor(), resip::Uri::scheme(), scrollok(), resip::TuIM::sendPage(), resip::TuIM::setDefaultProtocol(), resip::Log::setLevel(), resip::TuIM::setOutboundProxy(), resip::TuIM::setUAName(), resip::Log::Stack, statusWin, stdscr, resip::StunDisabled, resip::TCP, textWin, resip::TLS, TRUE, tuIM, resip::UDP, resip::Uri::user(), resip::V4, resip::V6, waddstr(), resip::Log::Warning, wmove(), and wrefresh().

Referenced by main().

{  
   Log::initialize(Log::Cerr, Log::Err, argv[0]);
   Log::setLevel(Log::Warning);

   InfoLog(<<"Test Driver for IM Starting");
    
   int port = 5060;
   int tlsPort = 0;
   int dtlsPort = 0;
   Uri aor;
   bool haveAor=false;
   dest = Uri("sip:nobody@example.com");
   Data aorPassword;
   Uri contact("sip:user@");
   bool haveContact=false;
   Uri outbound;
   bool noRegister = false;
   Data tlsDomain = Data::Empty;

   Data sendMsg = Data::Empty;
   
   int numAdd=0;
   Data addList[100];
   int numPub=0;
   Data pubList[100];
   bool encryp=false;
   bool sign=false;
   Data key("password");
   bool useTls = true;
   bool noTls = false;
   bool noTcp = false;
   bool prefUdp = false;
   bool prefTls = false;
   bool prefDtls = false;
   bool prefTcp = false;
   bool noUdp = false;
   bool noV6 = false;
   bool noV4 = false;
   bool genUserCert = false;
   
   for ( int i=1; i<argc; i++)
   {
      if (!strcmp(argv[i],"-vv"))
      {
         Log::setLevel(Log::Stack);
      }
      else if (!strcmp(argv[i],"-v"))
      {
         Log::setLevel(Log::Info);
      }
      else if (!strcmp(argv[i],"-encrypt"))
      {
         encryp = true;
      }
      else if (!strcmp(argv[i],"-genUserCert"))
      {
         genUserCert = true;
      }
      else if (!strcmp(argv[i],"-noRegister"))
      {
         noRegister = true;
      }
      else if (!strcmp(argv[i],"-sign"))
      {
         sign = true;
      }
      else if (!strcmp(argv[i],"-tlsDomain"))
      {
         i++;
         assert( i<argc );
         tlsDomain = Data(argv[i]);
      }
      else if (!strcmp(argv[i],"-ssl"))
      {
         useTls = false;
      }
      else if (!strcmp(argv[i],"-noTcp"))
      {
         noTcp = true;
      }
      else if (!strcmp(argv[i],"-noTls"))
      {
         noTls = true;
      }
      else if (!strcmp(argv[i],"-noUdp"))
      {
         noUdp = true;
      }
      else if (!strcmp(argv[i],"-prefTcp"))
      {
         prefTcp = true;
      }
      else if (!strcmp(argv[i],"-prefTls"))
      {
         prefTls = true;
      }
      else if (!strcmp(argv[i],"-prefUdp"))
      {
         prefUdp = true;
      }
      else if (!strcmp(argv[i],"-noV6"))
      {
         noV6 = true;
      }
      else if (!strcmp(argv[i],"-noV4"))
      {
         noV4 = true;
      }
      else if (!strcmp(argv[i],"-port"))
      {
         i++;
         assert( i<argc );
         port = atoi( argv[i] );
      } 
      else if (!strcmp(argv[i],"-tlsPort"))
      {
         i++;
         assert( i<argc );
         tlsPort = atoi( argv[i] );
      }
      else if (!strcmp(argv[i],"-dtlsPort"))
      {
         i++;
         assert( i<argc );
         dtlsPort = atoi( argv[i] );
      }
      else if (!strcmp(argv[i],"-aor"))
      {
         i++;
         assert( i<argc );
         try
         {
            aor = Uri(Data(argv[i]));
         }
         catch (...)
         {
            ErrLog( <<"AOR URI is not valid - must start with sip: ");
            exit(-1);
         }
         haveAor=true;
      } 
      else if (!strcmp(argv[i],"-outbound"))
      {
         i++;
         assert( i<argc );
         try
         {
            outbound = Uri(Data(argv[i]));
         }
         catch (...)
         {
            ErrLog( <<"Outbound URI is not valid - must start with sip: ");
            exit(-1);
         }
      } 
      else if (!strcmp(argv[i],"-send"))
      {
         i++;
         assert( i<argc );
         sendMsg = Data(argv[i]);
      } 
      else if (!strcmp(argv[i],"-contact"))
      {
         i++;
         assert( i<argc );
         try
         {
            contact = Uri(Data(argv[i]));
         }
         catch (...)
         {
            ErrLog( <<"Contact URI is not valid - must start with sip: ");
            exit(-1);
         }
         haveContact=true;
      } 
      else if (!strcmp(argv[i],"-add"))
      {
         i++;
         assert( i<argc );
         addList[numAdd++] = Data(argv[i]);
         assert( numAdd < 100 ); 
         try
         {
            // CJ TODO FIX 
            //Uri uri( Data(argv[i]) );
         }
         catch (...)
         {
            ErrLog( <<"URI in -add is not valid - must start with sip: ");
            exit(-1);
         }
      } 
      else if (!strcmp(argv[i],"-pub"))
      {
         i++;
         assert( i<argc );
         pubList[numPub++] = Data(argv[i]);
         assert( numPub < 100 ); 
         try
         {
            // CJ TODO FIX 
            //Uri uri(Data(argv[i]));
         }
         catch (...)
         {
            ErrLog( <<"Pub URI is not valid - must start with sip: ");
            exit(-1);
         }
      } 
      else if (!strcmp(argv[i],"-aorPassword"))
      {
         i++;
         assert( i<argc );
         aorPassword = Data(argv[i]);
      } 
      else if (!strcmp(argv[i],"-to"))
      {
         i++;
         assert( i<argc );
         try
         {
            dest = Uri(Data(argv[i])); 
         }
         catch (...)
         {
            ErrLog( <<"To URI is not valid - must start with sip: ");
            exit(-1);
         }
      } 
      else if (!strcmp(argv[i],"-key"))
      {
         i++;
         assert( i<argc );
         key = Data(argv[i]);
      } 
      else
      { 
         clog <<"Bad command line opion: " << argv[i] << endl;
         clog <<"options are: " << endl
              << "\t [-v] [-vv] [-tls] [-port 5060] [-tlsport 5061]" << endl
              << "\t [-aor sip:alice@example.com] [-aorPassword password]" << endl
              << "\t [-to sip:friend@example.com] [-add sip:buddy@example.com]" << endl
              << "\t [-sign] [-encrypt] [-key secret]" << endl
              << "\t [-contact sip:me@example.com] " << endl
              << "\t [-outbound \"sip:example.com;lr\"] " << endl
              << "\t [-noRegister] " << endl
              << "\t [-pub sip:foo.com] " << endl
              << "\t [-tlsDomain foo.com] " << endl
              << "\t [-send myMessage] " << endl; 
         clog << endl
              << " -v is verbose" << endl
              << " -vv is very verbose" << endl
              << " -noV6 don't use IPv6" << endl
              << " -noV4 don't use IPv4" << endl
              << " -noUdp don't use UDP" << endl
              << " -noTcp don't use TCP" << endl
              << " -noTls don't use TLS" << endl
              << " -prefUdp prefer UDP" << endl
              << " -prefTcp prefer TCP" << endl
              << " -prefTls prefer TLS" << endl
              << " -port sets the UDP and TCP port to listen on" << endl
              << " -tlsPort sets the port to listen for TLS on" << endl
              << " -tlsDomain domainName - sets tls and dtls to act as tls server instead of client" << endl
              << " -ssl - use ssl instead of tls" << endl
              << " -aor sets the proxy and user name to register with" << endl
              << " -aorPassword sets the password to use for registration" << endl
              << " -noRegister causes it not to register - by default the AOR is registered" << endl
              << " -to sets initial location to send messages to" << endl
              << " -outbound sets the outbound proxy" << endl
              << " -add adds a budy who's presence will be monitored" << endl
              << " -pub adds a State Agent to send publishes too" << endl
              << " -sign signs message you send and -encryp encrypt them " << endl
              << " -send takes a string (needs to be quoted if it has spaces) " 
              <<                                      "and sends it as an IM " << endl
              << "\t(You need PKI certs for this to work)" << endl
              << " -key allows you to enter a secret used to load your private key."<< endl
              << "  If you set the secret to - the system will querry you for it."<< endl
              << " -contact overrides your SIP contact - can be used for NAT games" << endl
              << "\t there can be many -add " << endl
              << " -genUserCert - generate a new user cert" << endl
              << " " << endl
              << "Examples" << endl
              << "An example command line for a user with account name alice at example.com is:" << endl
              << "\t" << argv[0] << " -aor \"alice@example.com\" -aorPassword \"secret\"" << endl
              << "to watch the presence of bob and charlie add" << endl
              << "\t-add \"sip:bob@bilboxi.com\" -add \"charlie@example.com\" " << endl
              << "If Alice was behind a NAT that had a public address of 1.2.3.4 and had forwarded" << endl
              << "port 5070 on this NAT to the machine Alice was using, then the following " << endl
              << "options would be added" << endl
              << "\t-contact \"sip:alice@1.2.3.4:5070\" -port 5070" << endl
              << "" << endl
              << endl;
         exit(1);
      }
   }
   
   //InfoLog( << "Using port " << port );
  
#ifdef USE_SSL
   InfoLog( << "Setting up Security" );
   Security* security=NULL;
   try
   {
      char cert_dir[ 1024 ] ;
      char *home_dir = getenv( "HOME" ) ;

      cert_dir[ 0 ] = '\0' ;
      ::strcat( cert_dir, home_dir ) ;
      ::strcat( cert_dir, "/.sipCerts/" ) ;

      security = new Security( cert_dir ) ;

      //  ::free( home_dir ) ; // CJ TODO mem leak 
   }
   catch( ... )
   {
      security = NULL;
      ErrLog( << "Got a exception setting up Security" );
   }

   SipStack sipStack( security );  
#else
   SipStack sipStack( false /*multihtread*/ );  
#endif

   if ( key == Data("-") )
   {
      clog << "Please enter password to use to load your private key: ";
      char buf[1024];
      cin.get(buf,1024);
      key = Data(buf);
      InfoLog( << "Certificate key set to <" << key << ">" );
   }
   
#ifdef USE_SSL
   try
   {
      Security* security = sipStack.getSecurity();
      assert(security != 0);
   }
   catch( ... )
   {
      ErrLog( << "Got an exception creating security object " );
   }

   try
   {
      assert(security != 0);
      security->preload();
   }
   catch( ... )
   {
      ErrLog( << "Got a exception pre loading certificates" );
   }


   if (genUserCert)
   {
      assert( security );
      security->generateUserCert(aor.getAor());
   }
#endif

   DebugLog( << "About to add the transports " );   
   if (port!=0)
   {
      if ( noUdp != true )
      {
         if (!noV4) sipStack.addTransport(UDP, port, V4);
#ifdef USE_IPV6
         if (!noV6) sipStack.addTransport(UDP, port, V6);
#endif
      }
      if ( noTcp != true )
      {
         if (!noV4) sipStack.addTransport(TCP, port, V4);
#ifdef USE_IPV6
         if (!noV6) sipStack.addTransport(TCP, port, V6);
#endif
      }
   }
#ifdef USE_SSL
   if ( tlsPort != 0 )
   {
      if ( noTls != true )
      {
         if (!noV4) 
         {
            sipStack.addTransport(TLS, tlsPort, V4, StunDisabled, Data::Empty, tlsDomain );
         }
         //if (!noV6) sipStack.addTlsTransport(tlsPort,Data::Empty,Data::Empty,Data::Empty,V6);
      }
   }
#ifdef USE_DTLS
   if ( dtlsPort != 0 )
   {
      if ( noTls != true )
      {
         if (!noV4) 
         {
            sipStack.addTransport(DTLS, dtlsPort, V4, StunDisabled, Data::Empty, tlsDomain );
         }
      }
   }
#endif
#endif

   DebugLog( << "Done adding the transports " );   

   if (!haveContact)
   {
      // contact.port() = port;
      // contact.host() = sipStack.getHostname();
   }
   
   if ( haveAor )
   {
      if (!haveContact)
      {
         contact.user() = aor.user();
#ifdef USE_SSL
         if ( aor.scheme() == "sips" )
         {
            contact.scheme() = aor.scheme();
            //contact.port() = tlsPort;
         }
#endif
      }
   }
   else
   {
      aor.port() = port;
      aor.host() = sipStack.getHostname();
      aor.user() = Data("user");
   }

   InfoLog( << "aor is " << aor );
   InfoLog( << "contact is " << contact );
   TestCallback callback;
   tuIM = new TuIM(&sipStack,aor,contact,&callback);

   Data name("SIPimp.org/0.2.5 (curses)");
   tuIM->setUAName( name );
      
   if ( !outbound.host().empty() )
   {
      tuIM->setOutboundProxy( outbound );
   }

   // setup prefered outbound transport 
   if ( prefUdp )
   {
      tuIM->setDefaultProtocol( UDP );
   }
   if ( prefTcp )
   {
      tuIM->setDefaultProtocol( TCP );
   }
   if ( prefTls )
   {
      tuIM->setDefaultProtocol( TLS );
   }
   if ( prefDtls )
   {
      tuIM->setDefaultProtocol( DTLS );
   }

   if ( haveAor )
   {
      if ( !noRegister )
      {
         tuIM->registerAor( aor, aorPassword );
      }
   }
   
   initscr(); 
   cbreak(); 
   noecho();
   nonl();
   intrflush(stdscr, FALSE);
   keypad(stdscr, TRUE);

   int rows=0;
   int cols=0;
   getmaxyx(stdscr,rows,cols);          /* get the number of rows and columns */
        
   commandWin = newwin(2,cols,rows-2,0);
   scrollok(commandWin, TRUE);
   wmove(commandWin,0,0);
     
   textWin = newwin(rows-3,cols*3/4,0,0);
   scrollok(textWin, TRUE);
   wmove(textWin,0,0);
     
   statusWin = newwin(rows-3,cols-(cols*3/4)-1,0,1+cols*3/4);
   scrollok(statusWin, FALSE);
   wmove(statusWin,0,0);

   mvhline(rows-3,0,ACS_HLINE,cols);
   mvvline(0,(cols*3/4),ACS_VLINE,rows-3);
   refresh();

   for ( int i=0; i<numAdd; i++ )
   { 
      Uri uri(addList[i]);
      tuIM->addBuddy( uri, Data::Empty );
   }

   for ( int i=0; i<numPub; i++ )
   { 
      Uri uri(pubList[i]);
      tuIM->addStateAgent( uri );
   }

   displayPres();
 
   waddstr(textWin,"Use -help on the command line to view options\n");
   waddstr(textWin,"To set where your messages will get sent type\n");
   waddstr(textWin,"    to: sip:alice@example.com \n");
   waddstr(textWin,"To monitores someeone presence type\n");
   waddstr(textWin,"    add: sip:buddy@example.com \n");
   waddstr(textWin,"To change you online status type\n");
   waddstr(textWin,"    status: in meeting\n");
   waddstr(textWin,"To set yourself to offline type\n");
   waddstr(textWin,"   status:\n");
   waddstr(textWin,"To exit type a single period\n");
   waddstr(textWin,"\n");
   wrefresh(textWin);     

   if ( !sendMsg.empty() )
   {
         tuIM->sendPage( sendMsg , dest, sign , (encryp) ?
                         (dest.getAorNoPort()) : (Data::Empty) );
   }

   StdInWatcher watcher(&dest,sign,encryp);
   FdPollItemHandle wh=sipStack.getPollGrp()->addPollItem(fileno(stdin), FPEM_Read, &watcher);

   while (1)
   {
      try
      {
         sipStack.process( 50 );
      }
      catch (...)
      {
         ErrLog( << "Got a exception from sipStack::process" );
      }

      if(!watcher.keepGoing())
      {
         break;
      }

      try
      {
         tuIM->process();
      }
      catch (...)
      {
         ErrLog( << "Got a exception passed from TuIM::process" );
      }
   }

   sipStack.getPollGrp()->delPollItem(wh);

   return 0;
}

Here is the call graph for this function:

WINDOW* newwin (   ...)

Definition at line 35 of file limpc.cxx.

Referenced by myMain().

{ return NULL; };
void noecho (   ...)

Definition at line 57 of file limpc.cxx.

Referenced by myMain().

{};
void nonl (   ...)

Definition at line 58 of file limpc.cxx.

Referenced by myMain().

{};
bool processStdin ( Uri dest,
bool  sign,
bool  encryp 
)

Definition at line 124 of file limpc.cxx.

References resip::TuIM::addBuddy(), resip::Data::c_str(), clearok(), commandWin, DebugLog, displayPres(), resip::Data::empty(), resip::Data::Empty, resip::Data::from(), resip::Uri::getAor(), resip::Uri::getAorNoPort(), getch(), resip::TuIM::haveCerts(), resip::TuIM::sendPage(), resip::TuIM::setMyPresence(), statusWin, textWin, TRUE, tuIM, waddch(), waddstr(), werase(), and wrefresh().

Referenced by StdInWatcher::processPollEvent().

{
   static unsigned int num=0;
   static char buf[1024];

   char c = getch();    
      
   if ( c == 0 )
   {
      return true;
   }
   
   if ( c == '\f' )
   {
      clearok(textWin,TRUE);
      clearok(statusWin,TRUE);
      clearok(commandWin,TRUE);

      assert( num < sizeof(buf) );
      buf[num] = 0;
      werase(commandWin);
      waddstr(commandWin,buf);

      wrefresh(textWin);
      wrefresh(statusWin);
      wrefresh(commandWin);

      return true;
   }

#if 0
   char junk[6];
   junk[0]=' ';
   junk[1]='0'+(c/100);
   junk[2]='0'+((c/10)%10);
   junk[3]='0'+(c%10);
   junk[4]=' ';
   junk[5]=0;
   waddstr(commandWin,junk);
#endif

   if (  (c == '\a') || (c == '\b') || (c == 4 ) || (c == 0x7F) )
   {
      if ( num > 0 )
      {
         num--;
      }
      buf[num]=0;

      werase(commandWin);
      waddstr(commandWin,buf);
      wrefresh(commandWin);
      
      return true;
   }
       
   if ( (c == '\r') || (c == '\n') || (num+2>=sizeof(buf)) )
   {
      buf[num] =0;

      if ( (num>3) && (!strncmp("to:",buf,3)) )
      {
         buf[num] = 0;
         *dest = Uri(Data(buf+3));
       
         //cerr << "Set destination to <" << *dest << ">";
         waddstr(textWin,"Set destination to ");
         waddstr(textWin, Data::from(*dest).c_str());
         waddstr(textWin,"\n");
         wrefresh(textWin);
      }
      else if ( (num>4) && (!strncmp("add:",buf,4)) )
      {
         buf[num] = 0;
         Uri uri(Data(buf+4));

         //cerr << "Subscribing to buddy <" << uri << ">";
         waddstr(textWin, "Subscribing to ");
         waddstr(textWin, Data::from(uri).c_str());
         waddstr(textWin, "\n");
         wrefresh(textWin);
         
         tuIM->addBuddy( uri, Data::Empty );
         displayPres();
      }
      else if ( (num>=7) && (!strncmp("status:",buf,7)) )
      {
         buf[num] = 0;
         Data stat(buf+7);

         //cerr << "setting presence status to  <" << stat << ">";
         waddstr(textWin,"Set presece status to <");
         waddstr(textWin,stat.c_str());
         waddstr(textWin,">\n");
         wrefresh(textWin);

         tuIM->setMyPresence( !stat.empty(), stat );
      }
      else if ( (num==1) && (!strncmp(".",buf,1)) )
      {
         //DebugLog( << "Got a period - end program" );
         return false;
      }
      else
      { 
         if ( num >= 1 )
         {
            assert( num < sizeof(buf) );
            buf[num] = 0;
            Data text(buf);
            
            Data destValue  = dest->getAor();
            
            DebugLog( << "Destination is " << destValue );

            Data encFor = Data::Empty;
            if (encryp)
            { 
               encFor = dest->getAorNoPort();
            }

            DebugLog( << "Destination encrypt for is " << encFor );

            if ( tuIM->haveCerts(sign,encFor) )
            {
               waddstr(textWin,"To: ");
               waddstr(textWin,destValue.c_str());
               waddstr(textWin," ");
               waddstr(textWin,text.c_str());
               waddstr(textWin,"\n");
               wrefresh(textWin);
               
               tuIM->sendPage( text , *dest, sign , encFor );
            }
            else
            {
               waddstr(textWin,"Don't have aproperate certificates to sign and encrypt a message to ");
               waddstr(textWin,destValue.c_str());
               waddstr(textWin,"\n");
               wrefresh(textWin);
            }
         }
      }

      num = 0;  

      werase(commandWin);
      wrefresh(commandWin);
   }
   else
   {
      buf[num++] = c;
      assert( num < sizeof(buf) );
      
      waddch(commandWin,c);
      wrefresh(commandWin);
   }

   return true;
}

Here is the call graph for this function:

void refresh (   ...)

Definition at line 51 of file limpc.cxx.

Referenced by myMain().

{};
void scrollok (   ...)

Definition at line 61 of file limpc.cxx.

Referenced by myMain().

{};
void waddch (   ...)

Definition at line 54 of file limpc.cxx.

Referenced by processStdin().

{};
void waddstr ( WINDOW ,
const char *  text 
)
void werase ( WINDOW )

Definition at line 48 of file limpc.cxx.

Referenced by displayPres(), and processStdin().

{};
void wmove (   ...)

Definition at line 62 of file limpc.cxx.

Referenced by myMain().

{};
void wrefresh (   ...)

Variable Documentation

char ACS_HLINE = 1

Definition at line 32 of file limpc.cxx.

Referenced by myMain().

char ACS_VLINE = 2

Definition at line 33 of file limpc.cxx.

Referenced by myMain().

WINDOW* commandWin = 0 [static]

Definition at line 93 of file limpc.cxx.

Referenced by myMain(), and processStdin().

Uri dest [static]
WINDOW* statusWin = 0 [static]

Definition at line 95 of file limpc.cxx.

Referenced by displayPres(), myMain(), and processStdin().

WINDOW* stdscr = 0

Definition at line 34 of file limpc.cxx.

Referenced by myMain().

WINDOW* textWin = 0 [static]
TuIM* tuIM [static]

Definition at line 97 of file limpc.cxx.

Referenced by displayPres(), myMain(), and processStdin().