Esempio n. 1
0
static void loadConfig() {
    byte* p = (byte*) &config;
    for (byte i = 0; i < sizeof config; ++i)
        p[i] = eeprom_read_byte((byte*) i);
    // if loaded config is not valid, replace it with defaults
    if (config.magic != 123) {
        config.magic = 123;
        config.freq = 8;
        config.in_group = 5;
        config.in_node = 31;
        config.out_group = 6;
        config.out_node = 30;
        config.acks_enable = 1; // 1 to support round-trip ACK relaying
        config.multi_node = 1;  // 1 to insert orig header byte when relaying
    }
    config.magic = 123;
    config.freq = 8;
    config.in_group = 5;
    config.in_node = 31;
    config.out_group = 5;
    config.acks_enable = 0;
    config.multi_node = 0;
    showConfig();
    rf12_initialize(config.in_node, code2type(config.freq), config.in_group);
}
Esempio n. 2
0
  /** 
   * Configure the QAction for this tool.
   * 
   * @param toolpad
   * 
   * @return QAction*
   */
  QAction *ScatterPlotTool::toolPadAction(ToolPad *toolpad) {
    p_action = new QAction(toolpad);
    p_action->setIcon(QPixmap(toolIconDir()+"/scatterplot.png"));
    p_action->setToolTip("Scatter Plot");
    //action->setShortcut(Qt::Key_C);
    QObject::connect(p_action,SIGNAL(activated()),p_mainWindow,SLOT(showConfig()));

    QString text  =
      "<b>Function:</b>  Compare two bands of same image or of a different image. \
      <p><b>Shortcut:</b>nonexsistant right now</p> ";
    p_action->setWhatsThis(text);
    return p_action;
  }
