Beispiel #1
0
//------------------------------------------------------------------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------------------------------------------------------------------
void Window::onInputEvent( const Message& message )
{
	switch( message.type )
	{
	case mtKeyDown:
		{
			const MessageKeyDown* messagePointer = static_cast<const MessageKeyDown*>(&message);				
			NOTIFY_LISTENERS( onKeyDown( this, messagePointer->keyCode ) );
			break;
		}
	case mtPointerButtonUp:
			NOTIFY_LISTENERS( onClick( this ) );
			break;
	}	
}
Beispiel #2
0
/**
 * pka_manager_remove_source:
 * @context: A #PkaContext.
 * @source: A #PkaSource.
 * @error: A location for a #GError, or %NULL.
 *
 * Removes @source from the Perfkit Agent.  If the context does not have
 * permissions, this operation will fail.
 *
 * Returns: %TRUE if successful; otherwise %FALSE.
 * Side effects: None.
 */
gboolean
pka_manager_remove_source (PkaContext  *context, /* IN */
                           PkaSource   *source,  /* IN */
                           GError     **error)   /* OUT */
{
	gboolean found;
	gint source_id;

	g_return_val_if_fail(context != NULL, FALSE);
	g_return_val_if_fail(PKA_IS_SOURCE(source), FALSE);

	ENTRY;
	AUTHORIZE_IOCTL(context, REMOVE_SOURCE);
	pka_source_notify_stopped(source);
	source_id = pka_source_get_id(source);
	INFO(Source, "Removing source %d on behalf of context %d.",
	     source_id, pka_context_get_id(context));
	G_LOCK(sources);
	found = g_ptr_array_remove(manager.sources, source);
	G_UNLOCK(sources);
	if (found) {
		NOTIFY_LISTENERS(source_removed, source_id);
		g_object_unref(source);
	}
	RETURN(found);
}
Beispiel #3
0
//------------------------------------------------------------------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------------------------------------------------------------------
void Window::onInputEvent( const Message& message )
{
	switch( message.type )
	{
		case mtPointerButtonDown:
			m_buttonPressed = true;
			break;

		case mtPointerButtonUp:
			NOTIFY_LISTENERS( onClick( this ) );
			m_buttonPressed = false;

			break;
		case mtPointerMove:
			const MessagePointerMove* messagePointer = static_cast<const MessagePointerMove*>(&message);			
			
			if (m_buttonPressed)
			{	
				m_position.x += messagePointer->x - m_prevX;
				m_position.y += messagePointer->y - m_prevY;
			}

			m_prevX = messagePointer->x;
			m_prevY = messagePointer->y;
			
			break;
	
	}	
}
Beispiel #4
0
/**
 * pka_manager_remove_channel:
 * @context: A #PkaContext.
 * @channel: A #PkaChannel.
 * @error: A location for a #GError, or %NULL.
 *
 * Removes @channel from the Perfkit Agent.  If the context does not have
 * permissions, the operation will fail.
 *
 * Returns: %TRUE if successful; otherwise %FALSE.
 * Side effects: None.
 */
