예제 #1
0
/** Constructor */
MessagesDialog::MessagesDialog(QWidget *parent)
: MainPage(parent)
{
  /* Invoke the Qt Designer generated object setup routine */
  ui.setupUi(this);

  connect( ui.msgWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messageslistWidgetCostumPopupMenu( QPoint ) ) );
  connect( ui.msgList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgfilelistWidgetCostumPopupMenu( QPoint ) ) );
  connect( ui.msgWidget, SIGNAL( itemClicked ( QTreeWidgetItem *, int) ), this, SLOT( updateMessages ( QTreeWidgetItem *, int) ) );
  connect( ui.listWidget, SIGNAL( currentRowChanged ( int) ), this, SLOT( changeBox ( int) ) );
  
  
  connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(newmessage()));
  connect(ui.removemessageButton, SIGNAL(clicked()), this, SLOT(removemessage()));
  

  mCurrCertId = "";
  mCurrMsgId  = "";
  
  /* hide the Tree +/- */
  ui.msgList -> setRootIsDecorated( false );


  /* Hide platform specific features */
#ifdef Q_WS_WIN

#endif
}
예제 #2
0
void KIconEditGrid::editPasteAsNew()
{
  bool ok = false;
  const QImage *tmp = clipboardImage(ok);

  if(ok)
  {
    *img = *tmp;
    load(img);
    modified = true;
    //repaint(viewRect(), false);

    p = *img;
    emit changed(QPixmap(p));
    emit sizechanged(numCols(), numRows());
    emit colorschanged(numColors(), data());
    emit newmessage(i18n("Done pasting"));
  }
  else
  {
    QString msg = i18n("Invalid pixmap data in clipboard!\n");
    KMsgBox::message(this, i18n("Warning"), msg.data());
  }
  delete tmp;
}
예제 #3
0
파일: tester.c 프로젝트: 99years/plan9
void
main(int argc, char **argv)
{
	char *err;
	char *mboxfile;

	ARGBEGIN{
	}ARGEND;

	if(argc > 0)
		mboxfile = argv[0];
	else
		mboxfile = "./mbox";

	root = newmessage(nil);

	err = readmbox(mboxfile, &root->part);
	if(err != nil){
		fprint(2, "boom: %s\n", err);
		exits(0);
	}

	info(0, 1, root);

	exits(0);
}
예제 #4
0
void MessageWind::on_action_Send_Message_triggered() //发送消息
{

    QTreeWidgetItem* item=ui->contactsTreeWidget->currentItem();
    Contact contact=texttocontact(item->whatsThis(0));
    NewMessage newmessage(numberToName(contact.number));
    newmessage.exec();
}
예제 #5
0
QImage *KIconEditGrid::getSelection(bool cut)
{
  const QRect rect = pntarray.boundingRect();
  int nx = 0, ny = 0, nw = 0, nh = 0;
  rect.rect(&nx, &ny, &nw, &nh);

  QImage *tmp = new QImage(nw, nh, 32);
  tmp->fill(TRANSPARENT);

  int s = pntarray.size(); //((rect.size().width()) * (rect.size().height()));
  for(int i = 0; i < s; i++)
  {
    int x = pntarray[i].x();
    int y = pntarray[i].y();
    if(img->valid(x, y) && rect.contains(QPoint(x, y)))
    {
      *((uint*)tmp->scanLine(y-ny) + (x-nx)) = *((uint*)img->scanLine(y) + x);
      if(cut)
      {
        *((uint*)img->scanLine(y) + x) = TRANSPARENT;
        setColor( (y*numCols()) + x, TRANSPARENT, false );
      }
    }
  }

  QPointArray a(pntarray.copy());
  pntarray.resize(0);
  drawPointArray(a, Mark);
  emit selecteddata(false);
  if(cut)
  {
    updateColors();
    repaint(rect.x()*cellSize(), rect.y()*cellSize(),
            rect.width()*cellSize(), rect.height()*cellSize(), false);
    p = *img;
    emit changed(p);
    emit colorschanged(numColors(), data());
    emit newmessage(i18n("Selected area cutted"));
  }
  else
    emit newmessage(i18n("Selected area copied"));

  return tmp;
}
예제 #6
0
void KIconEditGrid::editClear()
{
  img->fill(TRANSPARENT);
  fill(TRANSPARENT);
  update();
  modified = true;
  p = *img;
  emit changed(p);
  emit newmessage(i18n("Cleared"));
}
예제 #7
0
void KIconEditGrid::editSelectAll()
{
  start.setX(0);
  start.setY(0);
  end.setX(numCols());
  end.setY(numRows());
  isselecting = true;
  drawRect(false);
  emit newmessage(i18n("All selected"));
}
예제 #8
0
/** Constructor */
MessageWindow::MessageWindow(QWidget *parent, Qt::WindowFlags flags)
: RWindow("MessageWindow", parent, flags)
{
    /* Invoke the Qt Designer generated object setup routine */
    ui.setupUi(this);
        
	setAttribute ( Qt::WA_DeleteOnClose, true );

	actionSaveAs = NULL;
	actionPrint = NULL;
	actionPrintPreview = NULL;

	setupFileActions();

	connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(newmessage()));

	connect(ui.actionTextBesideIcon, SIGNAL(triggered()), this, SLOT(buttonStyle()));
	connect(ui.actionIconOnly, SIGNAL(triggered()), this, SLOT(buttonStyle()));
	connect(ui.actionTextUnderIcon, SIGNAL(triggered()), this, SLOT(buttonStyle()));

	ui.actionTextBesideIcon->setData(Qt::ToolButtonTextBesideIcon);
	ui.actionIconOnly->setData(Qt::ToolButtonIconOnly);
	ui.actionTextUnderIcon->setData(Qt::ToolButtonTextUnderIcon);

	msgWidget = NULL;
	
    // create tag menu
	TagsMenu *menu = new TagsMenu (tr("Tags"), this);
	connect(menu, SIGNAL(aboutToShow()), this, SLOT(tagAboutToShow()));
	connect(menu, SIGNAL(tagSet(int, bool)), this, SLOT(tagSet(int, bool)));
	connect(menu, SIGNAL(tagRemoveAll()), this, SLOT(tagRemoveAll()));

	ui.tagButton->setMenu(menu);
    
    // create print menu
	QMenu *printmenu = new QMenu();
	printmenu->addAction(ui.actionPrint);
	printmenu->addAction(ui.actionPrint_Preview);
	ui.printbutton->setMenu(printmenu);

	// create view menu
	QMenu *viewmenu = new QMenu();
	viewmenu->addAction(ui.actionTextBesideIcon);
	viewmenu->addAction(ui.actionIconOnly);
	//viewmenu->addAction(ui.actionTextUnderIcon);
	ui.viewtoolButton->setMenu(viewmenu);

	processSettings(true);

    /* Hide platform specific features */