Esempio n. 3
0
bool CmdConfig::exec(CmdHelper* ch)
{
  if(!init(ch)) return false;

  mCmd->regSubCmds("set show");

  if(mCmd->subCmdLooksBad()) return false;

  if(mCmd->wantHelp())
  {
    mCmd->inSubBrief("set", tr("Set config file values"));
    mCmd->inSubBrief("show", tr("Print config file settings"));
  }

  if(mCmd->needHelp(2))
  {
    if(mCmd->printThisWay("<Command>")) return true;

    mCmd->printComment(tr(
      "As you may know take the --config option each Filu program to use temporary "
      "different settings. With the set command will these settings written "
      "into the config file."));
    mCmd->printNote(tr(
      "To remove (unset) a key use '<Key>=---'"));
    mCmd->printForInst("set SqlDebug=Ample Verbose=Ample");
    mCmd->aided();
    return true;
  }

//   if(mIamEvil)
//   {
//     warning(FUNC, tr(""));
//   }

  if(mCmd->hasSubCmd("set"))        setConfig();
  else if(mCmd->hasSubCmd("show"))  showConfig();
  else
  {
    fatal(FUNC, QString("Unsupported command: %1").arg(mCmd->cmd()));
  }

  return !hasError();
}
void configure(int arg_num, char *arg_vet[]) {

    bool config_found = false;

    for (int i = 1; i < arg_num; i++) {
	    if (!strcmp(arg_vet[i], "-help")) {
            showHelp(arg_vet[0]);
            exit(0);
        }
    }

    for (int i = 1; i < arg_num; i++) {
	    if (!strcmp(arg_vet[i], "-config")) {
            GlobalParams::config_filename = arg_vet[++i];
            config_found = true;
            break;
        }
    }

    if (!config_found)
    {
        std::ifstream infile(CONFIG_FILENAME);
        if (infile.good())
            GlobalParams::config_filename = CONFIG_FILENAME;
        else
        {
            cerr << "No YAML configuration file found!\n Use -config to load examples from config_examples folder" << endl;
            exit(0);
        }
    }

    loadConfiguration();
    parseCmdLine(arg_num, arg_vet);

    checkConfiguration();

    // Show configuration
    if (GlobalParams::verbose_mode > VERBOSE_OFF)
        showConfig();
}
Esempio n. 5
0
AfarasView::AfarasView(QWidget *parent, Qt::WFlags flags) : KXmlGuiWindow(parent, flags),
  recorder(0),
  currentIndex(0)
{
  KGlobal::locale()->insertCatalog("simonlib");
  ui.setupUi(this);

  connect(ui.pbStartReview, SIGNAL(clicked()), this, SLOT(start()));
  connect(ui.pbBlacklistSample, SIGNAL(toggled(bool)), this, SLOT(blackListSample(bool)));
  connect(ui.pbPreviousSample, SIGNAL(clicked()), this, SLOT(previousSample()));
  connect(ui.pbNextSample, SIGNAL(clicked()), this, SLOT(nextSample()));
  connect(ui.pbBack, SIGNAL(clicked()), this, SLOT(stop()));

  connect(ui.urInputPrompts, SIGNAL(textChanged(QString)), this, SLOT(inputFilesChanged()));
  connect(ui.urPathPrefix, SIGNAL(textChanged(QString)), this, SLOT(inputFilesChanged()));
  connect(ui.urOutputBlacklist, SIGNAL(textChanged(QString)), this, SLOT(inputFilesChanged()));

  ui.wgRecording->setLayout(new QVBoxLayout());

  KStandardAction::quit(this, SLOT(close()), actionCollection());
  KStandardAction::preferences(this, SLOT(showConfig()), actionCollection());
  setupGUI();
}
Esempio n. 6
0
DGLMainWindow::DGLMainWindow(QWidget *_parent, Qt::WindowFlags flags)
        : QMainWindow(_parent, flags), m_BusyDialog(this), m_ProjectSaved(false) {

#pragma warning(push)
#pragma warning(disable : 4127)    // conditional expression is constant
    Q_INIT_RESOURCE(dglmainwindow);
#pragma warning(pop)

    boost::shared_ptr<OsIcon> icon(Os::createIcon());
#ifdef _WIN32
    setWindowIcon(QIcon(HICON_TO_QPIXMAP((HICON)icon->get())));
#endif

    // load designer UI

    m_ui.setupUi(this);
    setDockNestingEnabled(true);

    // create all widgets, actions iteractions etc...

    createActions();
    createMenus();
    createToolBars();
    createStatusBar();
    createDockWindows();
    createInteractions();

    // read QSettings

    readSettings();

    showConfig();

    if (QCoreApplication::arguments().size() == 2) {
        openProjectFromFile(QCoreApplication::arguments()[1]);
    }
}
Esempio n. 7
0
void showHelp() {
    showConfig();
    showString(helpText);
}
Esempio n. 8
0
//========================================
// main...
//----------------------------------------
int main (int argc, char*argv[]) {
	XF86MiscMouseSettings mseinfo;
	Display* dpy;
	int    c;
	int    DEBUG   = False;
	int    show    = False;
	int    Version = False;
	int    apply   = False;
	int    enable  = False;
	int    disable = False;
	int    major   = 0;
	int    minor   = 0;
	char   link    [256] = "";
	char   mydisp  [256] = "";
	char   option  [256] = "";
	char   left    [256] = "";
	struct mouse   *pointer;
	struct devnode *dev;
	struct stat    *linkstatus = NULL;

	pointer = (struct mouse*)   malloc(sizeof(struct mouse));
	dev     = (struct devnode*) malloc(sizeof(struct devnode));

	// get commandline options...
	//-----------------------------
	while (1) {
	int option_index = 0;
	static struct option long_options[] =
	{
		{"show"     , 0 , 0 , 's'},
		{"apply"    , 1 , 0 , 'a'},
		{"display"  , 1 , 0 , 'd'},
		{"help"     , 0 , 0 , 'h'},
		{"link"     , 1 , 0 , 'l'},
		{"enable"   , 0 , 0 , 'E'},
		{"disable"  , 0 , 0 , 'D'},
		{"version"  , 0 , 0 , 'v'},
		{"config"   , 0 , 0 , 'c'},
		{0          , 0 , 0 , 0  }
	};

	c = getopt_long (argc, argv, "hsa:d:l:EDvc",long_options, &option_index);
	if (c == -1)
	break;

	switch (c) {
	case 0:
		if (DEBUG) {
			fprintf (stderr,"option %s", long_options[option_index].name);
		if (optarg)
			fprintf (stderr," with arg %s", optarg);
			fprintf (stderr,"\n");
		}
	break;

	case 'h':
		usage();
	break;

	case 'c':
		showConfig();
	break;	

	case 's':
		show  = True;
	break;

	case 'v':
		Version = True;
	break;

	case 'a':
		if (! IsRoot()) {
			fprintf(stderr,"xmset: only root can do this\n");
			exit(1);
		}
		apply = True;
		strcpy(option,optarg);
	break;

    case 'l':
		// no longer used because we will get the
		// the device name (which may be a link) from the X-Server 
		// and check if it is realy a link to the pointer device. 
		// If not, no symlink is created after apply 
		// ---
		// strcpy(link,optarg);
	break;

	case 'd':
		strcpy(mydisp,optarg);
	break;

	case 'E':
		if (! IsRoot()) {
			fprintf(stderr,"xmset: only root can do this\n");
			exit(1);
		}
		enable  = True;
	break;

	case 'D':
		if (! IsRoot()) {
			fprintf(stderr,"xmset: only root can do this\n");
			exit(1);
		}
		disable = True;
		break;

	default:
		exit(1);
	}
	}
	// ...
	// open display...
	// ---
	if (strcmp(mydisp,"") == 0) {
		strcpy(mydisp,"null");
	}
	dpy = XOpen(mydisp);
	if (dpy == NULL) {
	if (Version) {
		printf("0:6\n");
	} else {
		fprintf(stderr,"xmset: could not open display\n");
	}
	exit(1);
	}
	if (Version) {
	if (XF86MiscQueryVersion(dpy,&major,&minor)) {
		printf("%d:%d\n",major,minor);
		exit (0);
	}
	}
	// ...
	// store link name if the device specification
	// of the current configuration is a link
	// ---
	if (!XF86MiscGetMouseSettings(dpy, &mseinfo)) {
		fprintf(stderr,"xmset: could not get mouse settings\n");
		exit(1);
	}
	if (apply == True) {
		linkstatus = (struct stat*)malloc(sizeof(struct stat));
		lstat (mseinfo.device,linkstatus);
		if (S_ISLNK (linkstatus->st_mode)) {
			strcpy (link,mseinfo.device);
		}
	}

	//=================================
	// enable mouse
	//---------------------------------
	if (enable == True)  {
		XF86MiscMouseSettings mseinfo;
		if (!XF86MiscGetMouseSettings(dpy, &mseinfo)) {
			exit(1);
		}
		mseinfo.flags |= MF_REOPEN;
		XSetErrorHandler (catchErrors);
		XF86MiscSetMouseSettings(dpy, &mseinfo);
		XSync(dpy, False);
		exit(0);
	}

	//=================================
	// disable mouse
	//---------------------------------
	if (disable == True) {
		XF86MiscMouseSettings mseinfo;
		if (!XF86MiscGetMouseSettings(dpy, &mseinfo)) {
			exit(1);
		}
		mseinfo.flags |= MF_REOPEN;
		mseinfo.device = "/dev/unused";
		XSetErrorHandler (catchErrors);
		XF86MiscSetMouseSettings(dpy, &mseinfo);
		XSync(dpy, False);
		exit(0);
	}

 
	//==================================
	// apply mouse settings
	//----------------------------------
	if (apply == True) {
		XF86MiscMouseSettings mseinfo;
		strsplit (option,':',left,option);  
		strcpy (pointer->device,left);
		strsplit (option,':',left,option);
		strcpy (pointer->type,left);
		strsplit (option,':',left,option);
		pointer->baudrate = atoi(left);
		strsplit (option,':',left,option);
		pointer->samplerate = atoi(left);
		strsplit (option,':',left,option);
		pointer->resolution = atoi(left);
		strsplit (option,':',left,option);
		pointer->buttons = atoi(left);
		strsplit (option,':',left,option);
		if (strcmp(left,"on") == 0) {
			strcpy(pointer->emu3button,"on");
		} else {
			strcpy(pointer->emu3button,"off");
		}
		strsplit(option,':',left,option);
		pointer->emu3timeout = atoi(left);
		strsplit(option,':',left,option);
		if (strcmp(left,"on") == 0) {
			strcpy(pointer->chordmiddle,"on");
		} else {
			strcpy(pointer->chordmiddle,"off");
		}
		strsplit (option,':',left,option);
		strcpy (pointer->flag,left);
		// ...
		// relink the /dev/sax link if the configuration
		// use a device link to point to the input device
		// ---
		if (S_ISLNK (linkstatus->st_mode)) {
			remove (link);
			symlink (pointer->device,link);
		}
		// ...
		// remove mouse from currently 
		// accessed device
		// ---
		if (!XF86MiscGetMouseSettings(dpy, &mseinfo)) {
			exit(1);
		}
		mseinfo.flags |= MF_REOPEN;
		sprintf(mseinfo.device,"disabled");
		XSetErrorHandler (catchErrors);
		XF86MiscSetMouseSettings(dpy, &mseinfo);
		XSync(dpy, False);
		// ...
		// set new mouse parameters...
		// ---
		usleep (1000);
		SetMouse (dpy,pointer);
	}

	//==================================
	// show current mouse settings
	//----------------------------------
	if (show == True) {
		GetMouse(dpy);
	}
	return(0);
}
Esempio n. 9
0
void
xQGanttBarViewPort::initMenu()
/////////////////////////////////
{
    _menu = new KPopupMenu(this);

    /*
        select
    */

    _selectMenu = new KPopupMenu(_menu);

    QPixmap pix = _iconloader->loadIcon("ganttSelect.png", KIcon::Toolbar , 16);
    if(pix.isNull()) printf("ganttSelect.png not found !\n");
    _selectMenu->insertItem(pix, i18n("Select Mode"), this, SLOT(setSelect()));

    _selectMenu->insertSeparator();

    pix = _iconloader->loadIcon("ganttSelecttask.png", KIcon::Toolbar , 16);
    if(pix.isNull()) printf("ganttSelecttask.png not found !\n");
    _selectMenu->insertItem(pix, i18n("Select All"), this, SLOT(selectAll()));

    pix = _iconloader->loadIcon("ganttUnselecttask", KIcon::Toolbar , 16);
    if(pix.isNull()) printf("ganttUnselecttask.png not found !\n");
    _selectMenu->insertItem(pix, i18n("Unselect All"), this, SLOT(unselectAll()));

    _menu->insertItem(i18n("Select"), _selectMenu);


    /*
        zoom
    */

    KPopupMenu *_zoomMenu = new KPopupMenu(_menu);

    pix = _iconloader->loadIcon("viewmag.png", KIcon::Toolbar , 16);
    if(pix.isNull()) printf("viewmag.png not found !\n");
    _zoomMenu->insertItem(i18n("Zoom Mode"), this, SLOT(setZoom()));

    _zoomMenu->insertSeparator();

    _zoomMenu->insertItem(pix, i18n("Zoom All"), this, SLOT(zoomAll()));
    _zoomMenu->insertSeparator();

    pix = _iconloader->loadIcon("viewmag+.png", KIcon::Toolbar , 16);
    if(pix.isNull()) printf("viewmag+.png not found !\n");
    _zoomMenu->insertItem(pix, i18n("Zoom In +"), this, SLOT(zoomIn()));

    pix = _iconloader->loadIcon("viewmag-.png", KIcon::Toolbar , 16);
    if(pix.isNull()) printf("viewmag-.png not found !\n");
    _zoomMenu->insertItem(pix, i18n("Zoom Out -"), this, SLOT(zoomOut()));

    _menu->insertItem("Zoom", _zoomMenu);

    pix = _iconloader->loadIcon("move.png", KIcon::Toolbar , 16);
    if(pix.isNull()) printf("move.png not found !\n");
    _menu->insertItem(pix, i18n("Move Mode"), this, SLOT(setMove()));

    _menu->insertSeparator();

    pix = _iconloader->loadIcon("configure.png", KIcon::Toolbar , 16);
    if(pix.isNull()) printf("configure.png not found !\n");
    _menu->insertItem(pix, i18n("Configure Gantt..."), _parent, SLOT(showConfig()));

}
Esempio n. 10
0
void *JabberBrowser::processEvent(Event *e)
{
    if (e->type() == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->EventAgentInfo){
        JabberAgentInfo *data = (JabberAgentInfo*)(e->param());
        if (m_search_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_search_id = "";
                    delete m_search;
                    m_search = NULL;
                    Command cmd;
                    cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdSearch;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_search->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showSearch()));
                }
                m_search_id = "";
                return e->param();
            }
            m_search->m_search->addWidget(data);
            return e->param();
        }
        if (m_reg_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_reg_id = "";
                    delete m_reg;
                    m_reg = NULL;
                    Command cmd;
                    cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdRegister;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_reg->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showReg()));
                }
                m_reg_id = "";
                return e->param();
            }
            m_reg->m_search->addWidget(data);
            return e->param();
        }
        if (m_config_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_config_id = "";
                    delete m_config;
                    m_config = NULL;
                    Command cmd;
                    cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdConfigure;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_config->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showConfig()));
                }
                m_config_id = "";
                return e->param();
            }
            m_config->m_search->addWidget(data);
            return e->param();
        }
    }
    if (e->type() == EventCommandExec){
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->param != this)
            return NULL;
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdSearch){
            if (m_search)
                delete m_search;
            m_search = new JabberWizard(this, I18N_NOOP("%1 Search"), "find", m_client, m_history[m_historyPos].c_str(), m_nodes[m_historyPos].c_str(), "search");
            m_search_id = m_client->get_agent_info(m_history[m_historyPos].c_str(), m_nodes[m_historyPos].c_str(), "search");
            return e->param();
        }
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdRegister){
            if (m_reg)
                delete m_reg;
            m_reg = new JabberWizard(this, I18N_NOOP("%1 Register"), "reg", m_client, m_history[m_historyPos].c_str(), m_nodes[m_historyPos].c_str(), "register");
            m_reg_id = m_client->get_agent_info(m_history[m_historyPos].c_str(), m_nodes[m_historyPos].c_str(), "register");
            return e->param();
        }
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdConfigure){
            if (m_config)
                delete m_config;
            m_config = new JabberWizard(this, I18N_NOOP("%1 Configure"), "configure", m_client, m_history[m_historyPos].c_str(), m_nodes[m_historyPos].c_str(), "data");
            m_config_id = m_client->get_agent_info(m_history[m_historyPos].c_str(), m_nodes[m_historyPos].c_str(), "data");
            return e->param();
        }
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdBack){
            if (m_historyPos){
                m_historyPos--;
                QString url  = QString::fromUtf8(m_history[m_historyPos].c_str());
                QString node;
                if (!m_nodes[m_historyPos].empty())
                    node = QString::fromUtf8(m_nodes[m_historyPos].c_str());
                go(url, node);
            }
        }
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdForward){
            if (m_historyPos + 1 < (int)(m_history.size())){
                m_historyPos++;
                QString url  = QString::fromUtf8(m_history[m_historyPos].c_str());
                QString node;
                if (!m_nodes[m_historyPos].empty())
                    node = QString::fromUtf8(m_nodes[m_historyPos].c_str());
                go(url, node);
            }
        }
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdUrl){
            if (!m_id1.empty() || !m_id2.empty()){
                stop("");
                return e->param();
            }
            QString jid;
            QString node;
            Command cmd;
            cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdUrl;
            cmd->param	= this;
            Event eWidget(EventCommandWidget, cmd);
            CToolCombo *cmbUrl = (CToolCombo*)(eWidget.process());
            if (cmbUrl)
                jid = cmbUrl->lineEdit()->text();
            cmd->id		= static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdNode;
            CToolCombo *cmbNode = (CToolCombo*)(eWidget.process());
            if (cmbNode)
                node = cmbNode->lineEdit()->text();
            if (!jid.isEmpty()){
                addHistory(jid);
                goUrl(jid, node);
            }
            return e->param();
        }
        if (cmd->id == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->CmdInfo){
            if (m_category.isEmpty() && m_type.isEmpty() && m_name.isEmpty() && m_features.isEmpty())
                return e->param();
            if (m_info == NULL)
                m_info = new DiscoInfo(this);
            m_info->reset();
            raiseWindow(m_info);
            return e->param();
        }
    }
    if (e->type() == static_cast<JabberPlugin*>(m_client->protocol()->plugin())->EventDiscoItem){
        JabberDiscoItem *item = (JabberDiscoItem*)(e->param());
        if (m_id1 == item->id){
            if (item->jid.empty()){
                m_id1 = "";
                m_list->adjustColumn();
                QString err;
                if (!item->name.empty()){
                    err = QString::fromUtf8(item->name.c_str());
                }else if (!item->node.empty()){
                    err = i18n("Error %1") .arg(atol(item->node.c_str()));
                }
                if (err.isEmpty() || m_id2.empty())
                    stop(err);
                return e->param();
            }
            QListViewItem *i = new QListViewItem(m_list);
            i->setText(COL_JID, QString::fromUtf8(item->jid.c_str()));
            i->setText(COL_NAME, QString::fromUtf8(item->name.c_str()));
            i->setText(COL_NODE, QString::fromUtf8(item->node.c_str()));
            return e->param();
        }
        if (m_id2 == item->id){
            if (item->jid.empty()){
                m_id2 = "";
                m_list->adjustColumn();
                QString err;
                if (!item->name.empty()){
                    err = QString::fromUtf8(item->name.c_str());
                }else if (!item->node.empty()){
                    err = i18n("Error %1") .arg(atol(item->node.c_str()));
                }
                if (m_id1.empty())
                    stop(err);
                return e->param();
            }
            if (item->jid == "feature"){
                if (!m_features.isEmpty())
                    m_features += "\n";
                m_features += QString::fromUtf8(item->name.c_str());
            }else{
                m_category = QString::fromUtf8(item->jid.c_str());
                m_type	   = QString::fromUtf8(item->node.c_str());
                m_name	   = QString::fromUtf8(item->name.c_str());
            }
            return e->param();
        }
    }
    return NULL;
}
Esempio n. 11
0
void QtSystray::setTrayMenu() {
	_trayMenu->clear();

	//openAction
#if defined(OS_MACOSX)
	// On Mac OS X, clicking the Dock icon should show the application thus the
	// 'Open WengoPhone' entry is not necessary. We get the Dock Icon click event
	// from our QtMacApplication class.
	QtMacApplication * qMacApp = dynamic_cast<QtMacApplication *>(QApplication::instance());
	SAFE_CONNECT_RECEIVER(qMacApp, SIGNAL(applicationMustShow()), _qtWengoPhone->getWidget(), SLOT(show()));
#endif
	_startNew = new QMenu(tr("Start New"));
	
	_newCall = new QAction(tr("Call"), _startNew);
	_newConference = new QAction(tr("Conference Call"), _startNew);
	//_newInstantMessage = new QMenu(tr("Instant Message"));
	_newInstantMessage = new QAction(tr("Instant Message"), _startNew);
	_newGroupChat = new QAction(tr("Group Chat"), _startNew);
	_newTextMessage = new QAction(tr("Text Message"), _startNew);
	_newGroupTextMessage = new QAction(tr("Group Text Message"), _startNew);
	_newEmail = new QAction(tr("Email"), _startNew);
	_newGroupEmail = new QAction(tr("Group Email"), _startNew);
	_newSendFile = new QAction(tr("Send File"), _startNew);
	_newSendFax = new QAction(tr("Send Fax"), _startNew);

	SAFE_CONNECT_RECEIVER(_newCall, SIGNAL(triggered()), _qtToolBar, SLOT(showKeyTab()));
	SAFE_CONNECT_RECEIVER(_newConference, SIGNAL(triggered()), _qtToolBar, SLOT(createConferenceCall()));
	/*_newInstantMessage->clear();
	SAFE_CONNECT(_newInstantMessage, SIGNAL(triggered(QAction *)), SLOT(startChat(QAction *)));
	QtContactMenu::populateChatMenu(_newInstantMessage, _qtWengoPhone->getCWengoPhone());*/
	_newInstantMessage->setDisabled(true);
	_newGroupChat->setDisabled(true);
	_newTextMessage->setDisabled(true);
	_newGroupTextMessage->setDisabled(true);
	_newEmail->setDisabled(true);
	_newGroupEmail->setDisabled(true);
	_newSendFile->setDisabled(true);
	_newSendFax->setDisabled(true);
	
	_startNew->addAction(_newCall);
	_startNew->addAction(_newConference);
	_startNew->addAction(_newInstantMessage);
	//_startNew->addMenu(_newInstantMessage);
	_startNew->addAction(_newGroupChat);
	_startNew->addAction(_newTextMessage);
	_startNew->addAction(_newGroupTextMessage);
	_startNew->addAction(_newEmail);
	_startNew->addAction(_newGroupEmail);
	_startNew->addAction(_newSendFile);
	_startNew->addAction(_newSendFax);	

	_recentContacts = new QMenu(tr("Recent Contacts"));
	_viewConversations = new QAction(tr("View Conversations"), _trayMenu);
	_showContactList = new QAction(tr("Show Contact List"), _trayMenu);
	_settings = new QAction(tr("Settings"), _trayMenu);
	_signOut = new QAction(tr("Sign Out"), _trayMenu);
	_quit = new QAction(tr("Quit @product@"), _trayMenu);
	
	_recentContacts->setDisabled(true);
	SAFE_CONNECT_RECEIVER(_viewConversations, SIGNAL(triggered()), _qtToolBar, SLOT(showHistory()));
	SAFE_CONNECT_RECEIVER(_showContactList, SIGNAL(triggered()), _qtToolBar, SLOT(showContactsTab()));
	SAFE_CONNECT_RECEIVER(_settings, SIGNAL(triggered()), _qtToolBar, SLOT(showConfig()));
//	SAFE_CONNECT_RECEIVER(_signOut, SIGNAL(triggered()), _qtToolBar, SLOT(logOff()));
//	SAFE_CONNECT_RECEIVER(_quit, SIGNAL(triggered()), _qtWengoPhone, SLOT(prepareToExitApplication()));	
	SAFE_CONNECT_RECEIVER(_signOut, SIGNAL(triggered()), _qtWengoPhone, SLOT(logOff()));					//VOXOX - JRT - 2009.07.13 
	SAFE_CONNECT_RECEIVER(_quit,	SIGNAL(triggered()), _qtWengoPhone, SLOT(exitApplication()));			//VOXOX - JRT - 2009.07.13 
	
	if(!_qtToolBar->getUserIsLogged()){
		_startNew->setDisabled(true);
		_viewConversations->setDisabled(true);
		_showContactList->setDisabled(true);
		_settings->setDisabled(true);
		_signOut->setDisabled(true);
	}

	_trayMenu->addMenu(_startNew);
	_trayMenu->addMenu(_recentContacts);
	_trayMenu->addAction(_viewConversations);
	_trayMenu->addAction(_showContactList);
	if ( getCUserProfile() ) {
		_trayMenu->addMenu(createStatusMenu());
	}
	_trayMenu->addAction(_settings);
	_trayMenu->addAction(_signOut);
	_trayMenu->addAction(_quit);

	_trayIcon->setPopup(_trayMenu);
}
Esempio n. 12
0
SamView::SamView(QWidget *parent, Qt::WFlags flags) : KXmlGuiWindow(parent, flags),
  m_startCompilationAfterAdaption(false),
  m_startTestAfterCompile(false),
  m_startTestAfterAdaption(false),
  m_exportAfterTest(false),
  m_dirty(false),
  m_creationCorpus(0),
  m_reportParameters(0),
  modelCompiler(0),
  modelCompilationAdapter(0),
  barGraph(0)
{
  KGlobal::locale()->insertCatalog("simonlib");
  ui.setupUi(this);
  ui.qpPlot->hide();

  barGraphLegend = new QwtLegend(ui.qpPlot);

  ui.qpPlot->insertLegend(barGraphLegend);
  #if QWT_VERSION >= 0x060100
  connect(ui.qpPlot, SIGNAL(legendDataChanged(const QVariant &, const QList<QwtLegendData>&)),
          barGraphLegend, SLOT(updateLegend(const QVariant&, const QList<QwtLegendData>&)));

  barGraphLegend->show();
  ui.qpPlot->updateLegend();
  #endif


  initGraph();

  ui.saTestConfigurations->setWidget(ui.wgTestConfigurations);

  KAction* getPathsFromSimon = new KAction(this);
  getPathsFromSimon->setText(i18n("Modify Simon's model"));
  getPathsFromSimon->setStatusTip(i18n("Manage Simon's current model with SSC"));
  getPathsFromSimon->setIcon(KIcon("simon"));
  actionCollection()->addAction("getPathsFromSimon", getPathsFromSimon);
  connect(getPathsFromSimon, SIGNAL(triggered(bool)),
          this, SLOT(getBuildPathsFromSimon()));

  KAction* recompile = new KAction(this);
  recompile->setText(i18n("Build model"));
  recompile->setStatusTip(i18n("Build the currently open model."));
  recompile->setIcon(KIcon("view-refresh"));
  recompile->setShortcut(Qt::CTRL + Qt::Key_F5);
  actionCollection()->addAction("compileModel", recompile);
  connect(recompile, SIGNAL(triggered(bool)),
          this, SLOT(compileModel()));

  KAction* test= new KAction(this);
  test->setText(i18n("Test model"));
  test->setStatusTip(i18n("Test the model."));
  test->setIcon(KIcon("chronometer"));
  actionCollection()->addAction("testModel", test);
  connect(test, SIGNAL(triggered(bool)),
          this, SLOT(testModel()));

  KAction* testResults= new KAction(this);
  testResults->setText(i18n("Test results"));
  testResults->setStatusTip(i18n("Display the test results."));
  testResults->setIcon(KIcon("view-pim-tasks"));
  actionCollection()->addAction("testResults", testResults);
  connect(testResults, SIGNAL(triggered(bool)),
          this, SLOT(switchToTestResults()));

  KAction* exportTestResults = new KAction(this);
  exportTestResults->setText(i18n("Export test result"));
  exportTestResults->setStatusTip(i18n("Export the test results to a file."));
  exportTestResults->setIcon(KIcon("document-export"));
  actionCollection()->addAction("exportTestResults", exportTestResults);
  connect(exportTestResults, SIGNAL(triggered(bool)),
          this, SLOT(exportTestResults()));

  m_user = "******";

  KStandardAction::openNew(this, SLOT(newProject()), actionCollection());
  KStandardAction::save(this, SLOT(save()), actionCollection());
  KStandardAction::saveAs(this, SLOT(saveAs()), actionCollection());
  KStandardAction::open(this, SLOT(load()), actionCollection());
  KStandardAction::preferences(this, SLOT(showConfig()), actionCollection());
  KStandardAction::quit(this, SLOT(close()), actionCollection());

  setupGUI();

  connect(ui.cbType, SIGNAL(currentIndexChanged(int)), this, SLOT(backendChanged()));

  connect(ui.pbCompileModel, SIGNAL(clicked()), this, SLOT(compileModel()));
  connect(ui.pbTestModel, SIGNAL(clicked()), this, SLOT(testModel()));


  connect(ui.pbImportRecognitionSamples, SIGNAL(clicked()), this, SLOT(importRecognitionSamples()));
  connect(ui.rbDynamicModel, SIGNAL(toggled(bool)), this, SLOT(setDirty()));
  connect(ui.rbStaticModel, SIGNAL(toggled(bool)), this, SLOT(setDirty()));

  connect(ui.urOutputModel, SIGNAL(textChanged(QString)), this, SLOT(setDirty()));
  connect(ui.urPromptsBasePath, SIGNAL(textChanged(QString)), this, SLOT(setDirty()));
  connect(ui.urLexicon, SIGNAL(textChanged(QString)), this, SLOT(setDirty()));
  connect(ui.urGrammar, SIGNAL(textChanged(QString)), this, SLOT(setDirty()));
  connect(ui.urVocabulary, SIGNAL(textChanged(QString)), this, SLOT(setDirty()));
  connect(ui.urPrompts, SIGNAL(textChanged(QString)), this, SLOT(setDirty()));
  connect(ui.urBaseModel, SIGNAL(textChanged(QString)), this, SLOT(setDirty()));
  connect(ui.leScriptPrefix, SIGNAL(textChanged(QString)), this, SLOT(setDirty()));
  connect(ui.sbSampleRate, SIGNAL(valueChanged(int)), this, SLOT(setDirty()));

  connect(ui.pbExtractSimonModel, SIGNAL(clicked()), this, SLOT(extractSimonModel()));

  ui.urOutputModel->setMode(KFile::File|KFile::LocalOnly);
  ui.urPromptsBasePath->setMode(KFile::Directory|KFile::ExistingOnly|KFile::LocalOnly);
  ui.urLexicon->setMode(KFile::File|KFile::ExistingOnly|KFile::LocalOnly);
  ui.urGrammar->setMode(KFile::File|KFile::ExistingOnly|KFile::LocalOnly);
  ui.urVocabulary->setMode(KFile::File|KFile::ExistingOnly|KFile::LocalOnly);
  ui.urPrompts->setMode(KFile::File|KFile::ExistingOnly|KFile::LocalOnly);
  ui.urBaseModel->setMode(KFile::File|KFile::ExistingOnly|KFile::LocalOnly);

  #ifdef BACKEND_TYPE_JHTK
    ui.cbType->removeItem(0);
    ui.swModelInputFiles->removeWidget(ui.pgSphinxInputFiles);

    if ((KCmdLineArgs::parsedArgs()->isSet("m")) && (KCmdLineArgs::parsedArgs()->getOption("m") == "sphinx")) {
      KMessageBox::sorry(this, i18n("SAM was built without SPHINX support."));
      exit(0);
    }
  #endif

  if (KCmdLineArgs::parsedArgs()->isSet("m"))
    ui.cbType->setCurrentIndex(KCmdLineArgs::parsedArgs()->getOption("m") == "htk" ? 1 : 0);

  backendChanged();

  connect(ui.pbAddTestConfiguration, SIGNAL(clicked()), this, SLOT(addTestConfiguration()));

  connect(ui.pbSerializeScenarios, SIGNAL(clicked()), this, SLOT(serializeScenarios()));
  connect(ui.pbSerializePrompts, SIGNAL(clicked()), this, SLOT(serializePrompts()));

  connect(ui.pbCancelBuildModel, SIGNAL(clicked()), this, SLOT(abortModelCompilation()));
  connect(ui.pbCancelTestModel, SIGNAL(clicked()), this, SLOT(abortModelTest()));
  connect(ui.pbSaveCompleteBuildlog, SIGNAL(clicked()), this, SLOT(storeBuildLog()));

  if (KCmdLineArgs::parsedArgs()->count() > 0)
  {
    QString loadPath = KCmdLineArgs::parsedArgs()->url(0).toLocalFile();
    kDebug() << "Load path: " << loadPath;

    if (!loadPath.isEmpty())
      load(loadPath);
  }

  bool autoTestModel = KCmdLineArgs::parsedArgs()->isSet("t");
  if (KCmdLineArgs::parsedArgs()->isSet("s"))
  {
    getBuildPathsFromSimon();
    //async
    if (KCmdLineArgs::parsedArgs()->isSet("c"))
    {
      m_startCompilationAfterAdaption = true;
      if (autoTestModel) {
        m_startTestAfterCompile = true;
      }
    } else
      if (autoTestModel) {
        m_startTestAfterAdaption = true;
      }
  } else {
    if (KCmdLineArgs::parsedArgs()->isSet("c"))
    {
      compileModel();
      if (autoTestModel)
        m_startTestAfterCompile = true;
    }
    else if (autoTestModel)
      testModel();
  }
  if (KCmdLineArgs::parsedArgs()->isSet("e"))
    m_exportAfterTest = true;
}
Esempio n. 13
0
/* ======================================================================
Function: handleFormConfig 
Purpose : handle main configuration page
Input   : -
Output  : - 
Comments: -
====================================================================== */
void handleFormConfig(void) 
{
  String response="";
  int ret ;

  LedBluON();

  // We validated config ?
  if (server.hasArg("save"))
  {
    int itemp;
    DebuglnF("===== Posted configuration"); 

    // WifInfo
    strncpy(config.ssid ,   server.arg("ssid").c_str(),     CFG_SSID_SIZE );
    strncpy(config.psk ,    server.arg("psk").c_str(),      CFG_PSK_SIZE );
    strncpy(config.host ,   server.arg("host").c_str(),     CFG_HOSTNAME_SIZE );
    strncpy(config.ap_psk , server.arg("ap_psk").c_str(),   CFG_PSK_SIZE );
    strncpy(config.ota_auth,server.arg("ota_auth").c_str(), CFG_PSK_SIZE );
    itemp = server.arg("ota_port").toInt();
    config.ota_port = (itemp>=0 && itemp<=65535) ? itemp : DEFAULT_OTA_PORT ;

    // Emoncms
    strncpy(config.emoncms.host,   server.arg("emon_host").c_str(),  CFG_EMON_HOST_SIZE );
    strncpy(config.emoncms.url,    server.arg("emon_url").c_str(),   CFG_EMON_URL_SIZE );
    strncpy(config.emoncms.apikey, server.arg("emon_apikey").c_str(),CFG_EMON_APIKEY_SIZE );
    itemp = server.arg("emon_node").toInt();
    config.emoncms.node = (itemp>=0 && itemp<=255) ? itemp : 0 ;
    itemp = server.arg("emon_port").toInt();
    config.emoncms.port = (itemp>=0 && itemp<=65535) ? itemp : CFG_EMON_DEFAULT_PORT ; 
    itemp = server.arg("emon_freq").toInt();
    if (itemp>0 && itemp<=86400){
      // Emoncms Update if needed
      Tick_emoncms.detach();
      Tick_emoncms.attach(itemp, Task_emoncms);
    } else {
      itemp = 0 ; 
    }
    config.emoncms.freq = itemp;

    // jeedom
    strncpy(config.jeedom.host,   server.arg("jdom_host").c_str(),  CFG_JDOM_HOST_SIZE );
    strncpy(config.jeedom.url,    server.arg("jdom_url").c_str(),   CFG_JDOM_URL_SIZE );
    strncpy(config.jeedom.apikey, server.arg("jdom_apikey").c_str(),CFG_JDOM_APIKEY_SIZE );
    strncpy(config.jeedom.adco,   server.arg("jdom_adco").c_str(),CFG_JDOM_ADCO_SIZE );
    itemp = server.arg("jdom_port").toInt();
    config.jeedom.port = (itemp>=0 && itemp<=65535) ? itemp : CFG_JDOM_DEFAULT_PORT ; 
    itemp = server.arg("jdom_freq").toInt();
    if (itemp>0 && itemp<=86400){
      // Emoncms Update if needed
      Tick_jeedom.detach();
      Tick_jeedom.attach(itemp, Task_jeedom);
    } else {
      itemp = 0 ; 
    }
    config.jeedom.freq = itemp;

    if ( saveConfig() ) {
      ret = 200;
      response = "OK";
    } else {
      ret = 412;
      response = "Unable to save configuration";
    }

    showConfig();
  }
  else
  {
    ret = 400;
    response = "Missing Form Field";
  }

  DebugF("Sending response "); 
  Debug(ret); 
  Debug(":"); 
  Debugln(response); 
  server.send ( ret, "text/plain", response);
  LedBluOFF();
}
void parseCmdLine(int arg_num, char *arg_vet[])
{
    if (arg_num == 1)
	cout <<
	    "Running with default parameters (use '-help' option to see how to override them)"
	    << endl;
    else {
	for (int i = 1; i < arg_num; i++) {
	    if (!strcmp(arg_vet[i], "-help")) {
		showHelp(arg_vet[0]);
		exit(0);
	    } else if (!strcmp(arg_vet[i], "-verbose"))
		NoximGlobalParams::verbose_mode = atoi(arg_vet[++i]);
	    else if (!strcmp(arg_vet[i], "-trace")) {
		NoximGlobalParams::trace_mode = true;
		strcpy(NoximGlobalParams::trace_filename, arg_vet[++i]);
	    } else if (!strcmp(arg_vet[i], "-dimx"))
		NoximGlobalParams::mesh_dim_x = atoi(arg_vet[++i]);
	    else if (!strcmp(arg_vet[i], "-dimy"))
		NoximGlobalParams::mesh_dim_y = atoi(arg_vet[++i]);
	    else if (!strcmp(arg_vet[i], "-buffer"))
		NoximGlobalParams::buffer_depth = atoi(arg_vet[++i]);
	    else if (!strcmp(arg_vet[i], "-size")) {
		NoximGlobalParams::min_packet_size = atoi(arg_vet[++i]);
		NoximGlobalParams::max_packet_size = atoi(arg_vet[++i]);
	    } else if (!strcmp(arg_vet[i], "-routing")) {
		char *routing = arg_vet[++i];
		if (!strcmp(routing, "xy"))
		    NoximGlobalParams::routing_algorithm = ROUTING_XY;
		else if (!strcmp(routing, "westfirst"))
		    NoximGlobalParams::routing_algorithm =
			ROUTING_WEST_FIRST;
		else if (!strcmp(routing, "northlast"))
		    NoximGlobalParams::routing_algorithm =
			ROUTING_NORTH_LAST;
		else if (!strcmp(routing, "negativefirst"))
		    NoximGlobalParams::routing_algorithm =
			ROUTING_NEGATIVE_FIRST;
		else if (!strcmp(routing, "oddeven"))
		    NoximGlobalParams::routing_algorithm =
			ROUTING_ODD_EVEN;
		else if (!strcmp(routing, "dyad")) {
		    NoximGlobalParams::routing_algorithm = ROUTING_DYAD;
		    NoximGlobalParams::dyad_threshold = atof(arg_vet[++i]);
		} else if (!strcmp(routing, "fullyadaptive"))
		    NoximGlobalParams::routing_algorithm =
			ROUTING_FULLY_ADAPTIVE;
		else if (!strcmp(routing, "table")) {
		    NoximGlobalParams::routing_algorithm =
			ROUTING_TABLE_BASED;
		    strcpy(NoximGlobalParams::routing_table_filename,
			   arg_vet[++i]);
		    NoximGlobalParams::packet_injection_rate = 0;	// ??? why ???
		} 
                    else if (!strcmp(routing, "custom"))                             //custom routing
		    NoximGlobalParams::routing_algorithm = ROUTING_CUSTOM;           //------do------ 
		    else
		    NoximGlobalParams::routing_algorithm = INVALID_ROUTING;
	    } else if (!strcmp(arg_vet[i], "-sel")) {
		char *selection = arg_vet[++i];
		if (!strcmp(selection, "random"))
		    NoximGlobalParams::selection_strategy = SEL_RANDOM;
		else if (!strcmp(selection, "bufferlevel"))
		    NoximGlobalParams::selection_strategy =
			SEL_BUFFER_LEVEL;
		else if (!strcmp(selection, "nop"))
		    NoximGlobalParams::selection_strategy = SEL_NOP;
		else
		    NoximGlobalParams::selection_strategy =
			INVALID_SELECTION;
	    } else if (!strcmp(arg_vet[i], "-pir")) {
		NoximGlobalParams::packet_injection_rate =
		    atof(arg_vet[++i]);
		char *distribution = arg_vet[++i];
		if (!strcmp(distribution, "poisson"))
		    NoximGlobalParams::probability_of_retransmission =
			NoximGlobalParams::packet_injection_rate;
		else if (!strcmp(distribution, "burst")) {
		    float burstness = atof(arg_vet[++i]);
		    NoximGlobalParams::probability_of_retransmission =
			NoximGlobalParams::packet_injection_rate / (1 -
								    burstness);
		} else if (!strcmp(distribution, "pareto")) {
		    float Aon = atof(arg_vet[++i]);
		    float Aoff = atof(arg_vet[++i]);
		    float r = atof(arg_vet[++i]);
		    NoximGlobalParams::probability_of_retransmission =
			NoximGlobalParams::packet_injection_rate *
			pow((1 - r), (1 / Aoff - 1 / Aon));
		} else if (!strcmp(distribution, "custom"))
		    NoximGlobalParams::probability_of_retransmission =
			atof(arg_vet[++i]);
	    } else if (!strcmp(arg_vet[i], "-traffic")) {
		char *traffic = arg_vet[++i];
		if (!strcmp(traffic, "random"))
		    NoximGlobalParams::traffic_distribution =
			TRAFFIC_RANDOM;
		else if (!strcmp(traffic, "transpose1"))
		    NoximGlobalParams::traffic_distribution =
			TRAFFIC_TRANSPOSE1;
		else if (!strcmp(traffic, "transpose2"))
		    NoximGlobalParams::traffic_distribution =
			TRAFFIC_TRANSPOSE2;
		else if (!strcmp(traffic, "bitreversal"))
		    NoximGlobalParams::traffic_distribution =
			TRAFFIC_BIT_REVERSAL;
		else if (!strcmp(traffic, "butterfly"))
		    NoximGlobalParams::traffic_distribution =
			TRAFFIC_BUTTERFLY;
		else if (!strcmp(traffic, "shuffle"))
		    NoximGlobalParams::traffic_distribution =
			TRAFFIC_SHUFFLE;
		else if (!strcmp(traffic, "table")) {
		    NoximGlobalParams::traffic_distribution =
			TRAFFIC_TABLE_BASED;
		    strcpy(NoximGlobalParams::traffic_table_filename,
			   arg_vet[++i]);
		} else
		    NoximGlobalParams::traffic_distribution =
			INVALID_TRAFFIC;
	    } else if (!strcmp(arg_vet[i], "-hs")) {
		int node = atoi(arg_vet[++i]);
		double percentage = atof(arg_vet[++i]);
		pair < int, double >t(node, percentage);
		NoximGlobalParams::hotspots.push_back(t);
	    } else if (!strcmp(arg_vet[i], "-warmup"))
		NoximGlobalParams::stats_warm_up_time = atoi(arg_vet[++i]);
	    else if (!strcmp(arg_vet[i], "-seed"))
		NoximGlobalParams::rnd_generator_seed = atoi(arg_vet[++i]);
 	    else if (!strcmp(arg_vet[i], "-detailed"))
		NoximGlobalParams::detailed = true;
	    else if (!strcmp(arg_vet[i], "-show_buf_stats"))
		NoximGlobalParams::show_buffer_stats = true;
	    else if (!strcmp(arg_vet[i], "-volume"))
		NoximGlobalParams::max_volume_to_be_drained =
		    atoi(arg_vet[++i]);
	    else if (!strcmp(arg_vet[i], "-sim"))
		NoximGlobalParams::simulation_time = atoi(arg_vet[++i]);
	    else if (!strcmp(arg_vet[i], "-pwr"))
	      strcpy(NoximGlobalParams::router_power_filename, arg_vet[++i]);
	    else if (!strcmp(arg_vet[i], "-lpls"))
	      NoximGlobalParams::low_power_link_strategy = true;
	    else if (!strcmp(arg_vet[i], "-qos"))
		NoximGlobalParams::qos = atof(arg_vet[++i]);
	    else {
		cerr << "Error: Invalid option: " << arg_vet[i] << endl;
		exit(1);
	    }
	}
    }

    checkInputParameters();

    // Show configuration
    if (NoximGlobalParams::verbose_mode > VERBOSE_OFF)
	showConfig();
}
Esempio n. 15
0
int main(int argc, char *argv[]){

	configuration_t *conf = clparser(argc, argv);
	wav_t newCarrier;


	wav_t carrierFile;
	dataHolder_t carrierData;

	if(conf != NULL)
		showConfig(conf);
	checkConfig(&conf);
	if(conf != NULL) {
		LOG("opening carrier file: %s\n", conf->carrierFile);
		carrierFile = newWavFromFile(conf->carrierFile);
		carrierData = wavGetData(carrierFile);

		if(conf->embed == steg_embed){
			fileContainer_t payload;
			char *ext = NULL;
			dataHolder_t payloadRawHolder, resultPayload;
			FCRead(conf->sourceFile, &payload);

			//Embeding
			if(conf->encriptation == NULL){
				//Embeding without encryptation.
				resultPayload.data = payload.rawData;
				resultPayload.size = payload.size;
				ext = payload.extension;
			} else {
				//Embeding with encryptation.
				typeConvertFCtoDH(&payload, &payloadRawHolder);
				crypto_Execute(*conf->encriptation, payloadRawHolder, &resultPayload);
				ext = NULL;
			}

			stegEmbed(&carrierData, &resultPayload, conf->stegMode, ext);
			newCarrier = newWavFromData(wavGetFMT(carrierFile), carrierData);
			wavWriteToFile(newCarrier, conf->targetFile);

		} else {
			fileContainer_t resultPayloadFile;
			dataHolder_t payloadData;
			if(conf->encriptation == NULL){
				LOG("extracting without decryption\n");
				//Extracting without decription
				stegExtract(&carrierData, &payloadData, conf->stegMode, resultPayloadFile.extension);

				resultPayloadFile.rawData = payloadData.data;
				resultPayloadFile.size = payloadData.size;
				LOG("got payload file size: %d, and extention %s\n", resultPayloadFile.size, resultPayloadFile.extension);
			} else {
				//Extracting with decription
				LOG("extrating with encryption\n");
				dataHolder_t cipherPayload;
				stegExtract(&carrierData, &cipherPayload, conf->stegMode, NULL);
				LOG("extracted cipherPayload({%d,%p})\n",cipherPayload.size, cipherPayload.data);
				crypto_Execute(*conf->encriptation, cipherPayload, &payloadData);
				typeConvertDHtoFC(&resultPayloadFile, &payloadData);
			}

			FCWrite(conf->targetFile, &resultPayloadFile);
		}

	} else {
		printf("user -h for help\n");
	}

	return 0;
}
Esempio n. 16
0
void *JabberBrowser::processEvent(Event *e)
{
    if (e->type() == EventAgentInfo){
        JabberAgentInfo *data = (JabberAgentInfo*)(e->param());
        if (m_search_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_search_id = "";
                    Command cmd;
                    cmd->id		= CmdBrowseSearch;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                    delete m_search;
                }else{
                    m_search->jidSearch->addWidget(data);
                    connect(this, SIGNAL(addSearch(QWidget*, Client*, const QString&)), topLevelWidget(), SLOT(addSearch(QWidget*, Client*, const QString&)));
                    emit addSearch(m_search, m_client, m_search->m_jid);
                    disconnect(this, SIGNAL(addSearch(QWidget*, Client*, const QString&)), topLevelWidget(), SLOT(addSearch(QWidget*, Client*, const QString&)));
                }
                m_search_id = "";
                m_search    = NULL;
                return e->param();
            }
            m_search->jidSearch->addWidget(data);
            return e->param();
        }
        if (m_reg_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_reg_id = "";
                    delete m_reg;
                    m_reg = NULL;
                    Command cmd;
                    cmd->id		= CmdRegister;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_reg->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showReg()));
                }
                m_reg_id = "";
                return e->param();
            }
            m_reg->m_search->addWidget(data);
            return e->param();
        }
        if (m_config_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_config_id = "";
                    delete m_config;
                    m_config = NULL;
                    Command cmd;
                    cmd->id		= CmdBrowseConfigure;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_config->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showConfig()));
                }
                m_config_id = "";
                return e->param();
            }
            m_config->m_search->addWidget(data);
            return e->param();
        }
    }