gboolean
pka_manager_remove_channel (PkaContext  *context, /* IN */
                            PkaChannel  *channel, /* IN */
                            GError     **error)   /* OUT */
{
	gint channel_id;

	g_return_val_if_fail(context != NULL, FALSE);
	g_return_val_if_fail(PKA_IS_CHANNEL(channel), FALSE);

	ENTRY;
	AUTHORIZE_IOCTL(context, REMOVE_CHANNEL);
	/*
	 * TODO:
	 *
	 *   1) Ensure the channel is completely stopped.
	 *   2) Ensure the channels sources are stopped.
	 *   3) Notify the subscriptions the channel is gone.
	 *   4) Notify the listeners the subscription is gone.
	 *
	 */
	if (FALSE) {
		channel_id = pka_channel_get_id(channel);
		INFO(Channel, "Removing channel %d on behalf of context %d.",
		     channel_id, pka_context_get_id(context));
		G_LOCK(channels);
		g_ptr_array_remove(manager.channels, channel);
		G_UNLOCK(channels);
		NOTIFY_LISTENERS(channel_removed, channel_id);
		g_object_unref(channel);
	}
	RETURN(TRUE);
}
Beispiel #5
0
void Slider::onInputEvent( const Message& message )
{
	switch( message.type )
	{
		case mtPointerButtonDown:
			m_buttonPressed = true;
			break;

		case mtPointerButtonUp:
			NOTIFY_LISTENERS( onClick( this ) );
			m_buttonPressed = false;

			break;
		case mtPointerMove:
			const MessagePointerMove* messagePointer = static_cast<const MessagePointerMove*>(&message);			
			
			if (m_buttonPressed)
			{	
				float inc = m_maxValue / m_steps;
				m_actualValue +=  (messagePointer->x - m_prevX) / inc;
				
			}

			m_prevX = messagePointer->x;
			
			
			break;
	
	}		
}
Beispiel #6
0
/**
 * This function is called to end sending of messages, it resets the send later
 * system and notifies the relevant parties that we have finished.
 */
void
nsMsgSendLater::EndSendMessages(nsresult aStatus, const PRUnichar *aMsg,
                                uint32_t aTotalTried, uint32_t aSuccessful)
{
  // Catch-all, we may have had an issue sending, so we may not be calling
  // StartNextMailFileSend to fully finish the sending. Therefore set
  // mSendingMessages to false here so that we don't think we're still trying
  // to send messages
  mSendingMessages = false;

  // Clear out our array of messages.
  mMessagesToSend.Clear();

  // We don't need to keep hold of the database now we've finished sending.
  (void)mMessageFolder->SetMsgDatabase(nullptr);

  // or the enumerator, temp file or output stream
  mEnumerator = nullptr;
  mTempFile = nullptr;
  mOutFile = nullptr;  

  NOTIFY_LISTENERS(OnStopSending, (aStatus, aMsg, aTotalTried, aSuccessful));

  // If we've got a shutdown listener, notify it that we've finished.
  if (mShutdownListener)
  {
    mShutdownListener->OnStopRunningUrl(nullptr, NS_OK);
    mShutdownListener = nullptr;
  }
}
Beispiel #7
0
/**
 * pka_manager_remove_encoder:
 * @context: A #PkaContext.
 * @encoder: A #PkaEncoder.
 * @error: A location for a #GError, or %NULL.
 *
 * Removes @encoder from the Perfkit Agent.  If the context does not have
 * permissions, this operation will fail.
 *
 * Returns: %TRUE if succesful; otherwise %FALSE.
 * Side effects: None.
 */
gboolean
pka_manager_remove_encoder (PkaContext  *context, /* IN */
                            PkaEncoder  *encoder, /* IN */
                            GError     **error)   /* OUT */
{
	gint encoder_id;

	g_return_val_if_fail(context != NULL, FALSE);
	g_return_val_if_fail(PKA_IS_ENCODER(encoder), FALSE);

	ENTRY;
	AUTHORIZE_IOCTL(context, REMOVE_ENCODER);
	/*
	 * TODO:
	 *
	 *   1) Enure the encoder is not attached to a running channel.
	 *
	 */
	if (FALSE) {
		encoder_id = pka_encoder_get_id(encoder);
		INFO(Encoder, "Removing encoder %d on behalf of context %d.",
		     encoder_id, pka_context_get_id(context));
		G_LOCK(encoders);
		g_ptr_array_remove(manager.encoders, encoder);
		G_UNLOCK(encoders);
		NOTIFY_LISTENERS(encoder_removed, encoder_id);
		g_object_unref(encoder);
	}
	RETURN(TRUE);
}
Beispiel #8
0
/**
 * pka_manager_add_source:
 * @context: A #PkaContext.
 * @plugin: A #PkaPlugin.
 * @source: A location for a #PkaSource.
 * @error: A location for a #GError or %NULL.
 *
 * Creates a new source in the Perfkit Agent.  If the context does
 * not have permissions to create the source, this operation will fail.
 *
 * If successful, the newly created instance is stored in @source.
 *
 * The caller owns a reference to the source and should free it with
 * g_object_unref().
 *
 * Returns: %TRUE if successful; otherwise %FALSE.
 * Side effects: None.
 */
