Exemple #1
0
Client::Client(QString name)
{
    this->name=name;
    socket = new QTcpSocket(this);
    connect(socket, SIGNAL(readyRead()), this, SLOT(readyRead()));
    connect(socket, SIGNAL(connected()), this, SIGNAL(Connected()));
    connect(socket, SIGNAL(connected()), this, SLOT(SendUsernameToServer()));
    connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SIGNAL(ConnectionFailed()));
	connect(socket,SIGNAL(disconnected()),this,SIGNAL(Disconnected()));
}
Exemple #2
0
/** Loop through all objects and check their topology.  */
void
run_topology(void)
{
    int ndone;
    for (ndone = 0; ndone < db_top; ndone++) {
        if (!IsGarbage(ndone) && Connected(Owner(ndone)) && !NoWarn(Owner(ndone))) {
            check_topology_on(Owner(ndone), ndone);
        }
    }
}
IP_Connection::IP_Connection(QObject *parent) :
    QObject(parent)
{
    IP_Init();

    connect(socket, SIGNAL(connected()), this, SIGNAL(Connected()));
    connect(socket, SIGNAL(disconnected()), this, SIGNAL(Disconnected()));
    connect(socket, SIGNAL(disconnected()), this, SLOT(sdisconnected()));
    connect(socket, SIGNAL(readyRead()), this, SIGNAL(dataReceived()));
}
Exemple #4
0
// -------------------------------------------------------------------
// ConnectionPort
// -------------------------------------------------------------------
long int BitSwarmClient::ConnectionPort()
{
	if (!Connected())
	{
		return -1;
	}
	else
	{
		return lastTcpPort;
	}
}
Exemple #5
0
void IsuCalcLink::Initialize()
{
    Socket = new QTcpSocket;
    connect(Socket, SIGNAL(connected()), this, SLOT(Connected()));
    connect(Socket, SIGNAL(disconnected()), this, SLOT(Disconnected()));
    connect(Socket, SIGNAL(readyRead()), this, SLOT(ReadyRead()));
    connect(Socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(SocketError(QAbstractSocket::SocketError)));
    Timer = new QTimer;
    Timer->setSingleShot(true);
    connect(Timer, SIGNAL(timeout()), this, SLOT(TimerExpired()));
}
Exemple #6
0
// -------------------------------------------------------------------
// ConnectionIp
// -------------------------------------------------------------------
boost::shared_ptr<string> BitSwarmClient::ConnectionIp()
{
	if (!Connected())
	{
		return boost::shared_ptr<string>(new string("Not Connected"));
	}
	else
	{
		return boost::shared_ptr<string>(new string(*lastIpAddress));
	}
}
bool EmuTCPConnection::SendPacket(EmuTCPNetPacket_Struct* tnps)
{
	if (RemoteID)
	{
		return false;
	}
	if (!Connected())
	{
		return false;
	}
	if (GetMode() != modePacket)
	{
		return false;
	}

	LockMutex lock(&MState);
	eTCPMode tmp = GetMode();
	if (tmp == modeTransition)
	{
		EmuTCPNetPacket_Struct* tnps2 = (EmuTCPNetPacket_Struct*) new uchar[tnps->size];
		memcpy(tnps2, tnps, tnps->size);
		InModeQueuePush(tnps2);
		return true;
	}
#if TCPN_LOG_PACKETS >= 1
	if (tnps && tnps->opcode != 0)
	{
		struct in_addr	in;
		in.s_addr = GetrIP();
		CoutTimestamp(true);
		std::cout << ": Logging outgoing TCP NetPacket. OPCode: 0x" << std::hex << std::setw(4) << std::setfill('0') << tnps->opcode << std::dec << ", size: " << std::setw(5) << std::setfill(' ') << tnps->size << " " << inet_ntoa(in) << ":" << GetrPort();
		if (pOldFormat)
		{
			std::cout << " (OldFormat)";
		}
		std::cout << std::endl;
#if TCPN_LOG_PACKETS == 2
		if (tnps->size >= 32)
		{
			DumpPacket((uchar*) tnps, 32);
		}
		else
		{
			DumpPacket((uchar*) tnps, tnps->size);
		}
#endif
#if TCPN_LOG_PACKETS >= 3
		DumpPacket((uchar*) tnps, tnps->size);
#endif
	}
#endif
	ServerSendQueuePushEnd((const uchar*) tnps, tnps->size);
	return true;
}
// ----------------------------------------------------------------------------
// CIpsPlgImap4ConnectOp::DoConnectOpL()
// ----------------------------------------------------------------------------    
//   
void CIpsPlgImap4ConnectOp::DoConnectOpL()
	{
    FUNC_LOG;
    iBaseMtm->SwitchCurrentEntryL( iService );

    iSelection->ResizeL(0);
    iSelection->AppendL(iService);
    
    // <qmail>
    iStatus = KRequestPending;
    if ( iDoPlainConnect && !Connected() )
        {
        TBuf8<1> parameter;
        NM_COMMENT("CIpsPlgImap4ConnectOp: do plain connect");
        // connect and synchronise starts background sync or idle
        iSubOperation = iBaseMtm->InvokeAsyncFunctionL(
            KIMAP4MTMConnect, *iSelection, parameter, iStatus);
        }
    else if ( Connected() )
        {
        // in this point cant use "connect and do something" commands,
        // use regular sync, when new mails is populated elsewhere.
        TBuf8<1> parameter;
        NM_COMMENT("CIpsPlgImap4ConnectOp: full sync starting");
        iSubOperation = iBaseMtm->InvokeAsyncFunctionL(
            KIMAP4MTMFullSync, *iSelection, parameter, iStatus);
        }
    else
        {
        // the used command requires an observer to be given even though we're not using it
        NM_COMMENT("CIpsPlgImap4ConnectOp: connect and sync");
        TPckg<MMsvImapConnectionObserver*> parameter( NULL );
        iSubOperation = iBaseMtm->InvokeAsyncFunctionL(
            KIMAP4MTMConnectAndSyncCompleteAfterFullSync, 
            *iSelection, parameter, iStatus );
        }
    SignalSyncStarted();
    iState = EStateConnectAndSync;
    SetActive();
    // </qmail>
	}