Esempio n. 17
0
void *JabberBrowser::processEvent(Event *e)
{
    if (e->type() == EventAgentInfo){
        JabberAgentInfo *data = (JabberAgentInfo*)(e->param());
        if (m_search_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_search_id = "";
                    delete m_search;
                    m_search = NULL;
                    Command cmd;
                    cmd->id		= CmdBrowseSearch;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_search->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showSearch()));
                }
                m_search_id = "";
                return e->param();
            }
            m_search->m_search->addWidget(data);
            return e->param();
        }
        if (m_reg_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_reg_id = "";
                    delete m_reg;
                    m_reg = NULL;
                    Command cmd;
                    cmd->id		= CmdRegister;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_reg->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showReg()));
                }
                m_reg_id = "";
                return e->param();
            }
            m_reg->m_search->addWidget(data);
            return e->param();
        }
        if (m_config_id == data->ReqID.ptr){
            if (data->Type.ptr == NULL){
                if (data->nOptions.value){
                    QString err;
                    if (data->Label.ptr && *data->Label.ptr)
                        err = i18n(data->Label.ptr);
                    if (err.isEmpty())
                        err = i18n("Error %1") .arg(data->nOptions.value);
                    m_config_id = "";
                    delete m_config;
                    m_config = NULL;
                    Command cmd;
                    cmd->id		= CmdBrowseConfigure;
                    cmd->param	= this;
                    Event eWidget(EventCommandWidget, cmd);
                    QWidget *parent = (QWidget*)(eWidget.process());
                    if (parent == NULL)
                        parent = this;
                    BalloonMsg::message(err, parent);
                }else{
                    m_config->m_search->addWidget(data);
                    QTimer::singleShot(0, this, SLOT(showConfig()));
                }
                m_config_id = "";
                return e->param();
            }
            m_config->m_search->addWidget(data);
            return e->param();
        }
    }
    if (e->type() == EventCheckState){
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->param != this)
            return NULL;
        if (cmd->menu_id != MenuBrowser)
            return NULL;
        cmd->flags &= ~COMMAND_CHECKED;
        switch (cmd->id){
        case CmdOneLevel:
            if (!m_client->getAllLevels())
                cmd->flags |= COMMAND_CHECKED;
            return e->param();
        case CmdAllLevels:
            if (m_client->getAllLevels())
                cmd->flags |= COMMAND_CHECKED;
            return e->param();
        case CmdModeDisco:
            if (m_client->getBrowseType() & BROWSE_DISCO)
                cmd->flags |= COMMAND_CHECKED;
            return e->param();
        case CmdModeBrowse:
            if (m_client->getBrowseType() & BROWSE_BROWSE)
                cmd->flags |= COMMAND_CHECKED;
            return e->param();
        case CmdModeAgents:
            if (m_client->getBrowseType() & BROWSE_AGENTS)
                cmd->flags |= COMMAND_CHECKED;
            return e->param();
        }
    }
    if (e->type() == EventCommandExec){
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->param != this)
            return NULL;
        QListViewItem *item = m_list->currentItem();
        if (cmd->menu_id == MenuBrowser){
            cmd->flags &= ~COMMAND_CHECKED;
            unsigned mode = m_client->getBrowseType();
            switch (cmd->id){
            case CmdOneLevel:
                m_client->setAllLevels(false);
				changeMode();
                return e->param();
            case CmdAllLevels:
                m_client->setAllLevels(true);
				changeMode();
                return e->param();
            case CmdModeDisco:
				mode ^= BROWSE_DISCO;
                m_client->setBrowseType(mode);
				changeMode();
                return e->param();
            case CmdModeBrowse:
				mode ^= BROWSE_BROWSE;
                m_client->setBrowseType(mode);
				changeMode();
                return e->param();
            case CmdModeAgents:
				mode ^= BROWSE_AGENTS;
                m_client->setBrowseType(mode);
				changeMode();
                return e->param();
            }
            return NULL;
        }
        if (item){
            if (cmd->id == CmdBrowseSearch){
                if (m_search)
                    delete m_search;
                m_search = new JabberWizard(this, i18n("%1 Search") .arg(item->text(COL_NAME).utf8()), "find", m_client, item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "search");
                m_search_id = m_client->get_agent_info(item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "search");
                return e->param();
            }
            if (cmd->id == CmdRegister){
                if (m_reg)
                    delete m_reg;
                m_reg = new JabberWizard(this, i18n("%1 Register") .arg(item->text(COL_NAME).utf8()), "reg", m_client, item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "register");
                m_reg_id = m_client->get_agent_info(item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "register");
                return e->param();
            }
            if (cmd->id == CmdBrowseConfigure){
                if (m_config)
                    delete m_config;
                m_config = new JabberWizard(this, i18n("%1 Configure") .arg(item->text(COL_NAME).utf8()), "configure", m_client, item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "data");
                m_config_id = m_client->get_agent_info(item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "data");
                return e->param();
            }
            if (cmd->id == CmdBrowseInfo){
                if (m_info == NULL)
                    m_info = new DiscoInfo(this, m_list->currentItem()->text(COL_FEATURES), item->text(COL_NAME), item->text(COL_TYPE), item->text(COL_CATEGORY));
                m_info->reset();
                raiseWindow(m_info);
                return e->param();
            }
        }
        if (cmd->id == CmdBack){
            if (m_historyPos){
                m_historyPos--;
                QString url  = QString::fromUtf8(m_history[m_historyPos].c_str());
                QString node;
                if (!m_nodes[m_historyPos].empty())
                    node = QString::fromUtf8(m_nodes[m_historyPos].c_str());
                go(url, node);
            }
        }
        if (cmd->id == CmdForward){
            if (m_historyPos + 1 < (int)(m_history.size())){
                m_historyPos++;
                QString url  = QString::fromUtf8(m_history[m_historyPos].c_str());
                QString node;
                if (!m_nodes[m_historyPos].empty())
                    node = QString::fromUtf8(m_nodes[m_historyPos].c_str());
                go(url, node);
            }
        }
        if (cmd->id == CmdUrl){
            if (m_bInProcess){
                stop("");
                return e->param();
            }
            QString jid;
            QString node;
            Command cmd;
            cmd->id		= CmdUrl;
            cmd->param	= this;
            Event eWidget(EventCommandWidget, cmd);
            CToolCombo *cmbUrl = (CToolCombo*)(eWidget.process());
            if (cmbUrl)
                jid = cmbUrl->lineEdit()->text();
            cmd->id		= CmdNode;
            CToolCombo *cmbNode = (CToolCombo*)(eWidget.process());
            if (cmbNode)
                node = cmbNode->lineEdit()->text();
            if (!jid.isEmpty()){
                addHistory(jid);
                goUrl(jid, node);
            }
            return e->param();
        }
    }
    if (e->type() == EventDiscoItem){
        if (!m_bInProcess)
            return NULL;
        DiscoItem *item = (DiscoItem*)(e->param());
        QListViewItem *it = findItem(COL_ID_DISCO_ITEMS, item->id.c_str());
        if (it){
            if (item->jid.empty()){
                it->setText(COL_ID_DISCO_ITEMS, "");
                if (it != m_list->firstChild()){
                    checkDone();
                    adjustColumn(it);
                    return e->param();
                }
                QString err;
                if (!item->name.empty()){
                    err = QString::fromUtf8(item->name.c_str());
                }else if (!item->node.empty()){
                    err = i18n("Error %1") .arg(atol(item->node.c_str()));
                }
                if (!err.isEmpty()){
					unsigned mode = atol(it->text(COL_MODE).latin1());
					if (((mode & BROWSE_BROWSE) == 0) || (it->text(COL_ID_BROWSE).isEmpty() & m_bError))
                        stop(err);
                    m_bError = true;
                }
                checkDone();
                adjustColumn(it);
                return e->param();
            }
            if (it->firstChild() == NULL){
                it->setExpandable(true);
						if ((it == m_list->firstChild()) || (it == m_list->currentItem()))
							it->setOpen(true);
            }
            QListViewItem *i;
            for (i = it->firstChild(); i; i = i->nextSibling()){
                if ((i->text(COL_JID) == QString::fromUtf8(item->jid.c_str())) &&
                        (i->text(COL_NODE) == QString::fromUtf8(item->node.c_str())))
                    return e->param();
            }
            i = new QListViewItem(it);
            i->setText(COL_JID, QString::fromUtf8(item->jid.c_str()));
            i->setText(COL_NAME, item->name.empty() ? QString::fromUtf8(item->jid.c_str()) : QString::fromUtf8(item->name.c_str()));
            i->setText(COL_NODE, QString::fromUtf8(item->node.c_str()));
            int mode = 0;
            if (m_client->getBrowseType() & BROWSE_DISCO){
                i->setText(COL_ID_DISCO_INFO, m_client->discoInfo(item->jid.c_str(), item->node.c_str()).c_str());
                mode |= BROWSE_INFO;
            }
            i->setText(COL_MODE, QString::number(mode));
			if (m_client->getAllLevels())
				loadItem(i);
            return e->param();
        }
        it = findItem(COL_ID_DISCO_INFO, item->id.c_str());
        if (it){
            if (item->jid.empty()){
                it->setText(COL_ID_DISCO_INFO, "");
                checkDone();
                adjustColumn(it);
                return e->param();
            }
            if (it->text(COL_NAME) == it->text(COL_JID))
                it->setText(COL_NAME, QString::fromUtf8(item->name.c_str()));
            it->setText(COL_CATEGORY, QString::fromUtf8(item->category.c_str()));
            it->setText(COL_TYPE, QString::fromUtf8(item->type.c_str()));
            it->setText(COL_FEATURES, QString::fromUtf8(item->features.c_str()));
            if ((m_client->getAllLevels()) || (it == m_list->currentItem()))
				loadItem(it);
            setItemPict(it);
            if (it == m_list->currentItem())
                currentChanged(it);
            return e->param();
        }
        it = findItem(COL_ID_BROWSE, item->id.c_str());
        if (it){
            if (item->jid.empty()){
                it->setText(COL_ID_BROWSE, "");
                if (it != m_list->firstChild()){
                    checkDone();
                    adjustColumn(it);
                    return e->param();
                }
                    QString err;
                    if (!item->name.empty()){
                        err = QString::fromUtf8(item->name.c_str());
                    }else if (!item->node.empty()){
                        err = i18n("Error %1") .arg(atol(item->node.c_str()));
                    }
                if (!err.isEmpty()){
					unsigned mode = atol(it->text(COL_MODE).latin1());
					if (((mode & BROWSE_DISCO) == 0) || (it->text(COL_ID_DISCO_ITEMS).isEmpty() & m_bError))
                        stop(err);
                    m_bError = true;
                }
                checkDone();
				adjustColumn(it);
                return e->param();
            }
            if (it->text(COL_JID) != QString::fromUtf8(item->jid.c_str())){
                QListViewItem *i;
                for (i = it->firstChild(); i; i = i->nextSibling()){
                    if ((i->text(COL_JID) == QString::fromUtf8(item->jid.c_str())) &&
                            (i->text(COL_NODE) == QString::fromUtf8(item->node.c_str())))
                        break;
                }
                if (i){
                    it = i;
                }else{
					if (it->firstChild() == NULL){
						it->setExpandable(true);
						if ((it == m_list->firstChild()) || (it == m_list->currentItem()))
							it->setOpen(true);
					}
                    it = new QListViewItem(it);
                    it->setText(COL_JID, QString::fromUtf8(item->jid.c_str()));
                    if (m_client->getAllLevels())
						loadItem(it);
                }
            }
            if (it->text(COL_NAME) == it->text(COL_JID))
                it->setText(COL_NAME, QString::fromUtf8(item->name.c_str()));
            it->setText(COL_CATEGORY, QString::fromUtf8(item->category.c_str()));
            it->setText(COL_TYPE, QString::fromUtf8(item->type.c_str()));
            it->setText(COL_FEATURES, QString::fromUtf8(item->features.c_str()));
            if (m_client->getAllLevels() || (it == m_list->currentItem()))
				loadItem(it);
            setItemPict(it);
            return e->param();
        }
    }
    return NULL;
}