Exemple #1
0
VOID WmKeydown(WPARAM VKey)
{
	TooltipHide(-1);
	if (Interruptable) {
		extern BOOL EscapeInput;

		#if defined(WIN32)
			if (VKey == VK_PAUSE) {
				if (VKey == VK_SCROLL) XOffState = GetKeyState(VK_SCROLL) & 1;
				else XOffState ^= TRUE;
				if (XOffState) NewStatus(1, L"Hold", NS_NORMAL);
				else {
					NewStatus(1, L"", NS_NORMAL);
					ReleaseXOff();
				}
			}
		#endif
		if (VKey == VK_CANCEL && GetKeyState(VK_CONTROL) < 0) {
			/*cancel button in search and replace dialogbox (?)*/
			#if defined(WIN32)
				ExecInterrupt(CTRL_BREAK_EVENT);
			#endif
			Interrupted	= TRUE;
			return;
		}
		if (Disabled && VKey != VK_NUMLOCK && VKey != VK_CAPITAL &&
						VKey != VK_SHIFT   && VKey != VK_CONTROL) {
			if (!EscapeInput && (VKey != 'C' || GetKeyState(VK_CONTROL) >= 0))
				MessageBeep(MB_OK);
				/*...a ctrl+c message beep will be generated later*/
			return;
		} else if (VKey=='C' || VKey=='Q' || VKey=='S') return;
	}
	GotKeydown(VKey);
}
Exemple #2
0
VOID WmChar(WPARAM Char)
{	static WCHAR Hold[10];

	if (!Disabled) {
		if (Interruptable) {
			#if defined(WIN32)
				switch (Char) {
					case CTRL('s'):	XOffState = TRUE;
									LOADSTRINGW(hInst, 914, Hold, WSIZE(Hold));
									NewStatus(1, Hold, NS_NORMAL);
									break;
					case CTRL('c'):	Interrupted	= TRUE;
									ExecInterrupt(CTRL_C_EVENT);
									/*FALLTHROUGH*/
					case CTRL('q'): XOffState = FALSE;
									NewStatus(1, L"", NS_NORMAL);
									ReleaseXOff();
									break;
				}
			#endif
		} else GotChar(Char, 0);
	} else if (Char == CTRL('c'))
		#if defined(WIN32)
			Interrupted = CTRL_C_EVENT+1;
		#else
			Interrupted	= TRUE;
		#endif
}
Exemple #3
0
// Add or remove statStr to/from the stat->program string:
static void addOrRemoveStatusString(STATUSPTR stat, actionType add_or_rm,
				    char *statStr)
{
   const int MaxStat = 300;
   char tmpstr[MaxStat+1], *startOfStr = NIL;;
   if (add_or_rm == actionAdd) // action is add
   {
      numberOfStatStrings[BeforeAction] = 0;
      if (stat == NIL) NewStatus(stat);	// create a new status struct
      if (stat->program == NIL)
	 stat->program = cs(statStr); // stat->program empty: easy job!
      else if ((startOfStr = strstr(stat->program,statStr)) == NIL)
      {  // append statStr with a comma to the end of stat->program:
	 char *s = stat->program;
	 strncpy(tmpstr,s,MaxStat);
	 if (strlen(s) > 0) strncat(tmpstr,",",MaxStat);
	 strncat(tmpstr,statStr,MaxStat);
	 stat->program = (cs(tmpstr));
      }
      else
	 numberOfStatStrings[BeforeAction] = 1; // already in stat->program
      numberOfStatStrings[AfterAction] = 1;
   }
   else // action is remove
   {
      numberOfStatStrings[BeforeAction] = 0;
      if (stat != NIL && stat->program != NIL &&
	  (startOfStr = strstr(stat->program,statStr)) != NIL)
      {  // stat->program exists and contains statStr. Remove it:
	 numberOfStatStrings[BeforeAction] = 1; // remember that we had one
	 int lengthOfStr = strlen(statStr);
	 if (startOfStr > stat->program && *(startOfStr-1) == ',')
	 {  // also remove the preceeding comma:
	    startOfStr -= 1;
	    lengthOfStr += 1;
	 }
	 int j = 0;
         char *p;
	 for (p = stat->program; p<startOfStr; ++p)
	    tmpstr[j++] = *p; // copy everything before statStr
	 for (p += lengthOfStr; *p != NIL; ++p)
	    tmpstr[j++] = *p; // copy everything after statStr
	 tmpstr[j] = NIL;
	 fs(stat->program); // forget about the old stat->program
	 stat->program = cs(tmpstr); // insert new stat->program;
      }
      numberOfStatStrings[AfterAction] = 0;
   }
}
StatusNotifierButton::StatusNotifierButton(QString service, QString objectPath, ILXQtPanelPlugin* plugin, QWidget *parent)
    : QToolButton(parent),
    mMenu(NULL),
    mStatus(Passive),
    mValid(true),
    mFallbackIcon(QIcon::fromTheme("application-x-executable")),
    mPlugin(plugin)
{
    interface = new org::kde::StatusNotifierItem(service, objectPath, QDBusConnection::sessionBus(), this);

    QString menuPath = interface->menu().path();
    if (!menuPath.isEmpty())
    {
        mMenu = (new DBusMenuImporter(service, interface->menu().path(), this))->menu();
        dynamic_cast<QObject &>(*mMenu).setParent(this);
        mMenu->setObjectName(QStringLiteral("StatusNotifierMenu"));
    }

    // HACK: sni-qt creates some invalid items (like one for konversarion 1.5)
    if (interface->title().isEmpty() && interface->id().isEmpty())
        mValid = false;

    if (mValid)
    {
        newToolTip();
        refetchIcon(Active);
        refetchIcon(Passive);
        refetchIcon(NeedsAttention);
        newStatus(interface->status());
        resetIcon();

        connect(interface, SIGNAL(NewIcon()), this, SLOT(newIcon()));
        connect(interface, SIGNAL(NewOverlayIcon()), this, SLOT(newOverlayIcon()));
        connect(interface, SIGNAL(NewAttentionIcon()), this, SLOT(newAttentionIcon()));
        connect(interface, SIGNAL(NewToolTip()), this, SLOT(newToolTip()));
        connect(interface, SIGNAL(NewStatus(QString)), this, SLOT(newStatus(QString)));
    }
}
Exemple #5
0
/* * * * * * * * * 
 *
 * This routine attaches the cell denoted by 'map' into the 
 * library structure.
 * in all cases, the pointers in the map structure
 * will be set the the corresponding lbrary, function, circuit and layout.
 * If the cell (or its library, function, etc.) does not exists it will be created.
 */