Exemple #9
0
bool LoginServer::InitLoginServer() {
	if(Connected() == false) {
		if(ConnectReady()) {
			Log.Out(Logs::Detail, Logs::World_Server, "Connecting to login server: %s:%d",LoginServerAddress,LoginServerPort);
			Connect();
		} else {
			Log.Out(Logs::Detail, Logs::World_Server, "Not connected but not ready to connect, this is bad: %s:%d",
				LoginServerAddress,LoginServerPort);
		}
	}
	return true;
}
Exemple #10
0
void WorldConnection::Process() {
	//persistent connection....
	if (!Connected()) {
		pConnected = tcpc.Connected();
		if (pConnected) {
			OnConnected();
		}
		else
			return;
	}

}
Exemple #11
0
//Constructor
phAnalyzer::phAnalyzer(QWidget *parent, Qt::WFlags flags) : QWidget(parent, flags), inj(0)
{
	//Sets up the UI
	ui.setupUi(this);

	//Get absolute path to application
	QString path = QApplication::applicationFilePath();
	path = path.replace(path.mid(path.lastIndexOf("/")), "");

	//Load settings
	QSettings settings(path + "/phAnalyzer.ini", QSettings::IniFormat);
	HOST = settings.value("phAnalyzer/Host").toString();
	PORT = settings.value("phAnalyzer/Port").toUInt();

	//Make sure the host/IP is not empty
	if(HOST.isEmpty())
	{
		//Set default IP
		settings.setValue("phAnalyzer/Host", "127.0.0.1");
		HOST = "127.0.0.1";
	}

	//Make sure the port is not null
	if(PORT == 0)
	{
		//Set default port
		settings.setValue("phAnalyzer/Port", 22580);
		PORT = 22580;
	}

	//Connect file menu actions
	connect(ui.actionSave, SIGNAL(triggered()), this, SLOT(Save()));
	connect(ui.actionInject, SIGNAL(triggered()), this, SLOT(Inject()));
	connect(ui.actionExit, SIGNAL(triggered()), this, SLOT(close()));

	//Connect right click menu for removing opcodes
	connect(ui.lstIgnore, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(RemoveOpcodeMenu(const QPoint &)));
    connect(ui.lstListen, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(RemoveOpcodeMenu(const QPoint &)));

	//New socket
	socket = new QTcpSocket(this);

	//Create the injection UI
	inj = new injection(0, socket);

	//Setup the connection slots
	connect(socket, SIGNAL(connected()), this, SLOT(Connected()));
    connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(SocketState(QAbstractSocket::SocketState)));
	connect(socket, SIGNAL(readyRead()), this, SLOT(readyRead()));

	//Connect
	socket->connectToHost(HOST, PORT);
}
Exemple #12
0
bool LoginServer::InitLoginServer() {
	if(Connected() == false) {
		if(ConnectReady()) {
			_log(WORLD__LS, "Connecting to login server: %s:%d",LoginServerAddress,LoginServerPort);
			Connect();
		} else {
			_log(WORLD__LS_ERR, "Not connected but not ready to connect, this is bad: %s:%d",
				LoginServerAddress,LoginServerPort);
		}
	}
	return true;
}
//================================================================================================================================================================
bool UnionFindTemplate::addPair(int p, int q)
{
    if(!Connected(p, q))
    {
        Union(p, q);
        nrUnionOperations++;

        return true;
    }
    else
        return false;
}
				void Vrc4::Irq::SaveState(State::Saver& state,const dword chunk) const
				{
					const byte data[5] =
					{
						unit.ctrl | (Connected() ? BaseIrq::ENABLE_0 : 0),
						unit.latch,
						unit.count[0] & 0xFF,
						unit.count[0] >> 8,
						unit.count[1]
					};

					state.Begin( chunk ).Write( data ).End();
				}
