void LLPluginClassMedia::setJavascriptEnabled(const bool enabled)
{
	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "javascript_enabled");
	message.setValueBoolean("enable", enabled);
	sendMessage(message);
}
Esempio n. 2
0
void LLPluginClassMedia::browse_back()
{
	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "browse_back");
	sendMessage(message);
}
Esempio n. 3
0
void LLPluginClassMedia::addCertificateFilePath(const std::string& path)
{
	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "add_certificate_file_path");
	message.setValue("path", path);
	sendMessage(message);
}
Esempio n. 4
0
void
tryWakeupThread (Capability *cap, StgTSO *tso)
{
    traceEventThreadWakeup (cap, tso, tso->cap->no);

#ifdef THREADED_RTS
    if (tso->cap != cap)
    {
        MessageWakeup *msg;
        msg = (MessageWakeup *)allocate(cap,sizeofW(MessageWakeup));
        SET_HDR(msg, &stg_MSG_TRY_WAKEUP_info, CCS_SYSTEM);
        msg->tso = tso;
        sendMessage(cap, tso->cap, (Message*)msg);
        debugTraceCap(DEBUG_sched, cap, "message: try wakeup thread %ld on cap %d",
                      (lnat)tso->id, tso->cap->no);
        return;
    }
#endif

    switch (tso->why_blocked)
    {
    case BlockedOnMVar:
    {
        if (tso->_link == END_TSO_QUEUE) {
            tso->block_info.closure = (StgClosure*)END_TSO_QUEUE;
            goto unblock;
        } else {
            return;
        }
    }

    case BlockedOnMsgThrowTo:
    {
        const StgInfoTable *i;
        
        i = lockClosure(tso->block_info.closure);
        unlockClosure(tso->block_info.closure, i);
        if (i != &stg_MSG_NULL_info) {
            debugTraceCap(DEBUG_sched, cap, "thread %ld still blocked on throwto (%p)",
                          (lnat)tso->id, tso->block_info.throwto->header.info);
            return;
        }

        // remove the block frame from the stack
        ASSERT(tso->stackobj->sp[0] == (StgWord)&stg_block_throwto_info);
        tso->stackobj->sp += 3;
        goto unblock;
    }

    case BlockedOnBlackHole:
    case BlockedOnSTM:
    case ThreadMigrating:
        goto unblock;

    default:
        // otherwise, do nothing
        return;
    }

unblock:
    // just run the thread now, if the BH is not really available,
    // we'll block again.
    tso->why_blocked = NotBlocked;
    appendToRunQueue(cap,tso);

    // We used to set the context switch flag here, which would
    // trigger a context switch a short time in the future (at the end
    // of the current nursery block).  The idea is that we have just
    // woken up a thread, so we may need to load-balance and migrate
    // threads to other CPUs.  On the other hand, setting the context
    // switch flag here unfairly penalises the current thread by
    // yielding its time slice too early.
    //
    // The synthetic benchmark nofib/smp/chan can be used to show the
    // difference quite clearly.

    // cap->context_switch = 1;
}
Esempio n. 5
0
void LLPluginClassMedia::set_cookies(const std::string &cookies)
{
	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "set_cookies");
	message.setValue("cookies", cookies);	
	sendMessage(message);
}
Esempio n. 6
0
void *MsgEdit::processEvent(Event *e)
{
    if (e->type() == EventMessageReceived){
        Message *msg = (Message*)(e->param());
        if ((msg->contact() == m_userWnd->id()) && (msg->type() != MessageStatus)){
            if (CorePlugin::m_plugin->getContainerMode()){
                bool bSetFocus = false;
                if (topLevelWidget() && topLevelWidget()->inherits("Container")){
                    Container *container = static_cast<Container*>(topLevelWidget());
                    if (container->wnd() == m_userWnd)
                        bSetFocus = true;
                }
                setMessage(msg, bSetFocus);
            }else{
                if (m_edit->isReadOnly())
                    QTimer::singleShot(0, this, SLOT(setupNext()));
            }
        }
    }
    if (e->type() == EventRealSendMessage){
        MsgSend *s = (MsgSend*)(e->param());
        if (s->edit == this){
            sendMessage(s->msg);
            return e->param();
        }
    }
    if (e->type() == EventCheckState){
        CommandDef *cmd = (CommandDef*)(e->param());
        if ((cmd->param == this) && (cmd->id == CmdTranslit)){
            Contact *contact = getContacts()->contact(m_userWnd->id());
            if (contact){
                TranslitUserData *data = (TranslitUserData*)(contact->getUserData(CorePlugin::m_plugin->translit_data_id));
                if (data){
                    cmd->flags &= ~COMMAND_CHECKED;
                    if (data->Translit)
                        cmd->flags |= COMMAND_CHECKED;
                }
            }
            return NULL;
        }
        if ((cmd->menu_id != MenuTextEdit) || (cmd->param != this))
            return NULL;
        cmd->flags &= ~(COMMAND_CHECKED | COMMAND_DISABLED);
        switch (cmd->id){
        case CmdUndo:
            if (m_edit->isReadOnly())
                return NULL;
            if (!m_edit->isUndoAvailable())
                cmd->flags |= COMMAND_DISABLED;
            return e->param();
        case CmdRedo:
            if (m_edit->isReadOnly())
                return NULL;
            if (!m_edit->isRedoAvailable())
                cmd->flags |= COMMAND_DISABLED;
            return e->param();
        case CmdCut:
            if (m_edit->isReadOnly())
                return NULL;
        case CmdCopy:
            if (!m_edit->hasSelectedText())
                cmd->flags |= COMMAND_DISABLED;
            return e->param();
        case CmdPaste:
            if (m_edit->isReadOnly())
                return NULL;
            if (QApplication::clipboard()->text().isEmpty())
                cmd->flags |= COMMAND_DISABLED;
            return e->param();
        case CmdClear:
            if (m_edit->isReadOnly())
                return NULL;
        case CmdSelectAll:
            if (m_edit->text().isEmpty())
                cmd->flags |= COMMAND_DISABLED;
            return e->param();
        }
        return NULL;
    }
    if (e->type() == EventCommandExec){
        CommandDef *cmd = (CommandDef*)(e->param());
        if ((cmd->id == CmdSmile) && (cmd->param == this)){
            Event eBtn(EventCommandWidget, cmd);
            QToolButton *btnSmile = (QToolButton*)(eBtn.process());
            if (btnSmile){
                SmilePopup *popup = new SmilePopup(this);
                QSize s = popup->minimumSizeHint();
                popup->resize(s);
                connect(popup, SIGNAL(insert(int)), this, SLOT(insertSmile(int)));
                QPoint p = CToolButton::popupPos(btnSmile, popup);
                popup->move(p);
                popup->show();
            }
            return e->param();
        }
void DispatchMessageSystem::sendMouseMessage(float x, float y, MouseEventTypes mouse_type)
{
	m_location.x = x;
	m_location.y = y;
	sendMessage(ET_MOUSE, mouse_type);
}
void SV_sendMessage(int targetID, bytestream message)
{
	sendMessage(NETWORK_MESSAGE_CUSTOM, -1, targetID, message);
}
	////////////////////////////////////////////////////////////////////////////////
	// virtual
	void onClickLinkNoFollow(const EventType& event)
	{
		LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "click_nofollow");
		message.setValue("uri", event.getStringValue());
		sendMessage(message);
	}
Esempio n. 10
0
bool SmtpClient::sendMail(MimeMessage& email)
{
    try
    {
        // Send the MAIL command with the sender
        sendMessage("MAIL FROM: <" + email.getSender().getAddress() + ">");

        waitForResponse();

        if (responseCode != 250) return false;

        // Send RCPT command for each recipient
        QList<EmailAddress*>::const_iterator it, itEnd;
        // To (primary recipients)
        for (it = email.getRecipients().begin(), itEnd = email.getRecipients().end();
             it != itEnd; ++it)
        {
            sendMessage("RCPT TO: <" + (*it)->getAddress() + ">");
            waitForResponse();

            if (responseCode != 250) return false;
        }

        // Cc (carbon copy)
        for (it = email.getRecipients(MimeMessage::Cc).begin(), itEnd = email.getRecipients(MimeMessage::Cc).end();
             it != itEnd; ++it)
        {
            sendMessage("RCPT TO: <" + (*it)->getAddress() + ">");
            waitForResponse();

            if (responseCode != 250) return false;
        }

        // Bcc (blind carbon copy)
        for (it = email.getRecipients(MimeMessage::Bcc).begin(), itEnd = email.getRecipients(MimeMessage::Bcc).end();
             it != itEnd; ++it)
        {
            sendMessage("RCPT TO: <" + (*it)->getAddress() + ">");
            waitForResponse();

            if (responseCode != 250) return false;
        }

        // Send DATA command
        sendMessage("DATA");
        waitForResponse();

        if (responseCode != 354) return false;

        sendMessage(email.toString());

        // Send \r\n.\r\n to end the mail data
        sendMessage(".");

        waitForResponse();

        if (responseCode != 250) return false;
    }
    catch (ResponseTimeoutException)
    {
        return false;
    }

    return true;
}
Esempio n. 11
0
void SmtpClient::quit()
{
    sendMessage("QUIT");
}
Esempio n. 12
0
bool SmtpClient::connectToHost()
{
    switch (connectionType)
    {
    case TlsConnection:
    case TcpConnection:
        socket->connectToHost(host, port);
        break;
    case SslConnection:
        ((QSslSocket*) socket)->connectToHostEncrypted(host, port);
        break;

    }

    // Tries to connect to server
    if (!socket->waitForConnected(connectionTimeout))
    {
        emit smtpError(ConnectionTimeoutError);
        return false;
    }

    try
    {
        // Wait for the server's response
        waitForResponse();

        // If the response code is not 220 (Service ready)
        // means that is something wrong with the server
        if (responseCode != 220)
        {
            emit smtpError(ServerError);
            return false;
        }

        // Send a EHLO/HELO message to the server
        // The client's first command must be EHLO/HELO
        sendMessage("EHLO " + name);

        // Wait for the server's response
        waitForResponse();

        // The response code needs to be 250.
        if (responseCode != 250) {
            emit smtpError(ServerError);
            return false;
        }

        if (connectionType == TlsConnection) {
            // send a request to start TLS handshake
            sendMessage("STARTTLS");

            // Wait for the server's response
            waitForResponse();

            // The response code needs to be 220.
            if (responseCode != 220) {
                emit smtpError(ServerError);
                return false;
            };

            ((QSslSocket*) socket)->startClientEncryption();

            if (!((QSslSocket*) socket)->waitForEncrypted(connectionTimeout)) {
                qDebug("%s", qPrintable( ((QSslSocket*) socket)->errorString()));
                emit SmtpError(ConnectionTimeoutError);
                return false;
            }

            // Send ELHO one more time
            sendMessage("EHLO " + name);

            // Wait for the server's response
            waitForResponse();

            // The response code needs to be 250.
            if (responseCode != 250) {
                emit smtpError(ServerError);
                return false;
            }
        }
    }
    catch (ResponseTimeoutException)
    {
        return false;
    }

    // If no errors occured the function returns true.
    return true;
}
Esempio n. 13
0
void irc_thread__parm::consume(char* c2, int i2) {
        vector<string> msgs = explode( string(c2, i2) );
        int it = 0;
        for(;it < msgs.size(); it++ ){
                string& s = msgs.at(it);

                if (hoscht.size() == 0) {
                        int p = s.find(" NOTICE" , 0);
                        if (p > 0) {
                                hoscht = string( s , 0, p );
                        }
                }

                //string playerzNeedle( hoscht + " 353 " );
                string body = after(s , " ");
                if (starts(body , "353 ")) {
                        string ps2 = after( body , ":" );
                        while (ps2.size() > 0 ) {
                                int isLastPlayer = ps2.find( " " , 0 ) == -1;
                                string player;
                                if (isLastPlayer) {
                                        player = ps2;
                                } else {
                                        player = before(ps2, " ");
                                }
                                player = name_irctolocal(player);
                                userz.push_back(player);
                                userzSorted.insert(player);
                                updatePlayers = 1;
                                if (isLastPlayer) {
                                        break;
                                }
                                ps2 = after(ps2, " ");
                        }
                } else if ( starts(body , "QUIT ") ){
                    string name = readPlayerFromLine(s);    
                        playersParted.push_back(name);
                        userzSorted.erase(name);
                        updatePlayers = 1;
                } else if ( starts(body , "433 ")) {
                        string ps2 = after( body , ":" );
                        appendText(Form1, ps2);
                        Form1->MENUITEM_MAINMENU_CHAT_DISCONNECT->Click();
                }
            
                int pingFind = s.find("PING " + hoscht, 0) ;
                int joinFind = s.find(" JOIN ", 0) ;
                int partFind = s.find(" PART ", 0) ;
                int endNameListFind = s.find("End of /NAMES list.",0);
            
                if (pingFind == 0) {
                        // sending pong
                        string pong ("PONG " + hoscht + "\r\n");
                        send(sd, pong.c_str(), pong.length(), 0);
                } else if (!sentVersion && endNameListFind >= 0) {
                        sentVersion = 1;
                        sendMessage( ("Logged in with " + Application->Title).c_str());
                } else if (joinFind > 0) {
                        string name = readPlayerFromLine(s);
                        playersJoined.push_back(name);
                        userzSorted.insert(name);
                        updatePlayers = 1;
                } else if (partFind > 0) {
                        string name = readPlayerFromLine(s);
                        playersParted.push_back(name);
                        userzSorted.erase(name);
                        updatePlayers = 1;
                }
                messages.push_back(s);
        }
}
Esempio n. 14
0
void LLPluginClassMedia::enableMediaPluginDebugging( bool enable )
{
	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "enable_media_plugin_debugging");
	message.setValueBoolean( "enable", enable );
	sendMessage( message );
}
Esempio n. 15
0
bool QtLocalPeer::sendMessage(const char* message, int timeout)
{
    return sendMessage(QByteArray(message), timeout);
}
void MediaPluginWebKit::receiveMessage(const char *message_string)
{
//	std::cerr << "MediaPluginWebKit::receiveMessage: received message: \"" << message_string << "\"" << std::endl;
	LLPluginMessage message_in;
	
	if(message_in.parse(message_string) >= 0)
	{
		std::string message_class = message_in.getClass();
		std::string message_name = message_in.getName();
		if(message_class == LLPLUGIN_MESSAGE_CLASS_BASE)
		{
			if(message_name == "init")
			{
				LLPluginMessage message("base", "init_response");
				LLSD versions = LLSD::emptyMap();
				versions[LLPLUGIN_MESSAGE_CLASS_BASE] = LLPLUGIN_MESSAGE_CLASS_BASE_VERSION;
				versions[LLPLUGIN_MESSAGE_CLASS_MEDIA] = LLPLUGIN_MESSAGE_CLASS_MEDIA_VERSION;
				versions[LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER] = LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER_VERSION;
				message.setValueLLSD("versions", versions);

				std::string plugin_version = "Webkit media plugin, Webkit version ";
				plugin_version += LLQtWebKit::getInstance()->getVersion();
				message.setValue("plugin_version", plugin_version);
				sendMessage(message);
			}
			else if(message_name == "idle")
			{
				// no response is necessary here.
				F64 time = message_in.getValueReal("time");
				
				// Convert time to milliseconds for update()
				update((int)(time * 1000.0f));
			}
			else if(message_name == "cleanup")
			{
				// DTOR most likely won't be called but the recent change to the way this process
				// is (not) killed means we see this message and can do what we need to here.
				// Note: this cleanup is ultimately what writes cookies to the disk
				LLQtWebKit::getInstance()->remObserver( mBrowserWindowId, this );
				LLQtWebKit::getInstance()->reset();
			}
			else if(message_name == "shm_added")
			{
				SharedSegmentInfo info;
				info.mAddress = message_in.getValuePointer("address");
				info.mSize = (size_t)message_in.getValueS32("size");
				std::string name = message_in.getValue("name");
				
//				std::cerr << "MediaPluginWebKit::receiveMessage: shared memory added, name: " << name 
//					<< ", size: " << info.mSize 
//					<< ", address: " << info.mAddress 
//					<< std::endl;

				mSharedSegments.insert(SharedSegmentMap::value_type(name, info));
			
			}
			else if(message_name == "shm_remove")
			{
				std::string name = message_in.getValue("name");
				
//				std::cerr << "MediaPluginWebKit::receiveMessage: shared memory remove, name = " << name << std::endl;

				SharedSegmentMap::iterator iter = mSharedSegments.find(name);
				if(iter != mSharedSegments.end())
				{
					if(mPixels == iter->second.mAddress)
					{
						// This is the currently active pixel buffer.  Make sure we stop drawing to it.
						mPixels = NULL;
						mTextureSegmentName.clear();
					}
					mSharedSegments.erase(iter);
				}
				else
				{
//					std::cerr << "MediaPluginWebKit::receiveMessage: unknown shared memory region!" << std::endl;
				}

				// Send the response so it can be cleaned up.
				LLPluginMessage message("base", "shm_remove_response");
				message.setValue("name", name);
				sendMessage(message);
			}
			else
			{
//				std::cerr << "MediaPluginWebKit::receiveMessage: unknown base message: " << message_name << std::endl;
			}
		}
		else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME)
		{
			if(message_name == "set_volume")
			{
				F32 volume = message_in.getValueReal("volume");
				setVolume(volume);
			}
		}
		else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA)
		{
			if(message_name == "init")
			{
				// This is the media init message -- all necessary data for initialization should have been received.
				if(initBrowser())
				{
					
					// Plugin gets to decide the texture parameters to use.
					mDepth = 4;

					LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "texture_params");
					message.setValueS32("default_width", 1024);
					message.setValueS32("default_height", 1024);
					message.setValueS32("depth", mDepth);
					message.setValueU32("internalformat", GL_RGBA);
	#if LL_QTWEBKIT_USES_PIXMAPS
					message.setValueU32("format", GL_BGRA_EXT); // I hope this isn't system-dependant... is it?  If so, we'll have to check the root window's pixel layout or something... yuck.
	#else
					message.setValueU32("format", GL_RGBA);
	#endif // LL_QTWEBKIT_USES_PIXMAPS
					message.setValueU32("type", GL_UNSIGNED_BYTE);
					message.setValueBoolean("coords_opengl", true);
					sendMessage(message);
				}
				else
				{
					// if initialization failed, we're done.
					mDeleteMe = true;
				}

			}
			else if(message_name == "set_user_data_path")
			{
				std::string user_data_path = message_in.getValue("path"); // n.b. always has trailing platform-specific dir-delimiter
				mProfileDir = user_data_path + "browser_profile";

				// FIXME: Should we do anything with this if it comes in after the browser has been initialized?
			}
			else if(message_name == "set_language_code")
			{
				mHostLanguage = message_in.getValue("language");

				// FIXME: Should we do anything with this if it comes in after the browser has been initialized?
			}
			else if(message_name == "plugins_enabled")
			{
				mPluginsEnabled = message_in.getValueBoolean("enable");
			}
			else if(message_name == "javascript_enabled")
			{
				mJavascriptEnabled = message_in.getValueBoolean("enable");
			}
			else if(message_name == "size_change")
			{
				std::string name = message_in.getValue("name");
				S32 width = message_in.getValueS32("width");
				S32 height = message_in.getValueS32("height");
				S32 texture_width = message_in.getValueS32("texture_width");
				S32 texture_height = message_in.getValueS32("texture_height");
				mBackgroundR = message_in.getValueReal("background_r");
				mBackgroundG = message_in.getValueReal("background_g");
				mBackgroundB = message_in.getValueReal("background_b");
//				mBackgroundA = message_in.setValueReal("background_a");		// Ignore any alpha
								
				if(!name.empty())
				{
					// Find the shared memory region with this name
					SharedSegmentMap::iterator iter = mSharedSegments.find(name);
					if(iter != mSharedSegments.end())
					{
						mPixels = (unsigned char*)iter->second.mAddress;
						mWidth = width;
						mHeight = height;

						if(initBrowserWindow())
						{

							// size changed so tell the browser
							LLQtWebKit::getInstance()->setSize( mBrowserWindowId, mWidth, mHeight );
							
	//						std::cerr << "webkit plugin: set size to " << mWidth << " x " << mHeight 
	//								<< ", rowspan is " << LLQtWebKit::getInstance()->getBrowserRowSpan(mBrowserWindowId) << std::endl;
									
							S32 real_width = LLQtWebKit::getInstance()->getBrowserRowSpan(mBrowserWindowId) / LLQtWebKit::getInstance()->getBrowserDepth(mBrowserWindowId); 
							
							// The actual width the browser will be drawing to is probably smaller... let the host know by modifying texture_width in the response.
							if(real_width <= texture_width)
							{
								texture_width = real_width;
							}
							else
							{
								// This won't work -- it'll be bigger than the allocated memory.  This is a fatal error.
	//							std::cerr << "Fatal error: browser rowbytes greater than texture width" << std::endl;
								mDeleteMe = true;
								return;
							}
						}
						else
						{
							// Setting up the browser window failed.  This is a fatal error.
							mDeleteMe = true;
						}

						
						mTextureWidth = texture_width;
						mTextureHeight = texture_height;
						
					};
				};

				LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "size_change_response");
				message.setValue("name", name);
				message.setValueS32("width", width);
				message.setValueS32("height", height);
				message.setValueS32("texture_width", texture_width);
				message.setValueS32("texture_height", texture_height);
				sendMessage(message);

			}
			else if(message_name == "load_uri")
			{
				std::string uri = message_in.getValue("uri");

//				std::cout << "loading URI: " << uri << std::endl;
				
				if(!uri.empty())
				{
					if(mInitState >= INIT_STATE_NAVIGATE_COMPLETE)
					{
						LLQtWebKit::getInstance()->navigateTo( mBrowserWindowId, uri );
					}
					else
					{
						mInitialNavigateURL = uri;
					}
				}
			}
			else if(message_name == "mouse_event")
			{
				std::string event = message_in.getValue("event");
				S32 button = message_in.getValueS32("button");
				mLastMouseX = message_in.getValueS32("x");
				mLastMouseY = message_in.getValueS32("y");
				std::string modifiers = message_in.getValue("modifiers");
				
				// Treat unknown mouse events as mouse-moves.
				LLQtWebKit::EMouseEvent mouse_event = LLQtWebKit::ME_MOUSE_MOVE;
				if(event == "down")
				{
					mouse_event = LLQtWebKit::ME_MOUSE_DOWN;
				}
				else if(event == "up")
				{
					mouse_event = LLQtWebKit::ME_MOUSE_UP;
				}
				else if(event == "double_click")
				{
					mouse_event = LLQtWebKit::ME_MOUSE_DOUBLE_CLICK;
				}
				
				LLQtWebKit::getInstance()->mouseEvent( mBrowserWindowId, mouse_event, button, mLastMouseX, mLastMouseY, decodeModifiers(modifiers));
				checkEditState();
			}
			else if(message_name == "scroll_event")
			{
				S32 x = message_in.getValueS32("x");
				S32 y = message_in.getValueS32("y");
				std::string modifiers = message_in.getValue("modifiers");
				
				// Incoming scroll events are adjusted so that 1 detent is approximately 1 unit.
				// Qt expects 1 detent to be 120 units.
				// It also seems that our y scroll direction is inverted vs. what Qt expects.
				
				x *= 120;
				y *= -120;
				
				LLQtWebKit::getInstance()->scrollWheelEvent(mBrowserWindowId, mLastMouseX, mLastMouseY, x, y, decodeModifiers(modifiers));
			}
			else if(message_name == "key_event")
			{
				std::string event = message_in.getValue("event");
				S32 key = message_in.getValueS32("key");
				std::string modifiers = message_in.getValue("modifiers");
				LLSD native_key_data = message_in.getValueLLSD("native_key_data");
				
				// Treat unknown events as key-up for safety.
				LLQtWebKit::EKeyEvent key_event = LLQtWebKit::KE_KEY_UP;
				if(event == "down")
				{
					key_event = LLQtWebKit::KE_KEY_DOWN;
				}
				else if(event == "repeat")
				{
					key_event = LLQtWebKit::KE_KEY_REPEAT;
				}
				
				keyEvent(key_event, key, decodeModifiers(modifiers), native_key_data);
			}
			else if(message_name == "text_event")
			{
				std::string text = message_in.getValue("text");
				std::string modifiers = message_in.getValue("modifiers");
				LLSD native_key_data = message_in.getValueLLSD("native_key_data");
				
				unicodeInput(text, decodeModifiers(modifiers), native_key_data);
			}
			if(message_name == "edit_cut")
			{
				LLQtWebKit::getInstance()->userAction( mBrowserWindowId, LLQtWebKit::UA_EDIT_CUT );
				checkEditState();
			}
			if(message_name == "edit_copy")
			{
				LLQtWebKit::getInstance()->userAction( mBrowserWindowId, LLQtWebKit::UA_EDIT_COPY );
				checkEditState();
			}
			if(message_name == "edit_paste")
			{
				LLQtWebKit::getInstance()->userAction( mBrowserWindowId, LLQtWebKit::UA_EDIT_PASTE );
				checkEditState();
			}
			else
			{
//				std::cerr << "MediaPluginWebKit::receiveMessage: unknown media message: " << message_string << std::endl;
			};
		}
		else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER)
		{
			if(message_name == "focus")
			{
				bool val = message_in.getValueBoolean("focused");
				LLQtWebKit::getInstance()->focusBrowser( mBrowserWindowId, val );
				
				if(mFirstFocus && val)
				{
					// On the first focus, post a tab key event.  This fixes a problem with initial focus.
					std::string empty;
					keyEvent(LLQtWebKit::KE_KEY_DOWN, KEY_TAB, decodeModifiers(empty));
					keyEvent(LLQtWebKit::KE_KEY_UP, KEY_TAB, decodeModifiers(empty));
					mFirstFocus = false;
				}
			}
			else if(message_name == "clear_cache")
			{
				LLQtWebKit::getInstance()->clearCache();
			}
			else if(message_name == "clear_cookies")
			{
				LLQtWebKit::getInstance()->clearAllCookies();
			}
			else if(message_name == "enable_cookies")
			{
				mCookiesEnabled = message_in.getValueBoolean("enable");
				LLQtWebKit::getInstance()->enableCookies( mCookiesEnabled );
			}
			else if(message_name == "enable_plugins")
			{
				mPluginsEnabled = message_in.getValueBoolean("enable");
				LLQtWebKit::getInstance()->enablePlugins( mPluginsEnabled );
			}
			else if(message_name == "enable_javascript")
			{
				mJavascriptEnabled = message_in.getValueBoolean("enable");
				//LLQtWebKit::getInstance()->enableJavascript( mJavascriptEnabled );
			}
			else if(message_name == "proxy_setup")
			{
				bool val = message_in.getValueBoolean("enable");
				std::string host = message_in.getValue("host");
				int port = message_in.getValueS32("port");
				LLQtWebKit::getInstance()->enableProxy( val, host, port );
			}
			else if(message_name == "browse_stop")
			{
				LLQtWebKit::getInstance()->userAction( mBrowserWindowId, LLQtWebKit::UA_NAVIGATE_STOP );
			}
			else if(message_name == "browse_reload")
			{
				// foo = message_in.getValueBoolean("ignore_cache");
				LLQtWebKit::getInstance()->userAction( mBrowserWindowId, LLQtWebKit::UA_NAVIGATE_RELOAD );
			}
			else if(message_name == "browse_forward")
			{
				LLQtWebKit::getInstance()->userAction( mBrowserWindowId, LLQtWebKit::UA_NAVIGATE_FORWARD );
			}
			else if(message_name == "browse_back")
			{
				LLQtWebKit::getInstance()->userAction( mBrowserWindowId, LLQtWebKit::UA_NAVIGATE_BACK );
			}
			else if(message_name == "set_status_redirect")
			{
				int code = message_in.getValueS32("code");
				std::string url = message_in.getValue("url");
				if ( 404 == code )	// browser lib only supports 404 right now
				{
					LLQtWebKit::getInstance()->set404RedirectUrl( mBrowserWindowId, url );
				};
			}
			else if(message_name == "set_user_agent")
			{
				mUserAgent = message_in.getValue("user_agent");
				LLQtWebKit::getInstance()->setBrowserAgentId( mUserAgent );
			}
			else if(message_name == "init_history")
			{
				// Initialize browser history
				LLSD history = message_in.getValueLLSD("history");
				// First, clear the URL history
				LLQtWebKit::getInstance()->clearHistory(mBrowserWindowId);
				// Then, add the history items in order
				LLSD::array_iterator iter_history = history.beginArray();
				LLSD::array_iterator end_history = history.endArray();
				for(; iter_history != end_history; ++iter_history)
				{
					std::string url = (*iter_history).asString();
					if(! url.empty()) {
						LLQtWebKit::getInstance()->prependHistoryUrl(mBrowserWindowId, url);
					}
				}
			}
			else
			{
//				std::cerr << "MediaPluginWebKit::receiveMessage: unknown media_browser message: " << message_string << std::endl;
			};
		}
		else
		{
//			std::cerr << "MediaPluginWebKit::receiveMessage: unknown message class: " << message_class << std::endl;
		};
	}
}
Esempio n. 17
0
void Messaging::acknowledge(in_addr_t ip, uint16_t port, MessageId messageId) {
  DLOG << "Replying with empty acknowledge message with msgID=" << messageId << '\n';
  auto msg = Message(Type::Acknowledgement, messageId, Code::Empty, 0, "", "");
  sendMessage(ip, port, msg);
}
Esempio n. 18
0
 //--------------------------------------------------------------
 void OscSender::sceneUpdated( Scene & s ){
     ofxOscMessage m = s.getOscMessage( "/TSPS/scene/" );
     sendMessage( m );
 }
Esempio n. 19
0
void MainWindow::createMessageEdit() {
  this->messageEdit = new QLineEdit();
  connect(messageEdit, SIGNAL(returnPressed()), this, SLOT(sendMessage()));
}
Esempio n. 20
0
 //--------------------------------------------------------------
 void OscSender::send ( ofxOscMessage m ){
     sendMessage(m);
 };
Esempio n. 21
0
   void BrothaApp::onKeyPress(SDLKey sym, bool down)
   {
      if (sym == SDLK_F12) {
         if (mCurrentState) {
            mCurrentState->draw();
            PrintingEngine::print();
         }
      } else {
         if (mCurrentState) {
            mCurrentState->onKeyPress(sym, down);
         }
      }
      return;  /// @todo   put the rest of this stuff in the game state

//      game::Player* player = getLocalPlayer();
      net::UpdatePlayerInfoMessage::UpdateWhat what = net::UpdatePlayerInfoMessage::NOTHING;
      PRFloat64 to = (down ? 1 : 0);

      if (sym == SDLK_w) {
         what = net::UpdatePlayerInfoMessage::ACCELERATION;
      } else if (sym == SDLK_s) {
         what = net::UpdatePlayerInfoMessage::BRAKE;
      } else if (sym == SDLK_SPACE) {
         what = net::UpdatePlayerInfoMessage::HANDBRAKE;
      } else if (sym == SDLK_a) {
         what = net::UpdatePlayerInfoMessage::TURNLEFT;
      } else if (sym == SDLK_d) {
         what = net::UpdatePlayerInfoMessage::TURNRIGHT;
      }

      if(what != net::UpdatePlayerInfoMessage::NOTHING) {
         sendMessage(new net::UpdatePlayerInfoMessage(what, to));
      }

      /*
      

      // test for quit
      if (mQuit.getDigitalData() == gk::DigitalInput::DOWN)
      {
         std::cout<<net::Message::mNumMsgsInMemory<<" Messages leaked"<<std::endl;
         mKernel->shutdown();
      }

      // un/pause game
      if (mPause.getDigitalData() == gk::DigitalInput::EDGE_DOWN)
      {
         mGame.setPaused( ! mGame.isPaused() );
      }

      // only deal with player related input if there is a local player
      if ( player != NULL )
      {
         // accelerate
         if (mAccelerate.getDigitalData() == gk::DigitalInput::EDGE_DOWN)
         {
            player->setAcceleration( 1 );
         }
         else if (mAccelerate.getDigitalData() == gk::DigitalInput::EDGE_UP)
         {
            player->setAcceleration( 0 );
         }

         // brake
         if (mBrake.getDigitalData() == gk::DigitalInput::EDGE_DOWN)
         {
            player->setBrake( 1 );
         }
         else if (mBrake.getDigitalData() == gk::DigitalInput::EDGE_UP)
         {
            player->setBrake( 0 );
         }

         // turn left
         if (mTurnLeft.getDigitalData() == gk::DigitalInput::EDGE_DOWN)
         {
            player->setTurnAngle( 1 );
         }
         else if (mTurnLeft.getDigitalData() == gk::DigitalInput::EDGE_UP)
         {
            player->setTurnAngle( 0 );
         }

         // turn right
         if (mTurnRight.getDigitalData() == gk::DigitalInput::EDGE_DOWN)
         {
            player->setTurnAngle( 0 );
         }
         else if (mTurnRight.getDigitalData() == gk::DigitalInput::EDGE_UP)
         {
            player->setTurnAngle( -1 );
         }
      }
*/
   }