void attach_map_to_lib(MAPTABLEPTR  map )

{
LIBRARYPTR
   lib;
register FUNCTIONPTR
   func;
register CIRCUITPTR
   cir;
register LAYOUTPTR
   lay;
/* long
   time(); */

if(Seadif_open == FALSE)
   {
   attach_fish_map_to_lib(map);
   return;
   }

   

/*
 * look for the library
 */
if(existslib(map->library) == FALSE || sdfreadlib(SDFLIBSTAT, map->library) == FALSE)
   { /* does not exist: make it and write.... */ 
   NewLibrary(lib);
   lib->name = canonicstring(map->library);
   lib->technology = Technologystring;
      
   NewStatus(lib->status);
   lib->status->timestamp = time(0);
   lib->status->program = canonicstring(DEFAULT_PROGRAM);
   lib->status->author = Authorstring;
   map->librarystruct = lib;
   
   if(No_sdf_write == FALSE && sdfwritelib(SDFLIBSTAT, lib) == FALSE)
      error(WARNING,"cannot write lib into seadif");
   }
else
   map->librarystruct = thislib;

/*
 * look for this function
 */
if(existsfun(map->function, map->library) == FALSE || 
   sdfreadfun(SDFFUNSTAT, map->function, map->library) == FALSE)
   { /* not found */
   NewFunction(func);
   func->name = canonicstring(map->function);
   func->type = canonicstring(DEFAULT_TYPE);
   /* no circuits yet */
   NewStatus(func->status);
   func->status->timestamp = time(0);
   func->status->program = canonicstring(DEFAULT_PROGRAM);
   func->status->author = Authorstring;

   func->next = map->librarystruct->function;
   map->librarystruct->function = func;
   
   func->library = map->librarystruct;
   map->functionstruct = func;
   
   if(No_sdf_write == FALSE  && sdfwritefun(SDFFUNSTAT, func) == FALSE)
      error(WARNING,"cannot write func into seadif");
   }
else
   map->functionstruct = thisfun;

/*
 * look for this circuit
 */
if(existscir(map->circuit, map->function, map->library) == FALSE || 
   sdfreadcir(SDFCIRSTAT, map->circuit, map->function, map->library) == FALSE)
   { /* empty */
   NewCircuit(cir);
   cir->name = canonicstring(map->circuit);
   /* no lists yet */
   NewStatus(cir->status);
   cir->status->timestamp = time(0);
   cir->status->program = canonicstring(DEFAULT_PROGRAM);
   cir->status->author = Authorstring;
   
   cir->next = map->functionstruct->circuit;
   map->functionstruct->circuit = cir;

   cir->function = map->functionstruct;
   map->circuitstruct = cir;

   if(No_sdf_write == FALSE && sdfwritecir(SDFCIRSTAT, cir) == FALSE)
      error(WARNING,"cannot write cir into seadif");
   }
else
   map->circuitstruct = thiscir;

/*
 * ready if circuit
 */
if(map->view == circuit_str)
   {
   if (map->circuitstruct->status == NIL) NewStatus(map->circuitstruct->status);
   map->circuitstruct->status->author = Authorstring;
   map->circuitstruct->status->program = canonicstring(DEFAULT_PROGRAM);
   return;
   }

 
/*
 * look for layout
 */
if(existslay(map->layout, map->circuit, map->function, map->library) == FALSE ||
   sdfreadlay(SDFLAYSTAT, map->layout, map->circuit, map->function, map->library) == FALSE)
   { 
   NewLayout(lay);
   lay->name = canonicstring(map->layout);
   NewStatus(lay->status);
   lay->status->timestamp = time(0);
   lay->status->program = canonicstring(DEFAULT_PROGRAM);
   lay->status->author = Authorstring;

   lay->next = map->circuitstruct->layout;
   map->circuitstruct->layout = lay; 

   lay->circuit = map->circuitstruct;
   map->layoutstruct = lay;

   if(No_sdf_write == FALSE && sdfwritelay(SDFLAYSTAT, lay) == FALSE)
      error(WARNING,"cannot write lay into seadif");

   }
else
   map->layoutstruct = thislay;

map->layoutstruct->status->author = Authorstring;
map->layoutstruct->status->program = canonicstring(DEFAULT_PROGRAM);
}
Exemple #6
0
/* * * * * * * * * 
 *
 * This routine attaches the cell denoted by 'map' into the 
 * LOCAL library structure (in case fish is not open).
 * in all cases, the pointers in the map structure
 * will be set the the corresponding lbrary, function, circuit and layout.
 * If the cell (or its library, function, etc.) does not exists it will be created.
 */