bool TCPConnection::Send(const uchar* data, int32 size)
{
	if (!Connected())
	{
		return false;
	}
	if (!size)
	{
		return true;
	}
	ServerSendQueuePushEnd(data, size);
	return true;
}
int main(){
	Graph G(3,Directed);
	G.addEdge(0, 1);
	G.addEdge(0,2);
	G.addEdge(2,1);
	DepthFirstOrder Connected(G);
	std::deque<int> *validation = Connected.GetreversePost();
	std::deque<int>::const_iterator prueba;
	for(prueba = validation->begin();prueba != validation->end(); ++prueba)
		std::cout << *prueba;

	std::cout<<std::endl;
}
Exemple #17
0
/** Check warnings on a specific player by themselves.
 * \param player player checking warnings on their objects.
 */
void
do_wcheck_me(dbref player)
{
    int ndone;
    if (!Connected(player))
        return;
    for (ndone = 0; ndone < db_top; ndone++) {
        if ((Owner(ndone) == player) && !IsGarbage(ndone))
            check_topology_on(player, ndone);
    }
    notify(player, T("@wcheck complete."));
    return;
}
Exemple #18
0
bool NHandsFree::
InetConnect(int port)
{
	int sock;
	sockaddr_in sa;

	assert(m_hfpd_state == NHS_HFPD_DISCONNECTED);
	assert(m_sock < 0);

	sock = socket(PF_INET, SOCK_STREAM, 0);
	if (sock < 0) {
		ndebug::out(ndebug::LOG_ERR, "NHandsFree: %s:%s(%d) - "
			    "Error creating socket(%d) - %s",
			    __FILE__, __FUNCTION__, __LINE__,
			    errno, strerror(errno));
		return false;
	}

	sa.sin_family = AF_INET;
	sa.sin_port = htons(port);
	sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);

	if (!SetNonBlock(sock, true)) {
		ndebug::out(ndebug::LOG_ERR, "NHandsFree: %s:%s(%d) - "
			    "Error setting nonblock on socket(%d) - %s",
			    __FILE__, __FUNCTION__, __LINE__,
			    errno, strerror(errno));
		close(sock);
		return false;
	}

	if (connect(sock, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
		if (errno == EINPROGRESS) {
			m_sock = sock;
			m_hfpd_state = NHS_HFPD_CONNECTING;
			return true;
		}

		ndebug::out(ndebug::LOG_ERR, "NHandsFree: %s:%s(%d) - "
			    "Error connecting socket(%d) - %s",
			    __FILE__, __FUNCTION__, __LINE__,
			    errno, strerror(errno));
		close(sock);
		return false;
	}

	m_hfpd_state = NHS_HFPD_CONNECTED;
	m_sock = sock;
	Connected();
	return true;
}
bool
RPCChannel::OnMaybeDequeueOne()
{
    // XXX performance tuning knob: could process all or k pending
    // messages here

    AssertWorkerThread();
    mMonitor->AssertNotCurrentThreadOwns();

    Message recvd;
    {
        MonitorAutoLock lock(*mMonitor);

        if (!Connected()) {
            ReportConnectionError("RPCChannel");
            return false;
        }

        if (!mDeferred.empty())
            MaybeUndeferIncall();

        MessageQueue *queue = mUrgent.empty()
                              ? mNonUrgentDeferred.empty()
                              ? &mPending
                              : &mNonUrgentDeferred
                              : &mUrgent;
        if (queue->empty())
            return false;

        recvd = queue->front();
        queue->pop_front();
    }

    if (IsOnCxxStack() && recvd.is_rpc() && recvd.is_reply()) {
        // We probably just received a reply in a nested loop for an
        // RPC call sent before entering that loop.
        mOutOfTurnReplies[recvd.seqno()] = recvd;
        return false;
    }

    CxxStackFrame f(*this, IN_MESSAGE, &recvd);

    if (recvd.is_rpc())
        Incall(recvd, 0);
    else if (recvd.is_sync())
        SyncChannel::OnDispatchMessage(recvd);
    else
        AsyncChannel::OnDispatchMessage(recvd);

    return true;
}
Exemple #20
0
bool
CCBListener::SendMsgToCCB(ClassAd &msg,bool blocking)
{
	if( !m_sock ) {
		Daemon ccb(DT_COLLECTOR,m_ccb_address.Value());

		int cmd = -1;
		msg.LookupInteger( ATTR_COMMAND, cmd );
		if( cmd != CCB_REGISTER ) {
			dprintf(D_ALWAYS,"CCBListener: no connection to CCB server %s"
					" when trying to send command %d\n",
					m_ccb_address.Value(), cmd );
			return false;
		}

		// Specifying USE_TMP_SEC_SESSION to force a fresh security
		// session.  Otherwise we can end up in a catch-22 where we
		// are trying to reconnect to the CCB server and we try to use
		// a cached security session which is no longer valid, but our
		// CCB server cannot send us the invalidation message because
		// we are trying to reconnect to it.  Expring this session
		// right away is also a good idea, because if we are just
		// starting up, the return address associated with it will not
		// have any CCB information attached, which again means that
		// the CCB server has no way to invalidate it.

		if( blocking ) {
			m_sock = ccb.startCommand( cmd, Stream::reli_sock, CCB_TIMEOUT, NULL, NULL, false, USE_TMP_SEC_SESSION );
			if( m_sock ) {
				Connected();
			}
			else {
				Disconnected();
				return false;
			}
		}
		else if( !m_waiting_for_connect ) {
			m_sock = ccb.makeConnectedSocket(Stream::reli_sock, CCB_TIMEOUT, 0, NULL, true /*nonblocking*/ );
			if( !m_sock ) {
				Disconnected();
				return false;
			}
			m_waiting_for_connect = true;
			incRefCount(); // do not let ourselves be deleted until called back
			ccb.startCommand_nonblocking( cmd, m_sock, CCB_TIMEOUT, NULL, CCBListener::CCBConnectCallback, this, NULL, false, USE_TMP_SEC_SESSION );
			return false;
		}
	}

	return WriteMsgToCCB(msg);
}
void SoundCloudService::ConnectFinished(OAuthenticator* oauth) {
  oauth->deleteLater();

  access_token_ = oauth->access_token();
  if (!access_token_.isEmpty()) {
    emit Connected();
  }
  expiry_time_ = oauth->expiry_time();
  QSettings s;
  s.beginGroup(kSettingsGroup);
  s.setValue("access_token", access_token_);

  EnsureItemsCreated();
}
Exemple #22
0
bool NHandsFree::
UnixConnect(const char *sockname)
{
	int sock;
	sockaddr_un sa;

	assert(m_hfpd_state == NHS_HFPD_DISCONNECTED);
	assert(m_sock < 0);

	sock = socket(PF_UNIX, SOCK_STREAM, 0);
	if (sock < 0) {
		ndebug::out(ndebug::LOG_ERR, "NHandsFree: %s:%s(%d) - "
			    "Error creating socket(%d) - %s",
			    __FILE__, __FUNCTION__, __LINE__,
			    errno, strerror(errno));
		return false;
	}

	sa.sun_family = AF_UNIX;
	strncpy(sa.sun_path, sockname, sizeof(sa.sun_path));

	if (!SetNonBlock(sock, true)) {
		ndebug::out(ndebug::LOG_ERR, "NHandsFree: %s:%s(%d) - "
			    "Error setting nonblock on socket(%d) - %s",
			    __FILE__, __FUNCTION__, __LINE__,
			    errno, strerror(errno));
		close(sock);
		return false;
	}

	if (connect(sock, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
		if (errno == EINPROGRESS) {
			m_sock = sock;
			m_hfpd_state = NHS_HFPD_CONNECTING;
			return true;
		}

		ndebug::out(ndebug::LOG_ERR, "NHandsFree: %s:%s(%d) - "
			    "Error connecting socket(%d) - %s",
			    __FILE__, __FUNCTION__, __LINE__,
			    errno, strerror(errno));
		close(sock);
		return false;
	}

	m_hfpd_state = NHS_HFPD_CONNECTED;
	m_sock = sock;
	Connected();
	return true;
}
bool
RPCChannel::EventOccurred() const
{
    AssertWorkerThread();
    mMonitor->AssertCurrentThreadOwns();
    RPC_ASSERT(StackDepth() > 0, "not in wait loop");

    return (!Connected() ||
            !mPending.empty() ||
            !mUrgent.empty() ||
            (!mOutOfTurnReplies.empty() &&
             mOutOfTurnReplies.find(mStack.top().seqno())
             != mOutOfTurnReplies.end()));
}
Exemple #24
0
void Transceiver::StopListen()
{
   if (Connected()){
      if   (timer.Cycle()<(_helloCycle+20))  //check 1min
          Idle();
      if  (timer.Cycle()>_helloCycle+100)  //after 5min without knock
         Deconnect();
   } else {
     if (timer.Cycle() >(_KnockCycle+60)){   // check 3 min
        DBGINFO("StopListen");
        Idle();
     }
   }
}
bool CMultiXL2Link::Write(CMultiXMsgStack *Stack,bool	bSSLPrivate)
{
	if(!Connected())
	{
		m_LastError	=	L2ErrLinkNotConnected;
		return	false;
	}
	MsgQueue().push_back(new	CMultiXL2LinkMsgQueueEntry(Stack,bSSLPrivate));
	Stack->Owner()	=	this;
	if(WritePending())
		return	true;

	return	SendNext();
}
Exemple #26
0
void HandleCallNotification(unsigned char Opt, unsigned char *pVal, unsigned char Len)
{
    tMessage Msg;

    switch (Opt)
    {
    case CALLER_NAME:
        if (Ring == FALSE)
        {
            Ring = TRUE;
            SendMessage(&Msg, VibrateMsg, VIBRA_PATTERN_RING);
            StartTimer(VibraTimer);

            DrawCallNotification(pVal, Len);

            if (GetProperty(PROP_AUTO_BACKLIGHT)) SendMessage(&Msg, AutoBacklightMsg, MSG_OPT_NONE);
        }
        break;

    case CALL_END:
        StopTimer(VibraTimer);
        Ring = FALSE;
        SendMessage(&Msg, ChangeModeMsg, IDLE_MODE | MSG_OPT_UPD_INTERNAL);
        if (Connected(CONN_TYPE_HFP)) SendMessage(&Msg, HfpMsg, MSG_OPT_HFP_RING_STOP);
        break;

    case CALL_REJECTED:
        StopTimer(VibraTimer);
        Ring = FALSE;
        if (Connected(CONN_TYPE_HFP)) SendMessage(&Msg, HfpMsg, MSG_OPT_HFP_HANGUP);
        break;

    case CALLER_NUMBER:
        SetCallerNumber(pVal, Len);
        break;
    }
}
/*
CMultiXProcess	*CMultiXProcess::NextProcess()
{
	return	ID().Next();
}

size_t	CMultiXProcess::OutQueueSize()
{
	return	m_pOutQueue->Size();
}
size_t	CMultiXProcess::InQueueSize()
{
	return	m_pInQueue->Size();
}
*/
bool CMultiXProcess::Login(std::string	sPassword)
{
    if(!sPassword.empty())
        PasswordToSend()	=	sPassword;
    if(SenderEnabled())
    {
        return	true;
    }
    if(!Connected())
        return	false;

    CMultiXL5Msg	Msg(CMultiXL5Msg::LoginMsgCode,*Owner());
    Msg.AddItem(LoginPasswordItemCode,PasswordToSend());
    return	SendMsg(Msg);
}
/* virtual */ void
ES_RemoteDebugConnection::OnSocketConnectionRequest(OpSocket* socket)
{
	OpSocket *new_socket;

	if (OpStatus::IsSuccess(SocketWrapper::CreateTCPSocket(&new_socket, this, SocketWrapper::NO_WRAPPERS)))
		if (OpStatus::IsSuccess(socket->Accept(new_socket)))
		{
			delete socket;
			socket = new_socket;

			state = CONNECTED;

			OpStatus::Ignore(Connected());
		}
}
Exemple #29
0
	void NTCPSession::HandlePhase4Sent (const boost::system::error_code& ecode,  std::size_t bytes_transferred)
	{
		if (ecode)
        {
			LogPrint ("Couldn't send Phase 4 message: ", ecode.message ());
			Terminate ();
		}
		else
		{	
			LogPrint ("Phase 4 sent: ", bytes_transferred);
			Connected ();
			m_ReceiveBufferOffset = 0;
			m_NextMessage = nullptr;
			Receive ();
		}	
	}	
void IncrementUpTime(void)
{
  if (Connected(CONN_TYPE_MAIN))
  {
    gBtStats.UpTime++;  
  }
  else
  {
    if ( gBtStats.UpTime > gBtStats.MaxUpTime )
    {
      gBtStats.MaxUpTime = gBtStats.UpTime;
    }
    
    gBtStats.UpTime = 0;
  }
}