⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form.cpp

📁 此源码包是在linux系统中运行的网络电话界面程序。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************** Form implementation generated from reading ui file 'form.ui'**** Created: Sun Nov 26 20:31:46 2006**      by:  The User Interface Compiler (uic)**** WARNING! All changes made in this file will be lost!****************************************************************************/#include "form.h"#include "server.h"#include <qlabel.h>#include <qlineedit.h>#include <qpushbutton.h>#include <qlayout.h>#include <qvariant.h>#include <qtooltip.h>#include <qwhatsthis.h>#include <qapplication.h>#include <qsize.h>#include <qprocess.h>#include <qdir.h>#include <qfile.h>#include <qtextview.h>#include <stdlib.h>#include <unistd.h>#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <string.h>#include <errno.h>#include <signal.h>#include <qmessagebox.h>#include <qpixmap.h>#include <qiconset.h>#include <qmenubar.h>#include <qfile.h>struct flock lock;#define FIFO "/home/yhy/fifots"#define ALARM "/home/yhy/alarm"#define SERVER "/home/yhy/server.txt"#define LIST "/home/yhy/list.txt"//#define HELP "/home/yhy/help.txt"  //leo1205int fd;//FIFO #define LINE_MAX_LEN 256#include "okcontrol.h"#include "proxy.h"//FILE *fp;   //stdout->fp//union sigval mysigval;//int childpid;//FILE *fbuf; //tmp->fbuf,read fbuf to buf[]//char buf[1000];//QString qstr;/*  *  Constructs a Form which is a child of 'parent', with the  *  name 'name' and widget flags set to 'f'  *///Form::Form( QWidget* parent,  const char* name, WFlags fl )   // : QWidget( parent, name, fl )Form::Form():QMainWindow(){    QSize size(300,310);      // if ( !name )//	setName( "Form" );    setMaximumSize( size );     setCaption(QString::fromLocal8Bit("网络电话") );      file=new QPopupMenu(this);   // file->insertItem(QString::fromLocal8Bit("服务器"),this,SLOT(reg()));    file->insertItem(QString::fromLocal8Bit("退出"),this,SLOT(send_terminate()));       serv=new QPopupMenu(this);    serv->insertItem(QString::fromLocal8Bit("注册"),this,SLOT(proxy_add()));    serv->insertItem(QString::fromLocal8Bit("移除"),this,SLOT(proxy_remove()));    serv->insertItem(QString::fromLocal8Bit("列表"),this,SLOT(proxy_list()));    helpbar=new QPopupMenu(this);    helpbar->insertItem(QString::fromLocal8Bit("说明"),this,SLOT(help()));        menuBar=new QMenuBar(this);    menuBar->insertItem(QString::fromLocal8Bit("文件"),file);    menuBar->insertItem(QString::fromLocal8Bit("服务器"),serv);    menuBar->insertItem(QString::fromLocal8Bit("帮助"),helpbar);    mainlayout=new QGridLayout(this,8,3,10);            LEdit = new QLineEdit( this, "LEdit" );    //LEdit->setGeometry( QRect( 10, 30, 220, 40 ) );     mainlayout->addMultiCellWidget(LEdit,1,1,0,1);      /*  RegisterButton = new QPushButton( this, "RegisterButton" );    RegisterButton->setGeometry( QRect( 90, 100, 60, 30 ) );     RegisterButton->setText(QString::fromLocal8Bit("服务器") );    mainlayout->addMultiWidgetCell(RegisterButton,1,1,0,0);       QuitButton = new QPushButton( this, "QuitButton" );    QuitButton->setGeometry( QRect( 170, 100, 60, 30 ) );     QuitButton->setText(QString::fromLocal8Bit("退出"));*/    TextLabel = new QLabel( this, "TextLabel" );   // TextLabel->setGeometry( QRect( 10, 250, 220, 50 ) );  //add by leo    QPalette pal;    QColorGroup cg;    pal.setActive( cg );    cg.setColor( QColorGroup::Background, QColor( 170, 255, 255) );     pal.setActive( cg );    TextLabel->setPalette( pal );    TextLabel->setText( tr( "" ) );    mainlayout->addMultiCellWidget(TextLabel,2,2,0,2);    backspacebutton=new QPushButton(this,"backspcae");    backspacebutton->setText("<-");    backspacebutton->setAutoRepeat(TRUE);    mainlayout->addMultiCellWidget(backspacebutton,1,1,2,2);     QPixmap *callpixmap=new QPixmap("call.png");    QIconSet *callIcon=new QIconSet(*callpixmap);   // callItem=new QIconViewItem(this,NULL,callpixmap);    CallAnswerButton = new QPushButton(*callIcon,NULL,this, "CallButton" );    mainlayout->addMultiCellWidget(CallAnswerButton,3,3,0,0);   /* CallButton = new QPushButton( this, "CallButton" );    CallButton->setGeometry( QRect( 10, 100, 60, 30 ) );     CallButton->setText(QString::fromLocal8Bit("呼叫"));    TermButton = new QPushButton( this, "TermButton" );    TermButton->setGeometry( QRect( 10, 150, 60, 30 ) );    TermButton->setText(QString::fromLocal8Bit("挂断"));*/      //  AnswerButton = new QPushButton( this, "AnswerButton" );   //   AnswerButton->setText(QString::fromLocal8Bit("接听"));   // mainlayout->addMultiCellWidget(AnswerButton,3,3,2,2);       QPixmap *guaduanpixmap=new QPixmap("guaduan.png");   // guaduanItem=new QIconViewItem(this,NULL,guaduanpixmap);    QIconSet *guaduanIcon=new QIconSet(*guaduanpixmap);    TermButton=new QPushButton(*guaduanIcon,NULL,this,"TermButton");    mainlayout->addMultiCellWidget(TermButton,3,3,2,2);    button1=new QPushButton(this,"button1");    button1->setText("1");    button1->setAutoRepeat(TRUE);    mainlayout->addMultiCellWidget(button1,4,4,0,0);    button2=new QPushButton(this,"button2");    button2->setText("2");    button2->setAutoRepeat(TRUE);    mainlayout->addMultiCellWidget(button2,4,4,1,1);      button3=new QPushButton(this,"button3");    button3->setText("3");    button3->setAutoRepeat(TRUE);    mainlayout->addMultiCellWidget(button3,4,4,2,2);    button4=new QPushButton(this,"button4");    button4->setText("4");    button4->setAutoRepeat(TRUE);    mainlayout->addMultiCellWidget(button4,5,5,0,0);    button5=new QPushButton(this,"button5");    button5->setText("5");    button5->setAutoRepeat(TRUE);    mainlayout->addMultiCellWidget(button5,5,5,1,1);    button6=new QPushButton(this,"button6");    button6->setText("6");    button6->setAutoRepeat(TRUE);    mainlayout->addMultiCellWidget(button6,5,5,2,2);    button7=new QPushButton(this,"button7");    button7->setText("7");    button7->setAutoRepeat(TRUE);    mainlayout->addMultiCellWidget(button7,6,6,0,0);    button8=new QPushButton(this,"button8");    button8->setText("8");    button8->setAutoRepeat(TRUE);    mainlayout->addMultiCellWidget(button8,6,6,1,1);      button9=new QPushButton(this,"button9");    button9->setText("9");    button9->setAutoRepeat(TRUE);    mainlayout->addMultiCellWidget(button9,6,6,2,2);    button10=new QPushButton(this,"button10");    button10->setText("*");    button10->setAutoRepeat(TRUE);    mainlayout->addMultiCellWidget(button10,7,7,0,0);    button0=new QPushButton(this,"button0");    button0->setText("0");    button0->setAutoRepeat(TRUE);    mainlayout->addMultiCellWidget(button0,7,7,1,1);    button11=new QPushButton(this,"button11");    button11->setText("#");    button11->setAutoRepeat(TRUE);    mainlayout->addMultiCellWidget(button11,7,7,2,2);    /*HelpButton = new QPushButton( this, "HelpButton" );    HelpButton->setGeometry( QRect( 170, 150, 60, 30) );    HelpButton->setText(QString::fromLocal8Bit("帮助"));*/    //add by leo    QString str = "./linphonec";    QDir workDir("/usr/qpe/bin");    proc = new QProcess(str);    proc->setCommunication(0);    proc->setWorkingDirectory(workDir);        connect(proc,SIGNAL(readyReadStdout()),this,SLOT(msgshow()));    if(proc->start())	{	  TextLabel->setText(QString::fromLocal8Bit("网络电话程序运行成功\n"));          printf("006\n");          char r_buf[150];          int cd,num;          printf("007\n");          if((cd=open(ALARM,O_RDONLY,0))<0)          {            perror("open alarm fifo error!");            exit(0);          }          else             {               memset(r_buf,0,sizeof(r_buf));               printf("008\n");               if((num=read(cd,r_buf,sizeof(r_buf)))<0)                 printf("read data from alarm\n ");               else if(num < 60)                    {                      printf("device is busy!\n");                      okcontrol *dialog = new okcontrol(0,"DSP");                      dialog->exec();                    }                    else                      printf("device is free!\n");      }	}    else	{	  printf("sssss3\n");	  TextLabel->setText(proc->readStderr());  //??	}     connect(backspacebutton,SIGNAL(clicked()),this,SLOT(backspace()));     connect(CallAnswerButton,SIGNAL(clicked()),this,SLOT(send_callanswer()));     connect(TermButton,SIGNAL(clicked()),this,SLOT(send_terminate()));     connect(button0,SIGNAL(clicked()),this,SLOT(button0slot()));     connect(button1,SIGNAL(clicked()),this,SLOT(button1slot()));      connect(button2,SIGNAL(clicked()),this,SLOT(button2slot()));     connect(button3,SIGNAL(clicked()),this,SLOT(button3slot()));     connect(button4,SIGNAL(clicked()),this,SLOT(button4slot()));     connect(button5,SIGNAL(clicked()),this,SLOT(button5slot()));     connect(button6,SIGNAL(clicked()),this,SLOT(button6slot()));     connect(button7,SIGNAL(clicked()),this,SLOT(button7slot()));     connect(button8,SIGNAL(clicked()),this,SLOT(button8slot()));     connect(button9,SIGNAL(clicked()),this,SLOT(button9slot()));     connect(button10,SIGNAL(clicked()),this,SLOT(button10slot()));     connect(button11,SIGNAL(clicked()),this,SLOT(button11slot()));     //connect(this,SIGNAL(Doubleclicked(QIconViewItem *)),this,SLOT(ItemDoubleclicked(QIconViewItem *)));    //   connect(CallButton,SIGNAL(clicked()),this,SLOT(send_call()));//    connect(CallButton,SIGNAL(clicked()),this,SLOT(alarm()));  //  connect(QuitButton,SIGNAL(clicked()),this,SLOT(send_quit()));  //  connect(TermButton,SIGNAL(clicked()),this,SLOT(send_terminate()));  //  connect(AnswerButton,SIGNAL(clicked()),this,SLOT(send_answer()));    // connect(AnswerButton,SIGNAL(clicked()),this,SLOT(alarm()));  //  connect(HelpButton,SIGNAL(clicked()),this,SLOT(help()));   // connect(RegisterButton,SIGNAL(clicked()),this,SLOT(reg())); //add by leo    printf("001\n");}/*   *  Destroys the object and frees any allocated resources */Form::~Form(){    // no need to delete child widgets, Qt does it all for us}/*void ItemDoubleClicked(QIconViewItem *Item){  if(Item==callItem)     send_call();  if(Item==guaduanItem)    send_terminate();}*/void Form::backspace(){  LEdit->backspace();}void Form::button0slot(){  LEdit->insert("0");}void Form::button1slot(){  LEdit->insert("1");}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -