bool XferObject::RegisterInterfaces()
{
    const InterfaceDescription* serviceIntf = ajConnection->busAttachment->GetInterface(XFER_SERVICE_INTERFACE_NAME);
    assert(serviceIntf);
    AddInterface(*serviceIntf);
    /** Register the method handlers with the object */
    MethodEntry methodEntries[6];
    methodEntries[0].member = serviceIntf->GetMember("query");
    methodEntries[0].handler = (MessageReceiver::MethodHandler)(&XferObject::Query);
    methodEntries[1].member = serviceIntf->GetMember("initiate");
    methodEntries[1].handler = (MessageReceiver::MethodHandler)(&XferObject::InitiateXferIn);
    methodEntries[2].member = serviceIntf->GetMember("receive");
    methodEntries[2].handler = (MessageReceiver::MethodHandler)(&XferObject::ReceiveSegment);
    methodEntries[3].member = serviceIntf->GetMember("status");
    methodEntries[3].handler = (MessageReceiver::MethodHandler)(&XferObject::TransferStatus);
    methodEntries[4].member = serviceIntf->GetMember("close");
    methodEntries[4].handler = (MessageReceiver::MethodHandler)(&XferObject::EndXfer);
    methodEntries[5].member = serviceIntf->GetMember("error");
    methodEntries[5].handler = (MessageReceiver::MethodHandler)(&XferObject::ErrorCode);
    status = AddMethodHandlers(methodEntries, sizeof(methodEntries) / sizeof(methodEntries[0]));
    if (ER_OK != status) {
        NotifyUser(MSG_ERROR, "Failed to register method handlers for XferObject");
        return false;
    }
    NotifyUser(MSG_SYSTEM, "register method handlers for XferObject");
    return true;
}
bool AllJoynBusListener::AcceptSessionJoiner(SessionPort sessionPort, const char* joiner, const SessionOpts& opts)
{
    if (sessionPort != PHOTOCHAT_PORT) {
        NotifyUser(MSG_ERROR, "Rejecting join attempt on non-chat session port %d\n", sessionPort);
        return false;
    }
    NotifyUser(MSG_STATUS, "Accepting join session request from %s (opts.proximity=%x, opts.traffic=%x, opts.transports=%x)\n",
               joiner, opts.proximity, opts.traffic, opts.transports);
    return true;
}
void AllJoynConnection::createMessageBus()
{
    status = ER_OK;
    NotifyUser(MSG_STATUS, "Create message bus.");
    ajn::BusAttachment* bus = new BusAttachment("chat", true);
    this->busAttachment = bus;
    NotifyUser(MSG_STATUS, "Create listener.");
    this->busListener = new AllJoynBusListener();
    this->busListener->SetListenCallback(JoinNotifier);
    this->busListener->SetConnection(this);
}
void AllJoynConnection::bindSessionPort(SessionOpts& opts)
{
    /* Bind the session port*/
    NotifyUser(MSG_STATUS, "Bind session port.");
    if (ER_OK == status) {
        SessionPort sp = PHOTOCHAT_PORT;
        status = this->busAttachment->BindSessionPort(sp, opts, *(this->busListener));
        if (ER_OK != status) {
            NotifyUser(MSG_ERROR, "BindSessionPort failed (%s)\n", QCC_StatusText(status));
        }
    }
}
// Distributed Methods
void XferObject::Query(const InterfaceDescription::Member* member, Message& msg)
{
    qcc::String filename = msg->GetArg(0)->v_string.str;
    NotifyUser(MSG_STATUS, "QUERY RECEIVED (%s)", filename.c_str());
    // call into managed code
    int accept = msg->GetArg(1)->v_uint32;
    queryCallback(filename.c_str(), accept);
    MsgArg outArg("i", accept);
    QStatus status = MethodReply(msg, &outArg, 1);
    if (ER_OK != status) {
        NotifyUser(MSG_ERROR, "XferObjectQuery : Error sending reply");
    }
}
Beispiel #6
0
void __cdecl Check_ThreadFunc(void *lpParam)
{
	InternetSetCookieA("https://mail.google.com/mail/", "GX", "");
	if (lpParam) {
		CheckMailInbox((Account *)lpParam);
		NotifyUser((Account *)lpParam);
	}
	else {
		for (int i = 0; i < acc_num && GetContactProto(acc[i].hContact); i++) {
			CheckMailInbox(&acc[i]);
			NotifyUser(&acc[i]);
		}
	}
}
//----------------------------------------------------------------------------------------
// AllJoynBusListener (BusListener, SessionPortListener, SessionListener )
//----------------------------------------------------------------------------------------
void AllJoynBusListener::FoundAdvertisedName(const char* name, TransportMask transport, const char* namePrefix)
{
    if (!connection->joinName.empty() && 0 == connection->sessionId) {
        const char* convName = name + strlen(NAME_PREFIX);
        SessionOpts opts(SessionOpts::TRAFFIC_MESSAGES, true, SessionOpts::PROXIMITY_ANY, TRANSPORT_ANY);
        QStatus status = connection->busAttachment->JoinSession(name, PHOTOCHAT_PORT, this, connection->sessionId, opts);
        if (ER_OK == status) {
            NotifyUser(MSG_STATUS, "Joined conversation \"%s\"\n", convName);
        } else {
            NotifyUser(MSG_ERROR, "JoinSession failed (status=%s)\n", QCC_StatusText(status));
        }
    }
    connection->joinComplete = true;
}
bool AllJoynConnection::invariants()
{
    if (NULL == ManagedOutput) {
        MessageBox(NULL, L"Managed Output not set", L"Alljoyn", MB_OK);
        return false;
    }
    if (NULL == JoinNotifier) {
        NotifyUser(MSG_ERROR, "Join Notifier not set");
        return false;
    }
    if (advertisedName.empty() && joinName.empty()) {
        NotifyUser(MSG_ERROR, "Neither advertised or joinName set");
        return false;
    }
    return true;
}
bool ChatConnection::invariants()
{
    if (NULL == JoinNotifier) {
        NotifyUser(MSG_ERROR, "Join Notifier not set");
        return false;
    }
    if (NULL == ManagedOutput) {
        NotifyUser(MSG_ERROR, "Managed Output  not set");
        return false;
    }
    if (advertisedName.empty() && joinName.empty()) {
        NotifyUser(MSG_ERROR, "Neither advertised or joinName set");
        return false;
    }
    return true;
}
void MyBusListener::SessionJoined(SessionPort sessionPort, SessionId id, const char* joiner)
{
    connection->sessionId = id;
    NotifyUser(MSG_STATUS, "SessionJoined with %s (id=%d)\n", joiner, id);
    int n = (int)id;
    (JoinedEvent)("joined", n);
}
Beispiel #11
0
void duGifCtrl::OnMouseLUp(POINT pt)
{
	if (GetState() == DU_STATE_PRESS)
	{
		Plugin_SetState(this, DU_STATE_NORMAL);
		NotifyUser(DUM_GIFCLICK, NULL, NULL);
	}
}
Beispiel #12
0
void WINAPI duListBox::OnMouseDbClick(POINT pt)
{
	if (m_pHotItem)
	{
		int nHotItemIndex = GetItemIndex(m_pHotItem);
		NotifyUser(DUM_LBLBUTTONDBCLICK, (WPARAM)nHotItemIndex, NULL);
	}
}
Beispiel #13
0
void WINAPI duListBox::OnMouseHover(POINT pt)
{
	if (m_pHotItem)
	{
		int nHotItemIndex = GetItemIndex(m_pHotItem);
		NotifyUser(DUM_LBHOVER, (WPARAM)nHotItemIndex, NULL);
	}
}
void XferObject::EndXfer(const InterfaceDescription::Member* member, Message& msg)
{
    closeFile();
    if (state != -1)
        state = 0;
    saveAsFilename = "";
    NotifyUser(MSG_SYSTEM, "Closed %s", saveAsFilename.c_str());
}
bool ChatObject::CreateInterfaces()
{
    const char* ifName = CHAT_SERVICE_INTERFACE_NAME;
    InterfaceDescription* chatIntf = NULL;

    status = ajConnection->busAttachment->CreateInterface(ifName, chatIntf);
    assert(chatIntf);
    if (ER_OK == status) {
        chatIntf->AddSignal("Chat", "s",  "str", 0);
        chatIntf->Activate();
    } else {
        NotifyUser(MSG_ERROR, "Failed to create interface \"%s\" (%s)\n", CHAT_SERVICE_INTERFACE_NAME, QCC_StatusText(status));
        return false;
    }
    NotifyUser(MSG_SYSTEM, "Create interface \"%s\" (%s)\n", CHAT_SERVICE_INTERFACE_NAME, QCC_StatusText(status));
    return true;
}
Beispiel #16
0
void WINAPI duListBox::OnMouseRDown(POINT pt)
{
	if (m_pHotItem)
	{
		int nHotItemIndex = GetItemIndex(m_pHotItem);
		NotifyUser(DUM_LBRBUTTONDOWN, (WPARAM)nHotItemIndex, NULL);
	}
}
void XferObject::ErrorCode(const InterfaceDescription::Member* member, Message& msg)
{
    MsgArg outArg("i", errorCode);
    QStatus status = MethodReply(msg, &outArg, 1);
    if (ER_OK != status) {
        NotifyUser(MSG_ERROR, "XferObject::ErrorCode : Error sending reply");
    }
}
// FACTOR UP
ProxyBusObject* AllJoynConnection::FetchProxy(int index)
{
    if (NULL == proxies[index]) {
        NotifyUser(MSG_ERROR, "INVALID PROXY = %d", index);
        return NULL;
    }
    return proxies[index];
}
void AllJoynConnection::startMessageBus()
{
    NotifyUser(MSG_STATUS, "Start the message bus.");
    /* Start the msg bus */
    if (ER_OK == status) {
        status = this->busAttachment->Start();
        if (ER_OK != status) {
            NotifyUser(MSG_ERROR, "BusAttachment::Start failed (%s)\n", QCC_StatusText(status));
        }
    }
    /* Register a bus listener */
    if (ER_OK == status) {
        // make sure the callback has been set
        this->busAttachment->RegisterBusListener(*(this->busListener));
    }
    NotifyUser(MSG_STATUS, "Registered BusListener");

    /* Get env vars */
    const char* connectSpec = getenv("BUS_ADDRESS");
    if (connectSpec == NULL) {
        connectSpec = "tcp:addr=127.0.0.1,port=9956";
        NotifyUser(MSG_STATUS, "Connect spec defaulted to %s", connectSpec);
    } else
        NotifyUser(MSG_STATUS, "Got environment BUS_ADDRESS %s", connectSpec);

    /* Connect to the local daemon */
    NotifyUser(MSG_STATUS, "Connect to the local daemon.");
    if (ER_OK == status) {
        status = this->busAttachment->Connect(connectSpec);
    }
    if (ER_OK != status) {
        NotifyUser(MSG_ERROR, "BusAttachment::Connect(%s) failed (%s)\n", connectSpec, QCC_StatusText(status));
    }
}
void AllJoynConnection::ReleaseProxy(int index)
{
    if (NULL == proxies[index])
        NotifyUser(MSG_ERROR, "INVALID PROXY INDEX = %d", index);
    else {
        delete proxies[index];
        proxies[index] = NULL;
    }
}
/** Send a Chat signal */
QStatus ChatObject::SendChatSignal(const char* msg)
{
    MsgArg chatArg("s", msg);
    uint8_t flags = 0;
    if (0 == ajConnection->sessionId) {
        NotifyUser(MSG_ERROR, "Sending Chat signal without a session id\n");
        return ER_ALLJOYN_JOINSESSION_REPLY_NO_SESSION;
    }
    return Signal(NULL, ajConnection->sessionId, *chatSignalMember, &chatArg, 1, 0, flags);
}
bool XferObject::openFile(const char* filename)
{
    hFile = CreateFileA(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    if (hFile == INVALID_HANDLE_VALUE) {
        DWORD err = GetLastError();
        NotifyUser(MSG_SYSTEM, "XferObjectQuery : Error opening file %s %d %x", filename, err, err);
        return false;
    }
    return true;
}
Beispiel #23
0
void
Wrapup( )
{
	struct rusage local_rusage;
	char notification[ BUFSIZ ];

	dprintf(D_FULLDEBUG, "Entering Wrapup()\n" );

	notification[0] = '\0';

	/* This HadErr business isn't well defined. There doesn't seem
		to be a clean way of representing the event of a
		pre-job startup initialization failure.  So, instead of trying
		to propogate the nonexistant JobStatus around to future
		code paths trying to clean up a mess specified by HadErr,
		we are simply going to EXCEPT(). HadErr only gets specified
		when either the std file can't be opened or the shadow
		cannot chdir() to the initialdir(often because of a
		permission/existance problem). */
	if( HadErr ) {
		/* dump the specific error if it has been determined */
		if (ErrBuf[0] != '\0') {
			EXCEPT("%s", ErrBuf);
		} else {
			EXCEPT("Couldn't set up std files or chdir to initialdir--"
				"probably a permissions error.");
		}
	} else {
		/* all event logging has been moved from handle_termination() to
		   log_termination()	--RR */
		handle_termination( Proc, notification, &JobStatus, NULL );
	}

	/* fill in the Proc structure's exit_status with JobStatus, so that when
	 * we call update_job_status the exit status is written into the job queue,
	 * so that the history file will have exit status information for the job.
	 * note that JobStatus is in BSD format, and Proc->exit_status is in POSIX
	 * int format, so we copy very carefully.  on most platforms the 2 formats
	 * are interchangeable, so most of the time we'll get intelligent results.
	 *    -Todd, 11/95
	*/
	memcpy(&(Proc->exit_status[0]),&JobStatus,sizeof((Proc->exit_status[0])));
	get_local_rusage( &local_rusage );
	update_job_status( &local_rusage, &JobRusage );


	/* log the event associated with the termination; pass local and remote
	   rusage for the run.  The total local and remote rusages for the job are
	   stored in the Proc --- these values were updated by update_job_status */
	log_termination (&local_rusage, &JobRusage);

	if( notification[0] ) {
		NotifyUser( notification, Proc );
	}
}
bool XferObject::CreateInterfaces()
{
    const char* ifName = XFER_SERVICE_INTERFACE_NAME;
    InterfaceDescription* xferIntf = NULL;
    status = ajConnection->busAttachment->CreateInterface(ifName, xferIntf);
    assert(xferIntf);
    if (ER_OK == status) {
        xferIntf->AddMethod("query", "si",  "i", "filename, filesize, acceptsize ", 0);
        xferIntf->AddMethod("initiate", "ii",  "i", "segmentSize, nSegs, acceptsize ", 0);
        xferIntf->AddMethod("receive", "ayii",  "i", "segment, serialNum. segSize , success ", 0);
        xferIntf->AddMethod("status", "i",  "i", "unused , status ", 0);
        xferIntf->AddMethod("close", "i",  "i", "unused , success ", 0);
        xferIntf->AddMethod("error", "i",  "i", "unused , error ", 0);
        xferIntf->Activate();
    } else {
        NotifyUser(MSG_ERROR, "Failed to create interface \"%s\" (%s)\n", XFER_SERVICE_INTERFACE_NAME, QCC_StatusText(status));
        return false;
    }
    NotifyUser(MSG_SYSTEM, "Create interface \"%s\" (%s)\n", XFER_SERVICE_INTERFACE_NAME, QCC_StatusText(status));
    return true;
}
Beispiel #25
0
void WINAPI duListBox::OnMouseLDown(POINT pt)
{
	if (m_pHotItem != m_pSelItem)
	{
		ListBoxItem *pTemp = m_pSelItem;
		m_pSelItem = m_pHotItem;
		Plugin_Redraw(this, TRUE);

		int nOldSelItemIndex = GetItemIndex(pTemp);
		int nNewSelItemIndex = GetItemIndex(m_pHotItem);
		NotifyUser(DUM_LBSELCHANGED, (WPARAM)nOldSelItemIndex, (LPARAM)nNewSelItemIndex);
	}
}
Beispiel #26
0
void duSpin::SetValue(int nVal)
{
	m_nVal = nVal;
	TCHAR m_szValue[256];
	_stprintf(m_szValue, _T("%d"), m_nVal);
	SetText(m_szValue);

	m_nSelectionStart = 0;
	m_nSelectionEnd = GetEditTextLength();

	OnEmReplaceSel(FALSE, m_szValue, FALSE, FALSE);
	m_nSelectionStart = m_nSelectionEnd = 0;
	
	NotifyUser(DUM_SPINCHANGE, m_nVal, NULL);
}
void ChatConnection::createMessageBus()
{
    QStatus status = ER_OK;
    NotifyUser(MSG_STATUS, "Create message bus.");
    ajn::BusAttachment* bus = new BusAttachment("chat", true);
    this->busAttachment = bus;
    this->busListener = new MyBusListener();
    this->busListener->SetListenCallback(JoinNotifier);
    this->busListener->SetConnection(this);
    /* Create org.alljoyn.bus.samples.chat interface */
    InterfaceDescription* chatIntf;
    status = bus->CreateInterface(CHAT_SERVICE_INTERFACE_NAME, chatIntf);
    if (ER_OK == status) {
        chatIntf->AddSignal("Chat", "s",  "str", 0);
        chatIntf->Activate();
    } else {
        NotifyUser(MSG_ERROR, "Failed to create interface \"%s\" (%s)\n", CHAT_SERVICE_INTERFACE_NAME, QCC_StatusText(status));
    }
    /* Create and register the bus object that will be used to send and receive signals */
    ChatObject* chatObject = new ChatObject(*bus, CHAT_SERVICE_OBJECT_PATH);
    this->chatObject = chatObject;
    this->busAttachment->RegisterBusObject(*chatObject);
    chatObject->SetConnection(this);
}
void AllJoynConnection::Connect(char* tag, bool asAdvertiser)
{
    status = ER_OK;
    if (asAdvertiser) {
        advertisedName = NAME_PREFIX;
        advertisedName += "xfer";
        joinName = "";
        NotifyUser(MSG_STATUS, "%s is advertiser \n", advertisedName.c_str());
    } else {
        joinName = NAME_PREFIX;
        joinName += "xfer";
        advertisedName = "";
        NotifyUser(MSG_STATUS, "%s is joiner\n", joinName.c_str());
    }
    assert(invariants());
    myTag = tag;
    createMessageBus();
    startMessageBus();
    SessionOpts opts(SessionOpts::TRAFFIC_MESSAGES, true, SessionOpts::PROXIMITY_ANY, TRANSPORT_ANY);
    bindSessionPort(opts);
    if (!this->advertisedName.empty()) {
        NotifyUser(MSG_STATUS, "Request name");
        status = this->busAttachment->RequestName(this->advertisedName.c_str(), DBUS_NAME_FLAG_DO_NOT_QUEUE);
        if (ER_OK != status) {
            NotifyUser(MSG_ERROR, "RequestName(%s) failed (status=%s)\n", this->advertisedName.c_str(), QCC_StatusText(status));
            status = (status == ER_OK) ? ER_FAIL : status;
        }
        /* Advertise same well-known name */
        if (ER_OK == status) {
            status = this->busAttachment->AdvertiseName(this->advertisedName.c_str(), opts.transports);
            if (status != ER_OK) {
                NotifyUser(MSG_ERROR, "Failed to advertise name %s (%s)\n", this->advertisedName.c_str(), QCC_StatusText(status));
            }
        }
    } else {
        status = this->busAttachment->FindAdvertisedName(this->joinName.c_str());
        if (status != ER_OK) {
            NotifyUser(MSG_ERROR, "org.alljoyn.Bus.FindAdvertisedName failed (%s)\n", QCC_StatusText(status));
        }
        NotifyUser(MSG_STATUS, "Found Advertised Name \n");
    }

    createBusObjects(tag);
    m_fConnected = (ER_OK == status);
    NotifyUser(MSG_STATUS, "Ready %s ...", tag);
}
void XferObject::InitiateXferIn(const InterfaceDescription::Member* member, Message& msg)
{
    int segmentSize = msg->GetArg(0)->v_uint32;
    int nSegs = msg->GetArg(1)->v_uint32;
    int accept = 0;
    xferCallback("Initiate", accept);
    const char* filename = GetSaveAsFilename();
    commonSegSize = segmentSize;
    if (openFile(filename))
        accept = 1;
    MsgArg outArg("i", accept);
    QStatus status = MethodReply(msg, &outArg, 1);
    if (ER_OK != status) {
        NotifyUser(MSG_ERROR, "XferObjectQuery : Error sending reply");
    }
}
void XferObject::ReceiveSegment(const InterfaceDescription::Member* member, Message& msg)
{
    const char* ccptr = msg->GetArg(0)->v_string.str;
    int serialNum = msg->GetArg(1)->v_uint32;
    int segSize = msg->GetArg(2)->v_uint32;
    int accept = 0;
    xferCallback("Receive", serialNum);

    uint8_t* bytes = (uint8_t*)ccptr;
    if (writeSegment(serialNum, bytes, segSize))
        accept = 1;
    MsgArg outArg("i", accept);
    QStatus status = MethodReply(msg, &outArg, 1);
    if (ER_OK != status) {
        NotifyUser(MSG_ERROR, "XferObjectReceiveSegment : Error sending reply");
    }
}