gboolean
pka_manager_add_source (PkaContext  *context, /* IN */
                        PkaPlugin   *plugin,  /* IN */
                        PkaSource  **source,  /* OUT */
                        GError     **error)   /* OUT */
{
	gint source_id;

	g_return_val_if_fail(context != NULL, FALSE);
	g_return_val_if_fail(source != NULL, FALSE);
	g_return_val_if_fail(PKA_IS_PLUGIN(plugin), FALSE);

	ENTRY;
	AUTHORIZE_IOCTL(context, ADD_SOURCE);
	if (pka_plugin_get_plugin_type(plugin) != PKA_PLUGIN_SOURCE) {
		g_set_error(error, PKA_PLUGIN_ERROR, PKA_PLUGIN_ERROR_INVALID_TYPE,
		            "The specified plugin is not a source plugin.");
		RETURN(FALSE);
	}
	if (!(*source = PKA_SOURCE(pka_plugin_create(plugin, error)))) {
		RETURN(FALSE);
	}
	source_id = pka_source_get_id(*source);
	INFO(Source, "Added source %d on behalf of context %d.",
	     source_id, pka_context_get_id(context));
	G_LOCK(sources);
	g_ptr_array_add(manager.sources, g_object_ref(*source));
	G_UNLOCK(sources);
	NOTIFY_LISTENERS(source_added, source_id);
	RETURN(TRUE);
}
Beispiel #9
0
/**
 * pka_manager_add_encoder:
 * @context: A #PkaContext.
 * @plugin: A #PkaPlugin.
 * @encoder: A location for a #PkaEncoder.
 * @error: A location for a #GError or %NULL.
 *
 * Creates a new encoder in the Perfkit Agent.  If the context does
 * not have permissions to create an encoder, this operation will fail.
 *
 * If successful, the newly created instance is stored in @encoder.
 *
 * The caller owns a reference to the encoder and should free it with
 * g_object_unref().
 *
 * Returns: %TRUE if successful; otherwise %FALSE.
 * Side effects: None.
 */