Esempio n. 22
0
void MessageSendController::processMessage(int inletIndex, PdMessage *message) {
    sendMessage(inletIndex, message);
}
Esempio n. 23
0
void LLPluginClassMedia::clear_cookies()
{
	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "clear_cookies");
	sendMessage(message);
}
Esempio n. 24
0
int ApiServerMHD::accessHandlerCallback(MHD_Connection *connection,
                                       const char *url, const char *method, const char *version,
                                       const char *upload_data, size_t *upload_data_size,
                                       void **con_cls)
{
    // is this call a continuation for an existing request?
    if(*con_cls)
    {
        return ((MHDHandlerBase*)(*con_cls))->handleRequest(connection, url, method, version, upload_data, upload_data_size);
    }

    // these characters are not allowe in the url, raise an error if they occur
    // reason: don't want to serve files outside the current document root
    const char *double_dots = "..";
    if(strstr(url, double_dots))
    {
        const char *error = "<html><body><p>Fatal error: found double dots (\"..\") in the url. This is not allowed</p></body></html>";
        struct MHD_Response* resp = MHD_create_response_from_data(strlen(error), (void*)error, 0, 1);
        MHD_add_response_header(resp, "Content-Type", "text/html");
        secure_queue_response(connection, MHD_HTTP_INTERNAL_SERVER_ERROR, resp);
        MHD_destroy_response(resp);
        return MHD_YES;
    }

    // if no path is given, redirect to index.html in static files directory
    if(strlen(url) == 1 && url[0] == '/')
    {
        std::string location = std::string(STATIC_FILES_ENTRY_PATH) + "index.html";
        std::string errstr = "<html><body><p>Webinterface is at <a href=\""+location+"\">"+location+"</a></p></body></html>";
        const char *error = errstr.c_str();
        struct MHD_Response* resp = MHD_create_response_from_data(strlen(error), (void*)error, 0, 1);
        MHD_add_response_header(resp, "Content-Type", "text/html");
        MHD_add_response_header(resp, "Location", location.c_str());
        secure_queue_response(connection, MHD_HTTP_FOUND, resp);
        MHD_destroy_response(resp);
        return MHD_YES;
    }
    // is it a call to the resource api?
    if(strstr(url, API_ENTRY_PATH) == url)
    {
        // create a new handler and store it in con_cls
        MHDHandlerBase* handler = new MHDApiHandler(mApiServer);
        *con_cls = (void*) handler;
        return handler->handleRequest(connection, url, method, version, upload_data, upload_data_size);
    }
    // is it a call to the filestreamer?
    if(strstr(url, FILESTREAMER_ENTRY_PATH) == url)
    {
#ifdef ENABLE_FILESTREAMER
        // create a new handler and store it in con_cls
        MHDHandlerBase* handler = new MHDFilestreamerHandler();
        *con_cls = (void*) handler;
        return handler->handleRequest(connection, url, method, version, upload_data, upload_data_size);
#else
        sendMessage(connection, MHD_HTTP_NOT_FOUND, "The filestreamer is not available, because this executable was compiled with a too old version of libmicrohttpd.");
        return MHD_YES;
#endif
    } 
    // is it a path to the static files?
    if(strstr(url, STATIC_FILES_ENTRY_PATH) == url)
    {
        url = url + strlen(STATIC_FILES_ENTRY_PATH);
        // else server static files
        std::string filename = mRootDir + url;
        // important: binary open mode (windows)
        // else libmicrohttpd will replace crlf with lf and add garbage at the end of the file
#ifdef O_BINARY
        int fd = open(filename.c_str(), O_RDONLY | O_BINARY);
#else
        int fd = open(filename.c_str(), O_RDONLY);
#endif
        if(fd == -1)
        {
#warning sending untrusted string to the browser
            std::string msg = "<html><body><p>Error: can't open the requested file. Path is &quot;"+filename+"&quot;</p></body></html>";
            sendMessage(connection, MHD_HTTP_NOT_FOUND, msg);
            return MHD_YES;
        }

        struct stat s;
        if(fstat(fd, &s) == -1)
        {
            close(fd);
            const char *error = "<html><body><p>Error: file was opened but stat failed.</p></body></html>";
            struct MHD_Response* resp = MHD_create_response_from_data(strlen(error), (void*)error, 0, 1);
            MHD_add_response_header(resp, "Content-Type", "text/html");
            secure_queue_response(connection, MHD_HTTP_NOT_FOUND, resp);
            MHD_destroy_response(resp);
            return MHD_YES;
        }

        // find the file extension and the content type
        std::string extension;
        int i = filename.size()-1;
        while(i >= 0 && filename[i] != '.')
        {
            extension = filename[i] + extension;
            i--;
        }
        const char* type = 0;
        if(extension == "html")
            type = "text/html";
        else if(extension == "css")
            type = "text/css";
        else if(extension == "js")
            type = "text/javascript";
        else if(extension == "jsx") // react.js jsx files
            type = "text/jsx";
        else if(extension == "png")
            type = "image/png";
        else if(extension == "jpg" || extension == "jpeg")
            type = "image/jpeg";
        else if(extension == "gif")
            type = "image/gif";
        else
            type = "application/octet-stream";

        struct MHD_Response* resp = MHD_create_response_from_fd(s.st_size, fd);
        MHD_add_response_header(resp, "Content-Type", type);
        secure_queue_response(connection, MHD_HTTP_OK, resp);
        MHD_destroy_response(resp);
        return MHD_YES;
    }

    if(strstr(url, UPLOAD_ENTRY_PATH) == url)
    {
        // create a new handler and store it in con_cls
        MHDHandlerBase* handler = new MHDUploadHandler(mApiServer);
        *con_cls = (void*) handler;
        return handler->handleRequest(connection, url, method, version, upload_data, upload_data_size);
    }

    // if url is not a valid path, then serve a help page
    sendMessage(connection, MHD_HTTP_NOT_FOUND,
                "This address is invalid. Try one of the adresses below:<br/>"
                "<ul>"
                "<li>/ <br/>Retroshare webinterface</li>"
                "<li>"+std::string(API_ENTRY_PATH)+" <br/>JSON over http api</li>"
                "<li>"+std::string(FILESTREAMER_ENTRY_PATH)+" <br/>file streamer</li>"
                "<li>"+std::string(STATIC_FILES_ENTRY_PATH)+" <br/>static files</li>"
                "</ul>"
                );
    return MHD_YES;
}
Esempio n. 25
0
void LLPluginClassMedia::enable_cookies(bool enable)
{
	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "enable_cookies");
	message.setValueBoolean("enable", enable);
	sendMessage(message);
}
Esempio n. 26
0
static void runTest(struct TwoNodes* tn)
{
    sendMessage(tn, "Hello World!", tn->nodeA, tn->nodeB);
    sendMessage(tn, "Hello cjdns!", tn->nodeB, tn->nodeA);
    sendMessage(tn, "send", tn->nodeA, tn->nodeB);
    sendMessage(tn, "a", tn->nodeB, tn->nodeA);
    sendMessage(tn, "few", tn->nodeA, tn->nodeB);
    sendMessage(tn, "packets", tn->nodeB, tn->nodeA);
    sendMessage(tn, "to", tn->nodeA, tn->nodeB);
    sendMessage(tn, "make", tn->nodeB, tn->nodeA);
    sendMessage(tn, "sure", tn->nodeA, tn->nodeB);
    sendMessage(tn, "the", tn->nodeB, tn->nodeA);
    sendMessage(tn, "cryptoauth", tn->nodeA, tn->nodeB);
    sendMessage(tn, "can", tn->nodeB, tn->nodeA);
    sendMessage(tn, "establish", tn->nodeA, tn->nodeB);

    Log_debug(tn->logger, "\n\nTest passed, shutting down\n\n");
    EventBase_endLoop(tn->base);
}
Esempio n. 27
0
void LLPluginClassMedia::ignore_ssl_cert_errors(bool ignore)
{
	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "ignore_ssl_cert_errors");
	message.setValueBoolean("ignore", ignore);
	sendMessage(message);
}
Esempio n. 28
0
bool QtLocalPeer::sendMessage(const QString &message, int timeout)
{
    return sendMessage(message.toUtf8(), timeout);
}
Esempio n. 29
0
void LLPluginClassMedia::crashPlugin()
{
	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_INTERNAL, "crash");

	sendMessage(message);
}
Esempio n. 30
0
void LLPluginClassMedia::setLanguageCode(const std::string &language_code)
{
	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "set_language_code");
	message.setValue("language", language_code);
	sendMessage(message);
}