Accueil > > > CALLERID/AFFICHEUR EN MODE CONSOLE ALA WINPOPUP
CALLERID/AFFICHEUR EN MODE CONSOLE ALA WINPOPUP
Information sur la source
Description
Projet perso pour afficher les appelants sur ma ligne telephonique. En mode console, C, sous linux (ubuntu) L'affichage ce fait a l'aide de linpopup(linux) ou Winpopup(windows) Une version Alpha, mal en point... Commentaires bienvenues
Source
- /*Auteur : Stephane Marchand
- *Date : 23 dec 2008
- *Loc.: Rouyn-Noranda, Quebec, Canada
- *Version Alpha000001, mode console
- *requis : un modem avec fonction callerid
- * GCC, Linpopup(linux) ou winpopup(windblows)
- *But : avoir la fonction d'affichage en modem graphique (X, win)
- *etat du code : mal en point
- *J'etais suppose utilise un toolkit GTK, mais j'ai laisser tomber...
- */
-
- #include <stdlib.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <string.h>
- #include <stdarg.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <termios.h>
-
- #define BAUDRATE B38400
- #define MODEMDEVICE "/dev/ttyS1"
- #define _POSIX_SOURCE 1 /* POSIX compliant source */
- #define FALSE 0
- #define TRUE 1
- #define MAX_FILE_LEN 256 // max length of file, dev, strbuf
-
- volatile int STOP=FALSE;
-
- void sendcmd(int fd, int timewait, char *fmt, ...);
- void mygtksend(char *gtkthemessage);
-
- char mystring[500];
- int thering=0;
- char buffermsg[501];
- char buffermsg2[501];
- char buf[255];
- int freakflag;
-
- int main(void)
- {
- int fd,res;
- struct termios oldtio,newtio;
-
- // you need your network to work with a win2000 (linux-windows)
- // win2k is my target machine along with a linux station
- // but... smbclient need to be install along with linpopup so
- // from linux station you can send/receive mesg.
- // My test were with several ubuntu station with a win2k pc
- // Every comments below here are for debugging
- // THIS code is from a learner and from the internet.
-
-
- // strcat(buffermsg,"/home/titou/Documents/dev_Steph/gnomecallerid/calleridmain ");
-
- fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY );
- if (fd <0) {perror(MODEMDEVICE); exit(1); }
-
- tcgetattr(fd,&oldtio); /* save current port settings */
-
- bzero(&newtio, sizeof(newtio));
- newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;
- newtio.c_iflag = IGNPAR;
- newtio.c_oflag = 0;
-
- /* set input mode (non-canonical, no echo,...) */
- newtio.c_lflag = 0;
-
- newtio.c_cc[VTIME] = 0; /* inter-character timer unused */
- newtio.c_cc[VMIN] = 5; /* blocking read until 5 chars received */
-
- tcflush(fd, TCIFLUSH);
- tcsetattr(fd,TCSANOW,&newtio);
-
- sendcmd(fd, 3, "+++\r");
- sendcmd(fd, 3, "ath\r");
- sendcmd(fd, 3, "at#CID=1\r");
-
- while (STOP==FALSE) { /* loop for input */
- res = read(fd,buf,255); /* returns after 5 chars have been input */
- buf[res]=0; /* so we can printf... */
- /*printf(":%s:%d", buf, res);*/
- //printf("%s", buf);
- if(freakflag==1){
- buf[0]='\0';
- printf("freakflag to 1");
- }
-
- mygtksend(buf);
-
- if (buf[0]=='z') STOP=TRUE;
- }
- tcsetattr(fd,TCSANOW,&oldtio);
- return 0;
- }
- void sendcmd(int fd, int timewait, char *fmt, ...)
- {
- char strbuf[MAX_FILE_LEN];
- va_list ap;
-
- bzero(strbuf, sizeof(strbuf));
-
- // flush i/o
- tcflush(fd, TCIOFLUSH);
-
- // send the command
- va_start(ap, fmt);
- vsnprintf(strbuf, sizeof(strbuf) - 1, fmt, ap);
- write(fd, strbuf, strlen(strbuf));
- va_end(ap);
-
- //wait for whatever char has been transmitted
- tcdrain(fd);
- sleep(timewait);
-
- return;
- }
- void mygtksend(char *gtkthemessage){
- //sending message to 2 stations
- //so 2 buffers
- if(strstr(gtkthemessage,"RING")!=NULL) thering++;
- if(thering==2){
- thering=0;
- // send message to gtk prog.
- strcat(buffermsg,"echo \"GNOMECALLERID\n\r");
- strcat(buffermsg2,"echo \"GNOMECALLERID\n\r");
- strcat(buffermsg, mystring);
- strcat(buffermsg2, mystring);
- strcat(buffermsg,"\" | smbclient -M drebi");
- strcat(buffermsg2,"\" | smbclient -M voyager");
- //printf("%s", buffermsg);
- system(buffermsg);
- system(buffermsg2);
-
- buffermsg[0]='\0';
- buffermsg2[0]='\0';
- mystring[0]='\0';
- // freaking put the buffer to 0 character !!!
- freakflag=1;
- }else{
- strcat(mystring, gtkthemessage);
- freakflag=0;
- }
- // printf("%s",gtkthemessage);
-
- return;
- }
/*Auteur : Stephane Marchand
*Date : 23 dec 2008
*Loc.: Rouyn-Noranda, Quebec, Canada
*Version Alpha000001, mode console
*requis : un modem avec fonction callerid
* GCC, Linpopup(linux) ou winpopup(windblows)
*But : avoir la fonction d'affichage en modem graphique (X, win)
*etat du code : mal en point
*J'etais suppose utilise un toolkit GTK, mais j'ai laisser tomber...
*/
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#define BAUDRATE B38400
#define MODEMDEVICE "/dev/ttyS1"
#define _POSIX_SOURCE 1 /* POSIX compliant source */
#define FALSE 0
#define TRUE 1
#define MAX_FILE_LEN 256 // max length of file, dev, strbuf
volatile int STOP=FALSE;
void sendcmd(int fd, int timewait, char *fmt, ...);
void mygtksend(char *gtkthemessage);
char mystring[500];
int thering=0;
char buffermsg[501];
char buffermsg2[501];
char buf[255];
int freakflag;
int main(void)
{
int fd,res;
struct termios oldtio,newtio;
// you need your network to work with a win2000 (linux-windows)
// win2k is my target machine along with a linux station
// but... smbclient need to be install along with linpopup so
// from linux station you can send/receive mesg.
// My test were with several ubuntu station with a win2k pc
// Every comments below here are for debugging
// THIS code is from a learner and from the internet.
// strcat(buffermsg,"/home/titou/Documents/dev_Steph/gnomecallerid/calleridmain ");
fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY );
if (fd <0) {perror(MODEMDEVICE); exit(1); }
tcgetattr(fd,&oldtio); /* save current port settings */
bzero(&newtio, sizeof(newtio));
newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;
newtio.c_iflag = IGNPAR;
newtio.c_oflag = 0;
/* set input mode (non-canonical, no echo,...) */
newtio.c_lflag = 0;
newtio.c_cc[VTIME] = 0; /* inter-character timer unused */
newtio.c_cc[VMIN] = 5; /* blocking read until 5 chars received */
tcflush(fd, TCIFLUSH);
tcsetattr(fd,TCSANOW,&newtio);
sendcmd(fd, 3, "+++\r");
sendcmd(fd, 3, "ath\r");
sendcmd(fd, 3, "at#CID=1\r");
while (STOP==FALSE) { /* loop for input */
res = read(fd,buf,255); /* returns after 5 chars have been input */
buf[res]=0; /* so we can printf... */
/*printf(":%s:%d", buf, res);*/
//printf("%s", buf);
if(freakflag==1){
buf[0]='\0';
printf("freakflag to 1");
}
mygtksend(buf);
if (buf[0]=='z') STOP=TRUE;
}
tcsetattr(fd,TCSANOW,&oldtio);
return 0;
}
void sendcmd(int fd, int timewait, char *fmt, ...)
{
char strbuf[MAX_FILE_LEN];
va_list ap;
bzero(strbuf, sizeof(strbuf));
// flush i/o
tcflush(fd, TCIOFLUSH);
// send the command
va_start(ap, fmt);
vsnprintf(strbuf, sizeof(strbuf) - 1, fmt, ap);
write(fd, strbuf, strlen(strbuf));
va_end(ap);
//wait for whatever char has been transmitted
tcdrain(fd);
sleep(timewait);
return;
}
void mygtksend(char *gtkthemessage){
//sending message to 2 stations
//so 2 buffers
if(strstr(gtkthemessage,"RING")!=NULL) thering++;
if(thering==2){
thering=0;
// send message to gtk prog.
strcat(buffermsg,"echo \"GNOMECALLERID\n\r");
strcat(buffermsg2,"echo \"GNOMECALLERID\n\r");
strcat(buffermsg, mystring);
strcat(buffermsg2, mystring);
strcat(buffermsg,"\" | smbclient -M drebi");
strcat(buffermsg2,"\" | smbclient -M voyager");
//printf("%s", buffermsg);
system(buffermsg);
system(buffermsg2);
buffermsg[0]='\0';
buffermsg2[0]='\0';
mystring[0]='\0';
// freaking put the buffer to 0 character !!!
freakflag=1;
}else{
strcat(mystring, gtkthemessage);
freakflag=0;
}
// printf("%s",gtkthemessage);
return;
}
Conclusion
ca fait le travail mais c'est pas tres 'beau' comme code
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc SHAREPOINT BLOG SITE, PROBLèME D'ARCHIVESSHAREPOINT BLOG SITE, PROBLèME D'ARCHIVES par junarnoalg
Dernièrement, nous avons migré le site
myTIC
vers un nouveau serveur SharePoint 2010. Dans les contenus que nous vouloins récupérer, nous avions un certain nombre de blogs.
Nous avons utilisé les commandes Power...
Cliquez pour lire la suite de l'article par junarnoalg
Forum
MATRICE TEMPLATEMATRICE TEMPLATE par hjr2610
Cliquez pour lire la suite par hjr2610 RE : SAC A DOS RE : SAC A DOS par hadjkaddour
Cliquez pour lire la suite par hadjkaddour
Logiciels
sDEVIS-FACTURES vlPRO (8.1.0.3)SDEVIS-FACTURES VLPRO (8.1.0.3)sDEVIS-FACTURES vlPRO a été mis au point pour les particuliers, créateurs, entrepreneurs, artisa... Cliquez pour télécharger sDEVIS-FACTURES vlPRO 974 Application Server (12.2.4.6)974 APPLICATION SERVER (12.2.4.6)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP
|