gboolean
pka_manager_add_encoder (PkaContext  *context, /* IN */
                         PkaPlugin   *plugin,  /* IN */
                         PkaEncoder **encoder, /* OUT */
                         GError     **error)   /* OUT */
{
	gint encoder_id;

	g_return_val_if_fail(context != NULL, FALSE);
	g_return_val_if_fail(encoder != NULL, FALSE);
	g_return_val_if_fail(PKA_IS_PLUGIN(plugin), FALSE);

	ENTRY;
	AUTHORIZE_IOCTL(context, ADD_ENCODER);
	if (pka_plugin_get_plugin_type(plugin) != PKA_PLUGIN_ENCODER) {
		g_set_error(error, PKA_PLUGIN_ERROR, PKA_PLUGIN_ERROR_INVALID_TYPE,
		            "The specified plugin is not an encoder plugin.");
		RETURN(FALSE);
	}
	if (!(*encoder = PKA_ENCODER(pka_plugin_create(plugin, error)))) {
		RETURN(FALSE);
	}
	encoder_id = pka_encoder_get_id(*encoder);
	INFO(Encoder, "Added encoder %d on behalf of context %d.",
	     encoder_id, pka_context_get_id(context));
	G_LOCK(encoders);
	g_ptr_array_add(manager.encoders, g_object_ref(*encoder));
	G_UNLOCK(encoders);
	NOTIFY_LISTENERS(encoder_added, encoder_id);
	RETURN(TRUE);
}
Beispiel #10
0
void
nsMsgSendLater::NotifyListenersOnMessageSendError(uint32_t aCurrentMessage,
                                                  nsresult aStatus,
                                                  const PRUnichar *aMsg)
{
  NOTIFY_LISTENERS(OnMessageSendError, (aCurrentMessage, mMessage,
                                        aStatus, aMsg));
}
Beispiel #11
0
void
nsMsgSendLater::NotifyListenersOnMessageStartSending(uint32_t aCurrentMessage,
                                                     uint32_t aTotalMessage,
                                                     nsIMsgIdentity *aIdentity)
{
  NOTIFY_LISTENERS(OnMessageStartSending, (aCurrentMessage, aTotalMessage,
                                           mMessage, aIdentity));
}
Beispiel #12
0
//------------------------------------------------------------------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------------------------------------------------------------------
void Window::onInputEvent( const Message& message )
{
	switch( message.type )
	{
	case mtPointerButtonUp:
		NOTIFY_LISTENERS( onClick( this ) );
		break;
	}	
}
Beispiel #13
0
void
nsMsgSendLater::NotifyListenersOnProgress(uint32_t aCurrentMessage,
                                          uint32_t aTotalMessage,
                                          uint32_t aSendPercent,
                                          uint32_t aCopyPercent)
{
  NOTIFY_LISTENERS(OnMessageSendProgress, (aCurrentMessage, aTotalMessage,
                                           aSendPercent, aCopyPercent));
}
Beispiel #14
0
void Label::onInputEvent( const Message& message )
{
	switch( message.type )
	{
		case mtPointerButtonDown:
			if (m_acceptPush)
				m_pushed = true;			
			break;

		case mtPointerButtonUp:
			if( m_pushed )
				NOTIFY_LISTENERS( onClick( this ) );
			m_pushed = false;			
			break;
	}
}
Beispiel #15
0
/**
 * pka_manager_add_subscription:
 * @context: A #PkaContext.
 * @subscription: A location for a #PkaSubscription.
 * @error: A location for a #GError, or %NULL.
 *
 * Adds a new subscription to the Perfkit Agent.  If the context does
 * not have permissions to create a subscription, this operation will fail.
 *
 * If successful, the newly created subscription instance is stored in
 * @subscription.  The caller owns a reference to the subscription and
 * should free it with pka_subscription_unref().
 *
 * Returns: %TRUE is successful; otherwise %FALSE.
 * Side effects: None.
 */
gboolean
pka_manager_add_subscription (PkaContext       *context,      /* IN */
                              PkaSubscription **subscription, /* OUT */
                              GError          **error)        /* OUT */
{
	g_return_val_if_fail(context != NULL, FALSE);
	g_return_val_if_fail(subscription != NULL, FALSE);

	ENTRY;
	AUTHORIZE_IOCTL(context, ADD_SUBSCRIPTION);
	*subscription = pka_subscription_new();
	INFO(Subscription, "Added subscription %d on behalf of context %d.",
	     pka_subscription_get_id(*subscription),
	     pka_context_get_id(context));
	G_LOCK(subscriptions);
	g_ptr_array_add(manager.subscriptions,
	                pka_subscription_ref(*subscription));
	G_UNLOCK(subscriptions);
	NOTIFY_LISTENERS(subscription_added, pka_subscription_get_id(*subscription));
	RETURN(TRUE);
}
Beispiel #16
0
/**
 * pka_manager_add_channel:
 * @context: A #PkaContext.
 * @channel: A location for a #PkaChannel.
 * @error: A location for #GError or %NULL.
 *
 * Adds a channel to the Perfkit Agent.  If the context does not have
 * sufficient permissions this operation will fail.
 *
 * If successful, the newly created #PkaChannel is stored in @channel.
 *
 * The channel has a reference owned by the caller and should be
 * freed using g_object_unref().
 *
 * Returns: %TRUE if successful; otherwise %FALSE and @error is set.
 * Side effects: None.
 */
