Esempio n. 1
0
/**
Set up as a fresh packet with the given opcode.
@param aOpcode a opcode
*/
EXPORT_C void CObexPacket::Init (TObexOpcode aOpcode)
	{
	LOG_LINE
	LOG_FUNC

	SetOpcode (aOpcode);
	SetPacketSize (KObexPacketHeaderSize);
	iInsertPoint = Payload ();
	iExtractPoint = Payload ();
	iNotificationEvents = 0;
	}
Esempio n. 2
0
void
WUploadThread::MessageReceived(const MessageRef & msg, const String & /* sessionID */)
{
	PRINT("WUploadThread::MessageReceived\n");
	switch (msg()->what)
	{
		case WTransfer::TransferCommandPeerID:
		{
			PRINT("WUpload::TransferCommandPeerID\n");
			const char *id = NULL;
                        if (msg()->FindString("beshare:FromSession", id) == B_OK)
			{
				fRemoteSessionID = QString::fromUtf8(id);

				{
					const char *name = NULL;

                                        if (msg()->FindString("beshare:FromUserName", name) ==  B_OK)
					{
						QString user = QString::fromUtf8(name);
						if ((user.isEmpty()) || (fRemoteUser == fRemoteSessionID))
							fRemoteUser = GetUserName(fRemoteSessionID);
						else
							fRemoteUser = user;
					}
					else
					{
						fRemoteUser = GetUserName(fRemoteSessionID);
					}
				}

				if (gWin->IsIgnored(fRemoteSessionID, true))
				{
					SetBlocked(true);
				}

				WUploadEvent *ui = new WUploadEvent(WUploadEvent::UpdateUI);
				if (ui)
				{
//					ui->SetSession(id);
					SendReply(ui);
				}

			}

			bool c = false;

                        if (!fTunneled && msg()->FindBool("unishare:supports_compression", c) == B_OK)
			{
				SetCompression(6);
			}

			double dpps = GetPacketSize() * 1024.0;
			int32 pps = lrint(dpps);

                        if ((msg()->FindInt32("unishare:preferred_packet_size", pps) == B_OK) && (pps < lrint(dpps)))
				SetPacketSize((double) pps / 1024.0);
			break;
		}

		case WTransfer::TransferFileList:
		{
			// TransferFileList(msg);
			WMessageEvent *wme = new WMessageEvent(msg);
			if (wme)
			{
				QApplication::postEvent(this, wme);
			}
			break;
		}
	}
}