Beispiel #1
0
/*
  We have a new comand from the server.
  'emit' a signal.
 */
void TTCP::newCommand(const QStringList &list)
{
    if (list[0] == "auto") {

	if (list.size() == 12) {
	    emit add_autoentry(list[1], list[2].toInt(), list[3].toInt(), list[4], list[5], list[6], list[7], list[8], list[9], list[10], list[11]);
			     /* user    project          auto_id          host     name     class    role     desk     title     flags    enabled */
	} else
	if (list.size() == 11) {
	    emit add_autoentry(list[1], list[2].toInt(), list[3].toInt(), list[4], list[5], list[6], list[7], list[8], list[9], list[10], "t");
			     /* user    project          auto_id          host     name     class    role     desk     title     flags    enabled */
	}
    } else if (list[0] == "entry") {
	emit add_entry(list[2], list[3].toInt(), list[4].toInt(), totime(list[5]),  totime(list[6]));
    } else if (list[0] == "timeslice") {
        if (list.size() == 8) {
            emit add_timeslice(list[1], list[2].toInt(), list[3].toInt(), list[4].toInt(), list[5], todatetime(list[6]), list[7]);
        } else {
            qWarning("timeslice: wrong # of arguments %d", list.size());
	}
    } else if (list[0] == "current") {
	emit current(list[2].toInt());
    } else if (list[0] == "disable") {
	emit disable(list[2].toInt());
    } else if (list[0] == "error") {
	emit error(list[1]);
    } else if (list[0] == "update") {
	emit update_all();
    } else if (list[0] == "update_time") {
	if (list.count() == 5) {
	    emit settime(list[2].toInt(), totime(list[3]), totime(list[4]));
	} else {
	    printf("Error in update_time\n");
	}
    } else if (list[0] == "accept_note") {
        qWarning("%s %s", qPrintable(list[0]), qPrintable(list[1]));
	emit accept_note(list[1]);
    } else if (list[0] == "accept_task") {
	emit accept_project(list[1]);
    } else if (list[0] == "accept_select") {
	emit accept_select(list[1]);
    } else if (list[0] == "alert") {
        emit alert_message(list[1].toInt(), list[2], list[3]);
    } else if (list[0] == "alert_end") {
        emit alert_end_message(list[1].toInt());
    } else if (list[0] == "hourly") {
        qWarning("Hourly");
        emit hourly();
    } else if (list[0] == "recentproject") {
        emit recentproject(
                    list[2].toInt(),   // project ID
                    list[3].toInt(),   // index
                    list[4].toInt(),   // max index
                    QString("A comment")
                );
    } else if (list[0] == "recentprojects") {
        QStringList plist(list.mid(2));
        QList<int> pilist;
        QStringList::iterator i;
        for (i = plist.begin(); i != plist.end(); ++i)
            pilist.append((*i).toInt());
        emit recentprojects(
                    pilist
                );
    } else {
        qWarning("TTCP Unknown: '%s'/%d\n", qPrintable(list[0]), list.size() - 1);
    }
}
Beispiel #2
0
int main ( int argc, char *argv[] )
 {
   int tdlstat;
   FILE *fp;
   char filename[8];
   int rep_type = atoi( argv[2] );
   int isc_no = atoi ( argv[3] );
   char mode = toupper(*argv[4]);

	if ( argc != 5 )
     terminate(1);

   if ( ( tdlstat = tdlinit()) != NORMAL )
     {
      //tdloff();
      return (tdlstat);
     }

   memset ( filename, 0, sizeof( filename ) );
	memcpy ( filename, afiles[ rep_type ], 2 );
   filename [2] = '3'; filename [3] = '5';
   memcpy ( filename+4, argv[1], 2 );
   filename[6] = mode; filename[7] = '\0';

   fp = fopen ( filename, "a" );

	switch ( rep_type )
     {
       case 0 :   if ( ( tdlstat = termrep ( isc_no, mode, fp )) != NORMAL)
                    {
                     tdloff();
               	   fclose (fp);
                     return(tdlstat);
                    }
                  break;

       case 1 :  if ( ( tdlstat = ddaily ( isc_no, mode, fp )) != NORMAL)
                    {
                     tdloff();
               	   fclose (fp);
                     return(tdlstat);
                    }
                  break;

       case 2 : if ( ( tdlstat = plall_i  ( isc_no, mode, fp )) != NORMAL)
                    {
                     tdloff();
               	   fclose (fp);
                     return(tdlstat);
                    }
                   break;
       case 3 : if ( ( tdlstat = hourly  ( isc_no, mode, fp )) != NORMAL)
                    {
                     tdloff();
               	   fclose (fp);
                     return(tdlstat);
                    }
                   break;
       case 4 : if ( ( tdlstat = floatc  ( isc_no, mode, 1, fp )) != NORMAL)
                    {
                     tdloff();
               	   fclose (fp);
                     return(tdlstat);
                    }
                   break;
  	  }

   tdloff();
   fclose (fp);
   return ( NORMAL );
  }