gboolean
pka_manager_add_channel (PkaContext  *context, /* IN */
                         PkaChannel **channel, /* OUT */
                         GError     **error)   /* OUT */
{
	gint channel_id;

	g_return_val_if_fail(context != NULL, FALSE);
	g_return_val_if_fail(channel != NULL, FALSE);

	ENTRY;
	AUTHORIZE_IOCTL(context, ADD_CHANNEL);
	*channel = g_object_new(PKA_TYPE_CHANNEL, NULL);
	channel_id = pka_channel_get_id(*channel);
	INFO(Channel, "Added channel %d on behalf of context %d.",
	     channel_id, pka_context_get_id(context));
	G_LOCK(channels);
	g_ptr_array_add(manager.channels, g_object_ref(*channel));
	G_UNLOCK(channels);
	NOTIFY_LISTENERS(channel_added, channel_id);
	RETURN(TRUE);
}
Beispiel #17
0
/**
 * pka_manager_remove_subscription:
 * @context: A #PkaContext.
 * @subscription: A #PkaSubscription.
 * @error: A location for a #GError, or %NULL.
 *
 * Removes a subscription from the Perfkit Agent.  If the context does not
 * have permissions, this operation will fail.
 *
 * Returns: %TRUE if successful; otherwise %FALSE.
 * Side effects: None.
 */
gboolean
pka_manager_remove_subscription (PkaContext       *context,      /* IN */
                                 PkaSubscription  *subscription, /* IN */
                                 GError          **error)        /* OUT */
{
	gint subscription_id;

	g_return_val_if_fail(context != NULL, FALSE);
	g_return_val_if_fail(subscription != NULL, FALSE);

	ENTRY;
	AUTHORIZE_IOCTL(context, REMOVE_SUBSCRIPTION);
	subscription_id = pka_subscription_get_id(subscription);
	INFO(Subscription, "Removing subscription %d on behalf of context %d",
	     subscription_id, pka_context_get_id(context));
	G_LOCK(subscriptions);
	g_ptr_array_remove(manager.subscriptions, subscription);
	G_UNLOCK(subscriptions);
	NOTIFY_LISTENERS(subscription_removed, subscription_id);
	pka_subscription_unref(subscription);
	RETURN(TRUE);
}
Beispiel #18
0
void
nsMsgSendLater::NotifyListenersOnStartSending(uint32_t aTotalMessageCount)
{
  NOTIFY_LISTENERS(OnStartSending, (aTotalMessageCount));
}
Beispiel #19
0
void mouse_drag_tracker_t::callback(HWND h, UINT m, WPARAM w, LPARAM l)
{
	switch(m)
	{
		case WM_MOUSEMOVE:
		{
			const unsigned int keys = w;
			const int x = LOWORD(l);
			const int y = HIWORD(l);

			if(dragging_button)
				NOTIFY_LISTENERS(drag)
					->on_mouse_drag_move(x, y, dragging_button, keys);

		}	break;

		case WM_LBUTTONDOWN:
		case WM_MBUTTONDOWN:
		case WM_RBUTTONDOWN:
		{
			const unsigned int keys = w;
			const int x = LOWORD(l);
			const int y = HIWORD(l);

			dragging_button = mkeys_t(keys).get_main_button_down_lrm();

			SetCapture(h);

			NOTIFY_LISTENERS(drag)
				->on_mouse_drag_start(x, y, dragging_button, keys);

		}	break;

		case WM_LBUTTONUP:
		case WM_RBUTTONUP:
		case WM_MBUTTONUP:
		{
			const unsigned int keys = w;
			const int x = LOWORD(l);
			const int y = HIWORD(l);

			if(GetCapture() == h)
				ReleaseCapture();

			if(dragging_button)
			{
				NOTIFY_LISTENERS(drag)
					->on_mouse_drag_end(x, y, dragging_button, keys);

				dragging_button = 0;
			}

		}	break;

		case WM_CAPTURECHANGED:
		{
			// const HWND lost_to = (HWND)l;

			if(dragging_button)
			{
				NOTIFY_LISTENERS(drag)
					->on_mouse_drag_lost(dragging_button);

				dragging_button = 0;
			}

		}	break;
	}
}