#ifdef Q_WS_WIN

#endif
}
예제 #9
0
void MessagesDialog::messageslistWidgetCostumPopupMenu( QPoint point )
{

      QMenu contextMnu( this );
      QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );

      newmsgAct = new QAction(QIcon(IMAGE_MESSAGE), tr( "New Message" ), this );
      connect( newmsgAct , SIGNAL( triggered() ), this, SLOT( newmessage() ) );
      
      replytomsgAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr( "Reply to Message" ), this );
      connect( replytomsgAct , SIGNAL( triggered() ), this, SLOT( replytomessage() ) );
      
      removemsgAct = new QAction(QIcon(IMAGE_MESSAGEREMOVE), tr( "Remove Message" ), this );
      connect( removemsgAct , SIGNAL( triggered() ), this, SLOT( removemessage() ) );
      


      contextMnu.clear();
      contextMnu.addAction( newmsgAct);
      contextMnu.addAction( replytomsgAct);
      contextMnu.addAction( removemsgAct);
      contextMnu.exec( mevent->globalPos() );
}
예제 #10
0
파일: plan9.c 프로젝트: AustenConrad/plan-9
//
//  read in the mailbox and parse into messages.
//
static char*
_readmbox(Mailbox *mb, int doplumb, Mlock *lk)
{
	int fd, n;
	String *tmp;
	Dir *d;
	static char err[128];
	Message *m, **l;
	Inbuf *inb;
	char *x;

	l = &mb->root->part;

	/*
	 *  open the mailbox.  If it doesn't exist, try the temporary one.
	 */
	n = 0;
retry:
	fd = open(mb->path, OREAD);
	if(fd < 0){
		rerrstr(err, sizeof(err));
		if(strstr(err, "exclusive lock") != 0 && n++ < 20){
			sleep(500);	/* wait for lock to go away */
			goto retry;
		}
		if(strstr(err, "exist") != 0){
			tmp = s_copy(mb->path);
			s_append(tmp, ".tmp");
			if(sysrename(s_to_c(tmp), mb->path) == 0){
				s_free(tmp);
				goto retry;
			}
			s_free(tmp);
		}
		return err;
	}

	/*
	 *  a new qid.path means reread the mailbox, while
	 *  a new qid.vers means read any new messages
	 */
	d = dirfstat(fd);
	if(d == nil){
		close(fd);
		errstr(err, sizeof(err));
		return err;
	}
	if(mb->d != nil){
		if(d->qid.path == mb->d->qid.path && d->qid.vers == mb->d->qid.vers){
			close(fd);
			free(d);
			return nil;
		}
		if(d->qid.path == mb->d->qid.path){
			while(*l != nil)
				l = &(*l)->next;
			seek(fd, mb->d->length, 0);
		}
		free(mb->d);
	}
	mb->d = d;
	mb->vers++;
	henter(PATH(0, Qtop), mb->name,
		(Qid){PATH(mb->id, Qmbox), mb->vers, QTDIR}, nil, mb);

	inb = emalloc(sizeof(Inbuf));
	inb->rptr = inb->wptr = inb->data;
	inb->fd = fd;

	//  read new messages
	snprint(err, sizeof err, "reading '%s'", mb->path);
	logmsg(err, nil);
	for(;;){
		if(lk != nil)
			syslockrefresh(lk);
		m = newmessage(mb->root);
		m->mallocd = 1;
		m->inmbox = 1;
		if(readmessage(m, inb) < 0){
			delmessage(mb, m);
			mb->root->subname--;
			break;
		}

		// merge mailbox versions
		while(*l != nil){
			if(memcmp((*l)->digest, m->digest, SHA1dlen) == 0){
				// matches mail we already read, discard
				logmsg("duplicate", *l);
				delmessage(mb, m);
				mb->root->subname--;
				m = nil;
				l = &(*l)->next;
				break;
			} else {
				// old mail no longer in box, mark deleted
				logmsg("disappeared", *l);
				if(doplumb)
					mailplumb(mb, *l, 1);
				(*l)->inmbox = 0;
				(*l)->deleted = 1;
				l = &(*l)->next;
			}
		}
		if(m == nil)
			continue;

		x = strchr(m->start, '\n');
		if(x == nil)
			m->header = m->end;
		else
			m->header = x + 1;
		m->mheader = m->mhend = m->header;
		parseunix(m);
		parse(m, 0, mb, 0);
		logmsg("new", m);

		/* chain in */
		*l = m;
		l = &m->next;
		if(doplumb)
			mailplumb(mb, m, 0);

	}
	logmsg("mbox read", nil);

	// whatever is left has been removed from the mbox, mark deleted
	while(*l != nil){
		if(doplumb)
			mailplumb(mb, *l, 1);
		(*l)->inmbox = 0;
		(*l)->deleted = 1;
		l = &(*l)->next;
	}

	close(fd);
	free(inb);
	return nil;
}
예제 #11
0
파일: pop3.c 프로젝트: AustenConrad/plan-9
//
// check for new messages on pop server
// UIDL is not required by RFC 1939, but 
// netscape requires it, so almost every server supports it.
// we'll use it to make our lives easier.
//
static char*
pop3read(Pop *pop, Mailbox *mb, int doplumb)
{
	char *s, *p, *uidl, *f[2];
	int mesgno, ignore, nnew;
	Message *m, *next, **l;

	// Some POP servers disallow UIDL if the maildrop is empty.
	pop3cmd(pop, "STAT");
	if(!isokay(s = pop3resp(pop)))
		return s;

	// fetch message listing; note messages to grab
	l = &mb->root->part;
	if(strncmp(s, "+OK 0 ", 6) != 0) {
		pop3cmd(pop, "UIDL");
		if(!isokay(s = pop3resp(pop)))
			return s;

		for(;;){
			p = pop3resp(pop);
			if(strcmp(p, ".") == 0 || strcmp(p, "unexpected eof") == 0)
				break;

			if(tokenize(p, f, 2) != 2)
				continue;

			mesgno = atoi(f[0]);
			uidl = f[1];
			if(strlen(uidl) > 75)	// RFC 1939 says 70 characters max
				continue;

			ignore = 0;
			while(*l != nil) {
				if(strcmp((*l)->uidl, uidl) == 0) {
					// matches mail we already have, note mesgno for deletion
					(*l)->mesgno = mesgno;
					ignore = 1;
					l = &(*l)->next;
					break;
				} else {
					// old mail no longer in box mark deleted
					if(doplumb)
						mailplumb(mb, *l, 1);
					(*l)->inmbox = 0;
					(*l)->deleted = 1;
					l = &(*l)->next;
				}
			}
			if(ignore)
				continue;

			m = newmessage(mb->root);
			m->mallocd = 1;
			m->inmbox = 1;
			m->mesgno = mesgno;
			strcpy(m->uidl, uidl);

			// chain in; will fill in message later
			*l = m;
			l = &m->next;
		}
	}

	// whatever is left has been removed from the mbox, mark as deleted
	while(*l != nil) {
		if(doplumb)
			mailplumb(mb, *l, 1);
		(*l)->inmbox = 0;
		(*l)->deleted = 1;
		l = &(*l)->next;
	}

	// download new messages
	nnew = 0;
	if(pop->pipeline){
		switch(rfork(RFPROC|RFMEM)){
		case -1:
			fprint(2, "rfork: %r\n");
			pop->pipeline = 0;

		default:
			break;

		case 0:
			for(m = mb->root->part; m != nil; m = m->next){
				if(m->start != nil)
					continue;
				Bprint(&pop->bout, "LIST %d\r\nRETR %d\r\n", m->mesgno, m->mesgno);
			}
			Bflush(&pop->bout);
			_exits(nil);
		}
	}

	for(m = mb->root->part; m != nil; m = next) {
		next = m->next;

		if(m->start != nil)
			continue;

		if(s = pop3download(pop, m)) {
			// message disappeared? unchain
			fprint(2, "download %d: %s\n", m->mesgno, s);
			delmessage(mb, m);
			mb->root->subname--;
			continue;
		}
		nnew++;
		parse(m, 0, mb, 1);

		if(doplumb)
			mailplumb(mb, m, 0);
	}
	if(pop->pipeline)
		waitpid();

	if(nnew || mb->vers == 0) {
		mb->vers++;
		henter(PATH(0, Qtop), mb->name,
			(Qid){PATH(mb->id, Qmbox), mb->vers, QTDIR}, nil, mb);
	}

	return nil;	
}
예제 #12
0
void KIconEditGrid::editPaste(bool paste)
{
  bool ok = false;
  const QImage *tmp = clipboardImage(ok);
  fixTransparence((QImage*)tmp);

  Properties *pprops = props(this);

  if(ok)
  {
    if( (tmp->size().width() > img->size().width()) || (tmp->size().height() > img->size().height()) )
    {
      if(KMsgBox::yesNo(this, i18n("Warning"),
          i18n("The clipboard image is larger than the current image!\nPaste as new image?")) == 1)
      {
        editPasteAsNew();
      }
      delete tmp;
      return;
    }
    else if(!paste)
    {
      ispasting = true;
      cbsize = tmp->size();
      //debug("insrect size: %d x %d", insrect.width(), insrect.height());
      return;
      emit newmessage(i18n("Pasting"));
    }
    else
    {
      //debug("KIconEditGrid: Pasting at: %d x %d", insrect.x(), insrect.y());

      QApplication::setOverrideCursor(waitCursor);

      for(int y = insrect.y(), ny = 0; y < numRows(), ny < insrect.height(); y++, ny++)
      {
        uint *l = ((uint*)img->scanLine(y)+insrect.x());
        uint *cl = (uint*)tmp->scanLine(ny);
        for(int x = insrect.x(), nx = 0; x < numCols(), nx < insrect.width(); x++, nx++, l++, cl++)
        {
          if(*cl != TRANSPARENT || pprops->pastetransparent)
          {
            *l = *cl;
            setColor((y*numCols())+x, (uint)*cl, false);
          }
        }
      }
      updateColors();
      repaint(insrect.x()*cellSize(), insrect.y()*cellSize(),
              insrect.width()*cellSize(), insrect.height()*cellSize(), false);

      QApplication::restoreOverrideCursor();

      modified = true;
      p = *img;
      emit changed(QPixmap(p));
      emit sizechanged(numCols(), numRows());
      emit colorschanged(numColors(), data());
      emit newmessage(i18n("Done pasting"));
    }
  }
  else
  {
    QString msg = i18n("Invalid pixmap data in clipboard!\n");
    KMsgBox::message(this, i18n("Warning"), msg.data());
  }
  delete tmp;
}
예제 #13
0
/*main loop, message sender, etc.pp.*/
int main(int argc,char**argv)
{
	int c,optindex=1;
	struct dhcp_msg *msg;
	/*parse options*/
	argv0=*argv;
        while(1){
                c=getopt_long(argc,argv,shortopt,longopt,&optindex);
                if(c==-1)break;
                switch(c){
                        case 'p':getprefix=1;break;
                        case 'P':getprefix=0;break;
                        case 'a':getaddress=1;break;
                        case 'A':getaddress=0;break;
                        case 'd':getdns=1;break;
                        case 'D':getdns=0;break;
                        case 'r':retries=atoi(optarg);break;
                        case 'l':localid=optarg;break;
                        case 'u':setduid(optarg);break;
                        case 'c':userapid=1;break;
                        case 'C':userapid=0;break;
                        case 'L':setloglevel(optarg);break;
                        default:
                                fprintf(stderr,"Syntax error in arguments.\n");
                                printhelp();
                                return 1;
                                break;
                        case 'h':
                                printhelp();
                                return 0;
                                break;
                }
        }
        if((optind+2)!=argc){
        	fprintf(stderr,"Syntax error.\n");
        	printhelp();
        	return 1;
	}
	device=argv[optind];
	script=argv[optind+1];

	if(DUIDLEN==0){
		if(localid)
			setlocalid(localid);
		else
			initlocalid();
	}
	/*init socket*/
	initsocket(DHCP_CLIENTPORT,device);
	if(sockfd<0){
		td_log(LOGERROR,"unable to allocate socket, exiting.");
		exit(1);
	}
	/*init my own stuff*/
	inititems();
	/*init SOLICIT/IREQ msg*/
	if(!getaddress && !getprefix){
		msg=newmessage(MSG_IREQUEST);
		addrecvfilter(MSG_REPLY);
	}else{
		msg=newmessage(MSG_SOLICIT);
		addrecvfilter(MSG_ADVERTISE);
	}
	COMPAREMSGID=1;
	settargetserver(&msg->msg_peer);
	messageaddopt(msg,OPT_CLIENTID);
	if(getdns){
		messageaddoptrequest(msg,OPT_DNS_SERVER);
		messageaddoptrequest(msg,OPT_DNS_NAME);
	}
	if(getaddress)messageaddopt(msg,OPT_IANA);
	if(getprefix)messageaddopt(msg,OPT_IAPD);
	if(userapid&&(getaddress||getprefix))messageaddopt(msg,OPT_RAPIDCOMMIT);
	/*start main loop*/
	for(c=0;c<retries;c++){
		sendmessage(msg);
		fd_set rfd,xfd;
		struct timeval tv;
		int sret;
		//wait for event
		FD_ZERO(&rfd);
		FD_ZERO(&xfd);
		FD_SET(sockfd,&rfd);
		FD_SET(sockfd,&xfd);
		tv.tv_sec=1;
		tv.tv_usec=0;
		sret=select(sockfd+1,&rfd,0,&xfd,&tv);
		//check for errors
		if(sret<0){
			int e=errno;
			if(e==EAGAIN)continue;
			td_log(LOGERROR,"Error caught: %s\n",strerror(e));
			return 1;
		}
		//check for event
		if(sret>0){
			if(FD_ISSET(sockfd,&rfd)){
				struct dhcp_msg*msg2;
				msg2=readmessage();
				if(msg2)
					if(handlemessage(msg2,msg)==0)break;
			}
			if(FD_ISSET(sockfd,&xfd)){
				td_log(LOGERROR,"Exception on socket caught.\n");
				return 1;
			}
		}else
			td_log(LOGDEBUG,"timeout, iteration %i",c);
	}
	/*execute script*/
	return execscript();
}
예제 #14
0
파일: imap4.c 프로젝트: aberg001/plan9
//
// check for new messages on imap4 server
// download new messages, mark deleted messages
//
static char*
imap4read(Imap *imap, Mailbox *mb, int doplumb)
{
    char *s;
    int i, ignore, nnew, t;
    Message *m, *next, **l;

    imap4cmd(imap, "STATUS %Z (MESSAGES UIDVALIDITY)", imap->mbox);
    if(!isokay(s = imap4resp(imap)))
        return s;

    imap->nuid = 0;
    imap->uid = erealloc(imap->uid, imap->nmsg*sizeof(imap->uid[0]));
    imap->muid = imap->nmsg;

    if(imap->nmsg > 0) {
        imap4cmd(imap, "UID FETCH 1:* UID");
        if(!isokay(s = imap4resp(imap)))
            return s;
    }

    l = &mb->root->part;
    for(i=0; i<imap->nuid; i++) {
        ignore = 0;
        while(*l != nil) {
            if((*l)->imapuid == imap->uid[i]) {
                ignore = 1;
                l = &(*l)->next;
                break;
            } else {
                // old mail, we don't have it anymore
                if(doplumb)
                    mailplumb(mb, *l, 1);
                (*l)->inmbox = 0;
                (*l)->deleted = 1;
                l = &(*l)->next;
            }
        }
        if(ignore)
            continue;

        // new message
        m = newmessage(mb->root);
        m->mallocd = 1;
        m->inmbox = 1;
        m->imapuid = imap->uid[i];

        // add to chain, will download soon
        *l = m;
        l = &m->next;
    }

    // whatever is left at the end of the chain is gone
    while(*l != nil) {
        if(doplumb)
            mailplumb(mb, *l, 1);
        (*l)->inmbox = 0;
        (*l)->deleted = 1;
        l = &(*l)->next;
    }

    // download new messages
    t = imap->tag;
    if(pipeline)
        switch(rfork(RFPROC|RFMEM)) {
        case -1:
            sysfatal("rfork: %r");
        default:
            break;
        case 0:
            for(m = mb->root->part; m != nil; m = m->next) {
                if(m->start != nil)
                    continue;
                if(imap->debug)
                    fprint(2, "9X%d UID FETCH %lud (UID RFC822.SIZE BODY[])\r\n",
                           t, (ulong)m->imapuid);
                Bprint(&imap->bout, "9X%d UID FETCH %lud (UID RFC822.SIZE BODY[])\r\n",
                       t++, (ulong)m->imapuid);
            }
            Bflush(&imap->bout);
            _exits(nil);
        }

    nnew = 0;
    for(m=mb->root->part; m!=nil; m=next) {
        next = m->next;
        if(m->start != nil)
            continue;

        if(!pipeline) {
            Bprint(&imap->bout, "9X%lud UID FETCH %lud (UID RFC822.SIZE BODY[])\r\n",
                   (ulong)imap->tag, (ulong)m->imapuid);
            Bflush(&imap->bout);
        }

        if(s = imap4fetch(mb, m)) {
            // message disappeared?  unchain
            fprint(2, "download %lud: %s\n", (ulong)m->imapuid, s);
            delmessage(mb, m);
            mb->root->subname--;
            continue;
        }
        nnew++;
        if(doplumb)
            mailplumb(mb, m, 0);
    }
    if(pipeline)
        waitpid();

    if(nnew || mb->vers == 0) {
        mb->vers++;
        henter(PATH(0, Qtop), mb->name,
        (Qid) {
            PATH(mb->id, Qmbox), mb->vers, QTDIR
        }, nil, mb);
    }
    return nil;
}