static void attach_fish_map_to_lib(MAPTABLEPTR  map )

{
LIBRARYPTR
   lib;
register FUNCTIONPTR
   func;
register CIRCUITPTR
   cir;
register LAYOUTPTR
   lay;
/* long
   time(); */
 
/*
 * look for SEADIF struct
 */
if(seadif == NULL)
   { /* make it */
   NewSeadif(seadif);
   NewStatus(seadif->status);
   seadif->status->timestamp = time(0);
   seadif->status->program = canonicstring(DEFAULT_PROGRAM);
   seadif->status->author = canonicstring(DEFAULT_AUTHOR);
   }

/*
 * look for the library
 */
for(lib = seadif->library; lib != NULL && 
                   lib->name != map->library; lib = lib->next)
   /* nothing */;
if(lib == NULL)     
   { /* not found */
   NewLibrary(lib);
   lib->name = canonicstring(map->library);
   lib->technology = Technologystring;
   /* no functions */
   NewStatus(lib->status);
   lib->status->timestamp = time(0);
   lib->status->program = canonicstring(DEFAULT_PROGRAM);
   lib->status->author = canonicstring(DEFAULT_AUTHOR);
   /* link */
   lib->next = seadif->library;
   seadif->library = lib;
   }

map->librarystruct = lib;

/*
 * look for this function
 */
for(func = lib->function; func != NULL && 
                          func->name != map->function; func = func->next)
   /* nothing */;
if(func == NULL)
   { /* not found */
   NewFunction(func);
   func->name = canonicstring(map->function);
   func->type = canonicstring(DEFAULT_TYPE);
   /* no circuits yet */
   NewStatus(func->status);
   func->status->timestamp = time(0);
   func->status->program = canonicstring(DEFAULT_PROGRAM);
   func->status->author = canonicstring(DEFAULT_AUTHOR);
   func->library = lib;
   func->next = lib->function;
   lib->function = func;
   }

map->functionstruct = func;

/*
 * look for this circuit
 */
for(cir = func->circuit; cir != NULL &&
                         cir->name != map->circuit; cir = cir->next)
   /* nothing */;
if(cir == NULL)
   { /* empty */
   NewCircuit(cir);
   cir->name = canonicstring(map->circuit);
   /* no lists yet */
   NewStatus(cir->status);
   cir->status->timestamp = time(0);
   cir->status->program = canonicstring(DEFAULT_PROGRAM);
   cir->status->author = canonicstring(not_in_core_str); /* not in core! */
   cir->function = func;
   cir->next = func->circuit;
   func->circuit = cir;
   }

map->circuitstruct = cir;

/*
 * ready if circuit
 */
if(map->view == circuit_str)
   return;
 
/*
 * look for layout
 */
for(lay = cir->layout; lay != NULL && 
                       lay->name != map->layout; lay = lay->next)
   /* nothing */;
if(lay == NULL)
   {
   NewLayout(lay);
   lay->name = canonicstring(map->layout);
   NewStatus(lay->status);
   lay->status->timestamp = time(0);
   lay->status->program = canonicstring(DEFAULT_PROGRAM);
   lay->status->author = canonicstring(not_in_core_str); /* not in core! */
   lay->circuit = cir;
   lay->next = cir->layout;
   cir->layout = lay;
   }

map->layoutstruct = lay;
}
Exemple #7
0
/////////////////////////////////////////////////////////////////////
// Called to start the SDR
/////////////////////////////////////////////////////////////////////
void CSdrInterface::StartSdr()
{
	m_FftBufPos = 0;

	switch(m_RadioType)
	{
		case SDRIP:
		case NETSDR:
			emit NewStatus( RUNNING );

			m_TxMsg.InitTxMsg(TYPE_HOST_SET_CITEM);
			m_TxMsg.AddCItem(CI_RX_CHAN_SETUP);
			m_TxMsg.AddParm8(m_ChannelMode);
			SendAscpMsg(&m_TxMsg);

			m_TxMsg.InitTxMsg(TYPE_HOST_SET_CITEM);
			m_TxMsg.AddCItem(CI_RX_RF_FILTER);
			m_TxMsg.AddParm8(m_Channel);
			m_TxMsg.AddParm8(CI_RX_RF_FILTER_AUTO);
			SendAscpMsg(&m_TxMsg);

			m_TxMsg.InitTxMsg(TYPE_HOST_SET_CITEM);
			m_TxMsg.AddCItem(CI_RX_AD_MODES);
			m_TxMsg.AddParm8(m_Channel);
			m_TxMsg.AddParm8(  CI_AD_MODES_DITHER | CI_AD_MODES_PGA);
			SendAscpMsg(&m_TxMsg);

			m_TxMsg.InitTxMsg(TYPE_HOST_SET_CITEM);
			m_TxMsg.AddCItem(CI_RX_SYNCIN_MODE_PARAMETERS);
			m_TxMsg.AddParm8(0);
			m_TxMsg.AddParm8(CI_RX_SYNCIN_MODE_OFF);
			SendAscpMsg(&m_TxMsg);

			m_TxMsg.InitTxMsg(TYPE_HOST_SET_CITEM);
			m_TxMsg.AddCItem(CI_RX_PULSEOUT_MODE);
			m_TxMsg.AddParm8(0);
			m_TxMsg.AddParm8(CI_PULSEOUT_MODE_OFF);
			SendAscpMsg(&m_TxMsg);

			m_TxMsg.InitTxMsg(TYPE_HOST_SET_CITEM);
			m_TxMsg.AddCItem(CI_RX_OUT_SAMPLE_RATE);
			m_TxMsg.AddParm8(0);
			m_TxMsg.AddParm32((quint32)m_SampleRate);
			SendAscpMsg(&m_TxMsg);

			m_TxMsg.InitTxMsg(TYPE_HOST_SET_CITEM);
			m_TxMsg.AddCItem(CI_RX_STATE);
			m_TxMsg.AddParm8(RX_STATE_DATACOMPLEX);
			m_TxMsg.AddParm8(RX_STATE_ON);
			if(m_SampleRate<1500000.0)
				m_TxMsg.AddParm8(MODE_CONTIGUOUS24);
			else
				m_TxMsg.AddParm8(MODE_CONTIGUOUS16);
			m_TxMsg.AddParm8(0);
			SendAscpMsg(&m_TxMsg);

			m_NCOSpurOffsetI = 0.0;		//don't need for netsdr
			m_NCOSpurOffsetQ = 0.0;
			m_NcoSpurCalActive = FALSE;
			break;
		case SDR14:
		case SDRIQ:
			emit NewStatus( RUNNING );

			m_TxMsg.InitTxMsg(TYPE_HOST_SET_CITEM);
			m_TxMsg.AddCItem(CI_RX_IF_GAIN);
			m_TxMsg.AddParm8(0);
			m_TxMsg.AddParm32(24);
			SendAscpMsg(&m_TxMsg);

			m_TxMsg.InitTxMsg(TYPE_HOST_SET_CITEM);
			m_TxMsg.AddCItem(CI_RX_STATE);
			m_TxMsg.AddParm8(RX_STATE_COMPLEX_HF);
			m_TxMsg.AddParm8(RX_STATE_ON);
			m_TxMsg.AddParm8(MODE_CONTIGUOUS16);
			m_TxMsg.AddParm8(0);
			SendAscpMsg(&m_TxMsg);
			ManageNCOSpurOffsets(CSdrInterface::NCOSPUR_CMD_STARTCAL,0,0);
			break;
	}
	SetSdrRfGain(m_RfGain);
	m_ScreenUpateFinished = TRUE;
	m_KeepAliveCounter = 0;
	//setup and start soundcard output
	if(!m_pSoundCardOut->Start(m_SoundOutIndex, m_StereoOut, m_Demodulator.GetOutputRate(), false) )
		SendIOStatus(ERROR);
//qDebug()<<"SR="<<m_SampleRate;
}
Exemple #8
0
////////////////////////////////////////////////////////////////////////
//  Called from worker thread with new ASCP message to parse from radio
//  Cannot call any QT functions since is a thread so use signals
// to inform the GUI.
////////////////////////////////////////////////////////////////////////
void CSdrInterface::ParseAscpMsg(CAscpMsg *pMsg)
{
quint16 Length;
quint32 tmp32;
	pMsg->InitRxMsg();	//initialize receive msg object for read back
	if( pMsg->GetType() == TYPE_TARG_RESP_CITEM )
	{	// Is a message from SDR in response to a request
//qDebug()<<"Msg "<<pMsg->GetCItem();
		switch(pMsg->GetCItem())
		{
			case CI_GENERAL_INTERFACE_NAME:
				m_DeviceName = (const char*)(&pMsg->Buf8[4]);
				// create radio type value from connected device string
				if("SDR-14" == m_DeviceName)
					m_RadioType = SDR14;
				else if("SDR-IQ" == m_DeviceName)
					m_RadioType = SDRIQ;
				else if("SDR-IP" == m_DeviceName)
					m_RadioType = SDRIP;
				if("NetSDR" == m_DeviceName)
					m_RadioType = NETSDR;
				break;
			case CI_GENERAL_INTERFACE_SERIALNUM:
				m_SerialNum = (const char*)(&pMsg->Buf8[4]);
				break;
			case CI_GENERAL_INTERFACE_VERSION:
				break;
			case CI_GENERAL_HARDFIRM_VERSION:
				if(pMsg->GetParm8() == 0)
				{
					m_BootRev = (float)pMsg->GetParm16()/100.0;
				}
				else
				{
					m_AppRev =(float)pMsg->GetParm16()/100.0;
					m_BandwidthIndex = -1;	//force update of sample rate logic
					emit NewInfoData();
				}
				break;
			case CI_RX_STATE:
				pMsg->GetParm8();
				if(RX_STATE_ON == pMsg->GetParm8())
				{
					emit NewStatus( RUNNING );
					m_Running = true;
				}
				else
				{
					emit NewStatus( CONNECTED );
					m_Running = false;
				}
				break;
			case CI_GENERAL_OPTIONS:
				break;
			case CI_GENERAL_SECURITY_CODE:
//qDebug()<<"security = "<<pMsg->GetParm16();
				break;
			case CI_GENERAL_STATUS_CODE:	//used as keepalive ack
				m_KeepAliveCounter = 0;
				break;
			case CI_RX_FREQUENCY:
				pMsg->GetParm8();
				tmp32 = pMsg->GetParm32();
				break;
			case CI_RX_OUT_SAMPLE_RATE:
				pMsg->GetParm8();
				m_SampleRate = (double)pMsg->GetParm32();
				break;
			case CI_GENERAL_PRODUCT_ID:
				break;
			case CI_UPDATE_MODE_PARAMS:
				break;
			default:
				break;
		}
	}
	else if( pMsg->GetType() == TYPE_TARG_RESP_CITEM_RANGE )
	{	// Is a range message from SDR
		switch( pMsg->GetCItem() )
		{
			case CI_RX_FREQUENCY:
				Length = pMsg->GetLength();
				pMsg->GetParm8();
				m_BaseFrequencyRangeMin = (quint64)pMsg->GetParm32();
				pMsg->GetParm8();
				m_BaseFrequencyRangeMax = (quint64)pMsg->GetParm32();
				pMsg->GetParm8();
				m_OptionFrequencyRangeMin = m_BaseFrequencyRangeMin;	//set option range to base range
				m_OptionFrequencyRangeMax = m_BaseFrequencyRangeMax;
				if(Length>15)
				{
					m_OptionFrequencyRangeMin = (quint64)pMsg->GetParm32();
					pMsg->GetParm8();
					m_OptionFrequencyRangeMax = (quint64)pMsg->GetParm32();
				}
//qDebug()<<"Base range"<<m_BaseFrequencyRangeMin << m_BaseFrequencyRangeMax;
//qDebug()<<"Option range"<<m_OptionFrequencyRangeMin << m_OptionFrequencyRangeMax;
				break;
			default:
				break;
		}
	}
	else if( pMsg->GetType() == TYPE_TARG_UNSOLICITED_CITEM )
	{	// Is an unsolicited message from SDR
		switch( pMsg->GetCItem() )
		{
			case CI_GENERAL_STATUS_CODE:
				if( GENERAL_STATUS_ADOVERLOAD == pMsg->GetParm8() )
					SendIOStatus(ADOVR);
				break;
			default:
				break;
		}
	}
	else if( pMsg->GetType() == TYPE_TARG_DATA_ITEM0 )
	{
	}
	else if( pMsg->GetType() == TYPE_TARG_DATA_ITEM1 )
	{
	}
	else if( pMsg->GetType() == TYPE_TARG_DATA_ITEM2 )
	{
	}
	else if( pMsg->GetType() == TYPE_TARG_DATA_ITEM3 )
	{
	}
	else if(pMsg->GetType() == TYPE_DATA_ITEM_ACK)
	{
		switch(pMsg->Buf8[2])
		{	//decode Data acks
			case 0:		//NetSDR and SDRIP keepalive ack
				break;
			case 1: 	//ack of AD6620 load so ok to send next msg if any left to send
				if( m_AD6620.GetNext6620Msg(m_TxMsg) )
					SendAscpMsg(&m_TxMsg);
				else
					qDebug()<<"AD6620 Load Complete";
				break;
			case 2:
				break;
			case 3:
				break;
		}
	}
}
Exemple #9
0
///////////////////////////////////////////////////////////////////////////////
// sends signal to indicate network/radio connection status
///////////////////////////////////////////////////////////////////////////////
void CSdrInterface::SendIOStatus(int iostatus)
{
	m_Status = (eStatus)iostatus;
	emit NewStatus( iostatus );
}