Ejemplo n.º 1
0
LedNumber LedNumber_Create(LedNumber_Place largestDigit)
{
  LedNumber self;
  int8_t i;

  if (isDigitOutOfBounds(largestDigit))
  {
    return NULL;
  }
  self = calloc(1, sizeof(LedNumberStruct));
  RETURN_VALUE_IF_NULL(self, NULL);

  self->ledDigit = LedDigit_Create();
  RETURN_VALUE_IF_NULL(self->ledDigit, NULL);

  self->digits = calloc(largestDigit+1, sizeof(LedDigit_Value));
  RETURN_VALUE_IF_NULL(self->digits, NULL);
  //Manually initialize because memset will set varialbes as unsigned chars
  for (i = LED_UNITS; i <= largestDigit; i++)
  {
    self->digits[i] = NO_DIGIT;
  }
  self->largestDigit = largestDigit;
  self->visibleDigit = LED_NONE;
  return self;
}
Ejemplo n.º 2
0
OP_STATUS PluginEULADialog::StartLoadingEULA(const OpStringC& mime_type, const OpStringC& plugin_content_url)
{
	if (mime_type.IsEmpty())
		return OpStatus::ERR;

	RETURN_IF_ERROR(m_mime_type.Set(mime_type));
	RETURN_IF_ERROR(m_plugin_content_url.Set(plugin_content_url));

	m_item = g_plugin_install_manager->GetItemForMimeType(mime_type);
	RETURN_VALUE_IF_NULL(m_item, OpStatus::ERR);
	OP_ASSERT(m_item->GetResource());

	OpString eula_url, title_string;
	RETURN_IF_ERROR(m_item->GetResource()->GetAttrValue(URA_EULA_URL, eula_url));
	RETURN_IF_ERROR(m_item->GetStringWithPluginName(Str::S_PLUGIN_AUTO_INSTALL_DIALOG_TITLE_AVAILABLE, title_string));

	QuickLabel* quick_title_label = m_dialog->GetWidgetCollection()->Get<QuickLabel>("plugin_eula_title_label");
	RETURN_VALUE_IF_NULL(quick_title_label, OpStatus::ERR);
	RETURN_IF_ERROR(quick_title_label->SetText(title_string));

	if (eula_url.IsEmpty())
		return OpStatus::ERR;

	OpWindowCommander* window_commander = m_browser_view->GetWindowCommander();
	RETURN_VALUE_IF_NULL(window_commander, OpStatus::ERR);

	// DSK-336850 - Plugin Install wizard: link to plugin EULA appears in browsing history
	window_commander->DisableGlobalHistory();

	// DSK-336843 - "Resizer" appears next to the scrollbars suggesting that EULA viewport can be resized
	// The resizer is OpResizeCorner and in order to disable it we need to change the window type.
	// Should there appear any problems related to changing the type, this needs to be handled in a different way,
	// perhaps by a core patch introducing a new window type for the OpBrowserView widget, or by allowing to control
	// the OpResizeCorner visibility better (see vis_dev.cpp: "corner->SetVisibility(h_on && v_on)").
	window_commander->GetWindow()->SetType(WIN_TYPE_BRAND_VIEW);

	// DSK-336847 - TAB navigation loops inside EULA
	// Don't allow the OpBrowserView to take the focus, it's more important to have tab stops on the dialog 
	// controls - checkbox and button(s).
	m_browser_view->SetTabStop(FALSE);
	m_browser_view->SetEnabled(FALSE);

	BOOL loading_started = window_commander->OpenURL(eula_url.CStr(), FALSE);
	if (FALSE == loading_started)
		OnLoadingFailed();

	return OpStatus::OK;
}
Ejemplo n.º 3
0
OP_STATUS ExtensionUtils::CreateExtensionClass(const OpStringC& path,OpGadgetClass** extension_class)
{
	RETURN_VALUE_IF_NULL(extension_class,OpStatus::ERR);
	OpFile upd_file;
	RETURN_IF_ERROR(upd_file.Construct(path));
	BOOL exists;
	RETURN_IF_ERROR(upd_file.Exists(exists));
	if (!exists)
	  return OpStatus::ERR;

	OpString error_reason;	
	*extension_class = g_gadget_manager->CreateClassWithPath(path.CStr(), URL_EXTENSION_INSTALL_CONTENT, NULL, error_reason);
	RETURN_VALUE_IF_NULL(*extension_class, OpStatus::ERR);

	return OpStatus::OK;
}
Ejemplo n.º 4
0
OP_STATUS
OpScopeTranscoder::TranscodeMessageToClient(OpScopeTPMessage &message_copy, OpScopeClient *client, const OpScopeTPMessage &message)
{
	if (!IsActive())
		return OpStatus::OK;

	// If transcoding is on we need to convert it to a format the client can understand, if possible
	OpScopeTPHeader::MessageType type = client->GetMessageType();
	if (type != message_copy.Type())
	{
		const OpProtobufMessage *proto_message = GetProtobufMessage(service_manager, &message);
		OP_ASSERT(proto_message);
		RETURN_VALUE_IF_NULL(proto_message, OpStatus::ERR_NULL_POINTER);

		OpProtobufMessage::MakeFunc make = proto_message->GetMakeFunction();
		void *instance_ptr = make();
		OP_ASSERT(instance_ptr);
		RETURN_OOM_IF_NULL(instance_ptr);
		OpProtobufInstanceProxy proxy(proto_message, instance_ptr);

		OP_STATUS status = TranscodeToClient(client, proxy, message_copy, message, type);

		OpProtobufMessage::DestroyFunc destroy = proto_message->GetDestroyFunction();
		destroy(instance_ptr);

		if (OpStatus::IsError(status))
			return status;
		++transcoded_host_to_client;
	}
	return OpStatus::OK;
}
Ejemplo n.º 5
0
OP_STATUS
OpScopeTranscoder::TranscodeMessageFromClient(OpScopeTPMessage &new_message, OpScopeClient *client, const OpScopeTPMessage &message)
{
	if (!IsActive())
		return OpStatus::OK;

	// Transcode to given format by using an instance and protocol buffer definitions
	const OpProtobufMessage *proto_message = GetProtobufMessage(service_manager, &message);
	OP_ASSERT(proto_message);
	RETURN_VALUE_IF_NULL(proto_message, OpStatus::ERR_NULL_POINTER);

	OpProtobufMessage::MakeFunc make = proto_message->GetMakeFunction();
	void *instance_ptr = make();
	OP_ASSERT(instance_ptr);
	RETURN_OOM_IF_NULL(instance_ptr);
	OpProtobufInstanceProxy proxy(proto_message, instance_ptr);

	OP_STATUS status = TranscodeFromClient(client, proxy, new_message, message, transcoding_format);

	OpProtobufMessage::DestroyFunc destroy = proto_message->GetDestroyFunction();
	destroy(instance_ptr);

	if (OpStatus::IsError(status))
		return status;
	++transcoded_client_to_host;
	return OpStatus::OK;
}
Ejemplo n.º 6
0
OP_STATUS
OpScopeTranscoder::HandleTranscoderResult(const OpScopeTPMessage *message)
{
	// We need the service manager to enable the transcoder
	if (!service_manager)
		return OpStatus::ERR;

	OpScopeProtocolService::HostInfo host_info;
	OpProtobufInstanceProxy instance(GetProtobufMessage(service_manager, message), reinterpret_cast<void *>(&host_info));
	if (instance.GetProtoMessage() == NULL)
		return OpStatus::ERR_NO_MEMORY;
	OpScopeTPError stp_error;
	RETURN_IF_ERROR(OpScopeClient::ParseDefault(*message, instance, stp_error));

	BOOL version_check = TRUE;
	for (unsigned i = 0; i < host_info.GetServiceList().GetCount(); ++i)
	{
		OpScopeProtocolService::Service *service_info = host_info.GetServiceList().Get(i);
		RETURN_VALUE_IF_NULL(service_info, OpStatus::ERR_NULL_POINTER);
		OpScopeService *service = service_manager->FindService(service_info->GetName());
		if ( !service || !TranscoderVersionCheck(service_info->GetVersion(), service->GetMajorVersion(), service->GetMinorVersion()) )
		{
			version_check = FALSE;
			break;
		}
	}
	if (version_check)
		transcoder_enabled = TRUE;
	return OpStatus::OK;
}
Ejemplo n.º 7
0
BOOL
OpSecurityManager_DOM::CheckScopeSecurity(const OpSecurityContext &source)
{
	DOM_Runtime *rt = source.GetRuntime();
	RETURN_VALUE_IF_NULL(rt, FALSE);

	FramesDocument *doc = DOM_Utils::GetDocument(rt);

	return (doc && doc->GetWindow()->GetType() == WIN_TYPE_DEVTOOLS);
}
QuickButton* ExtensionsManagerListViewItem::ConstructButtonAux(
		OpInputAction::Action action, const uni_char* action_data_str)
{
	OpInputAction* in_action = OP_NEW(OpInputAction, (action));
	RETURN_VALUE_IF_NULL(in_action, NULL);
	in_action->SetActionData(reinterpret_cast<INTPTR>(action_data_str));

	OpAutoPtr<QuickButton> button_aptr(
			QuickButton::ConstructButton(in_action));
	RETURN_VALUE_IF_NULL(button_aptr.get(), NULL);

	OP_DELETE(in_action);

#ifndef _MACINTOSH_
	button_aptr->GetOpWidget()->SetTabStop(g_op_ui_info->IsFullKeyboardAccessActive());
#endif //!_MACINTOSH_

	return button_aptr.release();
}
Ejemplo n.º 9
0
ExtensionsManagerView* ExtensionsPanel::ConstructExtensionsList(
		QuickWidget** widget, QuickLabel** counter_label, 
			Str::LocaleString button_str, OpInputAction::Action action, 
			const char* button_skin)
{
	*widget = NULL;
	*counter_label = NULL;

	QuickLabel* tmp_label = NULL;
	QuickStackLayout* tmp_stack = NULL;
	QuickButton* button = NULL;
	OpInputAction input_action(action);
	RETURN_VALUE_IF_ERROR(
			ConstructHeader(&tmp_stack, &tmp_label, &button,
				Str::D_EXTENSION_PANEL_COUNTER,
				button_str, 
				&input_action), NULL);
	OpAutoPtr<QuickStackLayout> widget_aptr(tmp_stack);	

	OpAutoPtr<T> extensions_list_aptr(OP_NEW(T, ()));
	RETURN_VALUE_IF_NULL(extensions_list_aptr.get(), NULL);

	ExtensionsManagerView* view_tmp = extensions_list_aptr.get();

	OpAutoPtr<QuickSkinElement> skinned_list_aptr(
			QuickSkinWrap(extensions_list_aptr.release(), 
				"Extensions Panel List Skin"));
	RETURN_VALUE_IF_NULL(skinned_list_aptr.get(), NULL);

	RETURN_VALUE_IF_ERROR(
			widget_aptr->InsertWidget(skinned_list_aptr.release()), NULL);
	
	*widget = widget_aptr.release();
	*counter_label = tmp_label;

	button->SetImage(button_skin);
	button->GetOpWidget()->SetFixedImage(TRUE);
#ifndef _MACINTOSH_	
	button->GetOpWidget()->SetTabStop(g_op_ui_info->IsFullKeyboardAccessActive());
#endif // !_MACINTOSH_

	return view_tmp;
}
Ejemplo n.º 10
0
/***********************************************************************************
 **
 **
 ** MessageUndelete::GetExpandedQueue
 ***********************************************************************************/
ImapCommandItem* ImapCommands::MessageUndelete::GetExpandedQueue(IMAP4& protocol)
{
	OpAutoPtr<ImapCommands::Store> remove_deleted_flag (OP_NEW(ImapCommands::Store, (m_mailbox, 0, 0,
						ImapCommands::USE_UID | ImapCommands::Store::REMOVE_FLAGS | Store::SILENT | ImapCommands::Store::FLAG_DELETED)));
	
	RETURN_VALUE_IF_NULL(remove_deleted_flag.get(), NULL);
	RETURN_VALUE_IF_ERROR(remove_deleted_flag->GetMessageSet().Copy(m_message_set), NULL);

	if (m_to_folder)
	{
		OpAutoPtr<ImapCommands::Move> move_from_trash_to_inbox (OP_NEW(ImapCommands::Move, (m_mailbox, m_to_folder, 0, 0)));

		RETURN_VALUE_IF_NULL(move_from_trash_to_inbox.get(), NULL);
		RETURN_VALUE_IF_ERROR(move_from_trash_to_inbox->GetMessageSet().Copy(m_message_set), NULL);
		move_from_trash_to_inbox->DependsOn(remove_deleted_flag.get(), protocol);
		move_from_trash_to_inbox.release();
	}

	return remove_deleted_flag.release();
}
Ejemplo n.º 11
0
QuickWidget* ExtensionsPanel::ConstructNormalExtensionsList()
{
	QuickWidget* widget = NULL;
	m_extensions_view = 
		ConstructExtensionsList<ExtensionsManagerListView>(&widget, 
			&m_counter_label, Str::D_EXTENSION_PANEL_GET_MORE,
				OpInputAction::ACTION_GET_MORE_EXTENSIONS,
				"Extensions Panel Button Get More");
	RETURN_VALUE_IF_NULL(m_extensions_view, NULL);

	return widget;
}
Ejemplo n.º 12
0
QuickWidget* ExtensionsPanel::ConstructDeveloperExtensionsList()
{
	QuickWidget* widget = NULL;
	m_extensions_dev_view = 
		ConstructExtensionsList<ExtensionsManagerDevListView>(&widget, 
			&m_dev_counter_label, Str::D_EXTENSION_PANEL_OPEN_ERROR_CONSOLE,
				OpInputAction::ACTION_SHOW_MESSAGE_CONSOLE,
				"Extensions Panel Button Open Error Console");
	RETURN_VALUE_IF_NULL(m_extensions_dev_view, NULL);

	return widget;
}
QuickStackLayout* ExtensionsManagerDevListViewItem::ConstructDebugButtons()
{
	OpAutoPtr<QuickStackLayout> list_aptr(
			OP_NEW(QuickStackLayout, (QuickStackLayout::HORIZONTAL)));
	RETURN_VALUE_IF_NULL(list_aptr.get(), NULL);

	OpAutoPtr<QuickButton> reload_button_aptr(
			ConstructButtonAux(OpInputAction::ACTION_DEVTOOLS_RELOAD_EXTENSION,
				GetModelItem().GetExtensionId(),
				Str::SI_RELOAD_BUTTON_TEXT));
	RETURN_VALUE_IF_NULL(reload_button_aptr.get(), NULL);

	reload_button_aptr->SetSkin("Extensions Panel List Item Button Debug");

	RETURN_VALUE_IF_ERROR(list_aptr->InsertWidget(reload_button_aptr.release()), NULL);
	RETURN_VALUE_IF_ERROR(list_aptr->InsertEmptyWidget(10, 0, 10, 0), NULL);

	OpAutoPtr<QuickButton> open_folder_button_aptr(
			ConstructButtonAux(OpInputAction::ACTION_OPEN_FOLDER,
				GetModelItem().GetExtensionPath(),
				Str::D_EXTENSION_PANEL_OPEN_FOLDER));
	RETURN_VALUE_IF_NULL(open_folder_button_aptr.get(), NULL);

	open_folder_button_aptr->SetSkin("Extensions Panel List Item Button Debug");

	RETURN_VALUE_IF_ERROR(
			list_aptr->InsertWidget(open_folder_button_aptr.release()), NULL);

	OpAutoPtr<QuickStackLayout> stack_aptr(
			OP_NEW(QuickStackLayout, (QuickStackLayout::VERTICAL)));
	RETURN_VALUE_IF_NULL(stack_aptr.get(), NULL);

	RETURN_VALUE_IF_ERROR(stack_aptr->InsertEmptyWidget(0, DEV_BUTTONS_TOP_MARGIN, 0, 
			DEV_BUTTONS_TOP_MARGIN), NULL);
	RETURN_VALUE_IF_ERROR(stack_aptr->InsertWidget(list_aptr.release()), NULL);
	
	return stack_aptr.release();
}
Ejemplo n.º 14
0
QuickStackLayout* ExtensionsPanel::ConstructDeveloperAndEmptyPageWidget()
{
	OpAutoPtr<QuickWidget> extensions_dev_list_aptr(
			ConstructDeveloperExtensionsList());
	RETURN_VALUE_IF_NULL(extensions_dev_list_aptr.get(), NULL);
	
	OpAutoPtr<QuickWidget> empty_panel_widget_aptr(
			ExtensionsManagerView::ConstructEmptyPageWidget());
	RETURN_VALUE_IF_NULL(empty_panel_widget_aptr.get(), NULL);

	OpAutoPtr<QuickStackLayout> two_lists_aptr(OP_NEW(QuickStackLayout,
			(QuickStackLayout::VERTICAL)));
	RETURN_VALUE_IF_NULL(two_lists_aptr.get(), NULL);

	RETURN_VALUE_IF_ERROR(
			two_lists_aptr->InsertWidget(extensions_dev_list_aptr.release()), NULL);
	RETURN_VALUE_IF_ERROR(
			two_lists_aptr->InsertEmptyWidget(1, 33, 1, 33), NULL);
	RETURN_VALUE_IF_ERROR(
			two_lists_aptr->InsertWidget(empty_panel_widget_aptr.release()), NULL);
	
	return two_lists_aptr.release();
}
Ejemplo n.º 15
0
QuickStackLayout* ExtensionsPanel::ConstructNormalAndDeveloper()
{
	OpAutoPtr<QuickWidget> extensions_list_aptr(
			ConstructNormalExtensionsList());
	RETURN_VALUE_IF_NULL(extensions_list_aptr.get(), NULL);

	OpAutoPtr<QuickWidget> extensions_dev_list_aptr(
			ConstructDeveloperExtensionsList());
	RETURN_VALUE_IF_NULL(extensions_dev_list_aptr.get(), NULL);

	OpAutoPtr<QuickStackLayout> two_lists_aptr(
			OP_NEW(QuickStackLayout, (QuickStackLayout::VERTICAL)));
	RETURN_VALUE_IF_NULL(two_lists_aptr.get(), NULL);

	RETURN_VALUE_IF_ERROR(
			two_lists_aptr->InsertWidget(extensions_dev_list_aptr.release()), NULL);
	RETURN_VALUE_IF_ERROR(
			two_lists_aptr->InsertEmptyWidget(1, 13, 1, 13), NULL);
	RETURN_VALUE_IF_ERROR(
			two_lists_aptr->InsertWidget(extensions_list_aptr.release()), NULL);
	
	return two_lists_aptr.release();
}
QuickButton* ExtensionsManagerListViewItem::ConstructButtonAux(
		OpInputAction::Action action, const uni_char* action_data_str, 
			Str::LocaleString str_id)
{
	OpInputAction* in_action = OP_NEW(OpInputAction, (action));
	RETURN_VALUE_IF_NULL(in_action, NULL);
	in_action->SetActionData(reinterpret_cast<INTPTR>(action_data_str));

	OpAutoPtr<QuickButton> button_aptr(
			QuickButton::ConstructButton(str_id, in_action));
	RETURN_VALUE_IF_NULL(button_aptr.get(), NULL);

	OP_DELETE(in_action);

	button_aptr->GetOpWidget()->SetButtonTypeAndStyle(
			OpButton::TYPE_CUSTOM, OpButton::STYLE_TEXT);	
	button_aptr->SetSkin("Extensions Panel List Item Button");

#ifndef _MACINTOSH_	
	button_aptr->GetOpWidget()->SetTabStop(g_op_ui_info->IsFullKeyboardAccessActive());
#endif //!_MACINTOSH_

	return button_aptr.release();
}
Ejemplo n.º 17
0
BOOL
OpSecurityManager_DOM::CheckOperaConnectSecurity(const OpSecurityContext &source)
{
	DOM_Runtime *rt = source.GetRuntime();
	RETURN_VALUE_IF_NULL(rt, FALSE);

	if (DOM_Utils::GetOriginURL(rt).GetAttribute(URL::KName).CompareI("opera:debug") == 0)
		return TRUE;

	FramesDocument *doc = DOM_Utils::GetDocument(rt);

	if (doc && doc->GetWindow() && doc->GetWindow()->GetType() == WIN_TYPE_DEVTOOLS)
		return TRUE;

	return FALSE;
}
Ejemplo n.º 18
0
OP_STATUS VersionChecker::GetDataFileLastModificationTime(time_t& result)
{
	uni_char* updateFile = m_data_file_reader.GetUpdateFile();

	RETURN_VALUE_IF_NULL(updateFile, OpStatus::ERR);

	OP_STATUS retcode = OpStatus::OK;
	OpFile opFile;
	retcode = opFile.Construct(updateFile);
	if (OpStatus::IsSuccess(retcode))
		retcode = opFile.GetLastModified(result);

	// AUDataFileReader uses a plain old "new []" to allocate the strings
	delete [] updateFile;
	return retcode;;
}
Ejemplo n.º 19
0
BOOL3
OpScopeTPReader::ParseString(OpString &str, unsigned int len)
{
    if (protobuf_limit >= 0)
    {
        if (protobuf_limit < (int)len) // Cannot read string value in current limit
            return NO;
    }
    if (incoming->Length() < len)
        return MAYBE;
    OpHeapArrayAnchor<char> buffer(OP_NEWA(char, len));
    RETURN_VALUE_IF_NULL(buffer.Get(), NO);
    incoming->Extract(0, len, buffer.Get());
    RETURN_VALUE_IF_ERROR(OpProtobufUtils::Convert(str, buffer.Get(), len), NO);
    incoming->Consume(len);
    if (protobuf_limit > 0)
        protobuf_limit -= len;
    return YES;
}
OP_STATUS ExtensionInstallGenericController::SetWarningAccessLevel()
{
	QuickPagingLayout * paging_layout = m_widgets->Get<QuickPagingLayout>("paging_layout");
	RETURN_VALUE_IF_NULL(paging_layout,OpStatus::ERR);

	if(m_use_expand)
	{
		if (m_dialog_mode ==  ExtensionUtils::TYPE_SIMPLE)
		{
			OpString access_list_string;
			RETURN_IF_ERROR(ExtensionUtils::GetAccessLevelString(m_gclass, access_list_string));
			RETURN_IF_ERROR(SetWidgetText<QuickMultilineEdit>("Access_message1",access_list_string));

			paging_layout->GoToPage(1);
		}
		else if (m_dialog_mode ==  ExtensionUtils::TYPE_CHECKBOXES)
		{
			RETURN_IF_ERROR(GetBinder()->Connect("Secure_conn_checkbox0", m_secure_mode));
			RETURN_IF_ERROR(GetBinder()->Connect("Private_mode_checkbox0", m_private_mode));
			paging_layout->GoToPage(0);
		}
	}
	else
	{
		if (m_dialog_mode ==  ExtensionUtils::TYPE_SIMPLE)
		{
			OpString access_list_string;
			RETURN_IF_ERROR(ExtensionUtils::GetAccessLevelString(m_gclass, access_list_string));
			RETURN_IF_ERROR(SetWidgetText<QuickMultilineEdit>("Access_message3",access_list_string));

			paging_layout->GoToPage(3);
		}
		else if (m_dialog_mode ==  ExtensionUtils::TYPE_CHECKBOXES)
		{
			RETURN_IF_ERROR(GetBinder()->Connect("Secure_conn_checkbox2", m_secure_mode));
			RETURN_IF_ERROR(GetBinder()->Connect("Private_mode_checkbox2", m_private_mode));
			paging_layout->GoToPage(2);
		}
	}
	return OpStatus::OK;
}
Ejemplo n.º 21
0
static BOOL isBeyondLargestDigit(LedNumber self)
{
  RETURN_VALUE_IF_NULL(self, TRUE);
  return self->visibleDigit > self->largestDigit;
}
QuickStackLayout* ExtensionsManagerListViewItem::ConstructControlButtons()
{
	OpAutoPtr<QuickStackLayout> strip_aptr(
			OP_NEW(QuickStackLayout, (QuickStackLayout::HORIZONTAL)));
	RETURN_VALUE_IF_NULL(strip_aptr.get(), NULL);

	OpAutoPtr<QuickButton> update_button_aptr(
			ConstructButtonAux(OpInputAction::ACTION_UPDATE_EXTENSION,
				GetModelItem().GetExtensionId(),
				Str::D_EXTENSION_MANAGER_UPDATE));
	RETURN_VALUE_IF_NULL(update_button_aptr.get(), NULL);

	OpAutoPtr<QuickButton> enable_button_aptr(
			ConstructButtonAux(OpInputAction::ACTION_ENABLE_EXTENSION,
				GetModelItem().GetExtensionId(),
				Str::S_LITERAL_ENABLE));
	RETURN_VALUE_IF_NULL(enable_button_aptr.get(), NULL);

	OpAutoPtr<QuickButton> disable_button_aptr(
			ConstructButtonAux(OpInputAction::ACTION_DISABLE_EXTENSION,
				GetModelItem().GetExtensionId(),
				Str::S_LITERAL_DISABLE));
	RETURN_VALUE_IF_NULL(disable_button_aptr.get(), NULL);

	OpAutoPtr<QuickButton> uninstall_button_aptr(
			ConstructButtonAux(OpInputAction::ACTION_UNINSTALL_EXTENSION,
				GetModelItem().GetExtensionId(),
				Str::D_EXTENSION_MANAGER_UNINSTALL));
	RETURN_VALUE_IF_NULL(uninstall_button_aptr.get(), NULL);

	OpAutoPtr<QuickButton> cogwheel_button_aptr(
			ConstructButtonAux(OpInputAction::ACTION_SHOW_EXTENSION_COGWHEEL_MENU,
				GetModelItem().GetExtensionId()));
	RETURN_VALUE_IF_NULL(cogwheel_button_aptr.get(), NULL);

	cogwheel_button_aptr->SetMinimumHeight(uninstall_button_aptr->GetMinimumHeight());
	cogwheel_button_aptr->GetOpWidget()->SetButtonTypeAndStyle(
			OpButton::TYPE_CUSTOM, OpButton::STYLE_IMAGE_AND_TEXT_ON_RIGHT);
	cogwheel_button_aptr->SetSkin("Extensions Panel List Item Button");
	cogwheel_button_aptr->GetOpWidget()->GetForegroundSkin()->SetImage(
			"Extensions Panel Cogwheel");
	cogwheel_button_aptr->GetOpWidget()->SetName("Extensions Panel Cogwheel Button");
#ifndef _MACINTOSH_	
	cogwheel_button_aptr->GetOpWidget()->SetTabStop(
			g_op_ui_info->IsFullKeyboardAccessActive());
#endif //_MACINTOSH_
	OpAutoPtr<QuickPagingLayout> enable_disable_pages_aptr(
			OP_NEW(QuickPagingLayout, ()));
	RETURN_VALUE_IF_NULL(enable_disable_pages_aptr.get(), NULL);

	QuickPagingLayout* page_layout_tmp = enable_disable_pages_aptr.get();

	OpAutoPtr<QuickPagingLayout> update_pages_aptr(
			OP_NEW(QuickPagingLayout, ()));
	RETURN_VALUE_IF_NULL(update_pages_aptr.get(), NULL);

	m_update_layout = update_pages_aptr.get();

	RETURN_VALUE_IF_ERROR(
		update_pages_aptr->InsertPage(
			update_button_aptr.release(),0), NULL);

	// there is no empty widget for paging layout :(
	QuickWidget* widget = OP_NEW(NullWidget, ());
	if (!widget)
		return NULL;

	widget->SetMinimumWidth(10);
	widget->SetMinimumHeight(21);
	widget->SetPreferredWidth(40);

	RETURN_VALUE_IF_ERROR(
		update_pages_aptr->InsertPage(widget,1), NULL);

	RETURN_VALUE_IF_ERROR(
			enable_disable_pages_aptr->InsertPage(
				enable_button_aptr.release(), 0), NULL);
	RETURN_VALUE_IF_ERROR(
			enable_disable_pages_aptr->InsertPage(
				disable_button_aptr.release(), 1), NULL);

	RETURN_VALUE_IF_ERROR(
			strip_aptr->InsertWidget(
				update_pages_aptr.release()), NULL);

	RETURN_VALUE_IF_ERROR(
			strip_aptr->InsertWidget(
				enable_disable_pages_aptr.release()), NULL);
	RETURN_VALUE_IF_ERROR(
			strip_aptr->InsertWidget(
				uninstall_button_aptr.release()), NULL);
	RETURN_VALUE_IF_ERROR(
			strip_aptr->InsertWidget(
				cogwheel_button_aptr.release()), NULL);

	m_enable_disable_pages = page_layout_tmp;

	return strip_aptr.release();
}
Ejemplo n.º 23
0
BOOL LedDigit_IsDecimalShown(LedDigit self)
{
  RETURN_VALUE_IF_NULL(self, FALSE);
  return self->showDecimal;
}
Ejemplo n.º 24
0
LedDigit_Value LedDigit_CurrentDigit(LedDigit self)
{
  RETURN_VALUE_IF_NULL(self, NO_DIGIT);
  return self->digitToShow;
}
Ejemplo n.º 25
0
BOOL OpSpeedDialView::OnInputAction(OpInputAction* action)
{
	switch (action->GetAction())
	{
		case OpInputAction::ACTION_LOWLEVEL_PREFILTER_ACTION:
		{
			OpInputAction* child_action = action->GetChildAction();

			switch (child_action->GetAction())
			{
				case OpInputAction::ACTION_ZOOM_TO:
				{
					return g_speeddial_manager->IsScaleAutomatic();
				}
			}
			break;
		}

		case OpInputAction::ACTION_GET_ACTION_STATE:
		{
			OpInputAction* child_action = action->GetChildAction();

			switch (child_action->GetAction())
			{
				case OpInputAction::ACTION_THUMB_CONFIGURE:
				{
					child_action->SetEnabled(!IsReadOnly());
					return TRUE;
				}

				case OpInputAction::ACTION_THUMB_CLOSE_PAGE:
				{
					const DesktopSpeedDial* entry = g_speeddial_manager->GetSpeedDial(*child_action);
					child_action->SetEnabled(!IsReadOnly() && entry != NULL && !entry->IsEmpty());
					return TRUE;
				}

				case OpInputAction::ACTION_SHOW_SPEEDDIAL_GLOBAL_CONFIG:
				{
					child_action->SetEnabled(!IsReadOnly());
					child_action->SetSelected(!IsReadOnly() && m_global_config_dialog != NULL);
					return TRUE;
				}

				case OpInputAction::ACTION_ZOOM_IN:
				case OpInputAction::ACTION_ZOOM_OUT:
				case OpInputAction::ACTION_ZOOM_TO:
				{
					 child_action->SetEnabled(!g_speeddial_manager->IsScaleAutomatic());

					 if (child_action->GetAction() == OpInputAction::ACTION_ZOOM_TO)
						 child_action->SetSelected(!g_speeddial_manager->IsScaleAutomatic() && action->GetActionData() == (int)(g_speeddial_manager->GetThumbnailScale() * 100 + 0.5));

					 return TRUE;
				}

				case OpInputAction::ACTION_RELOAD:
				{
					 BOOL enable = OpWidget::IsVisible();
					 if (enable)
						enable = GetVisibleThumbnailCount() ? TRUE : FALSE;
					 child_action->SetEnabled(enable);

					 if (child_action->GetActionOperator() !=  OpInputAction::OPERATOR_PLUS && !child_action->GetNextInputAction())
						child_action->SetSelected(FALSE);

					 return TRUE;
				}

				case OpInputAction::ACTION_UNDO:
				{
					 child_action->SetEnabled(g_speeddial_manager->IsUndoAvailable());
					 return TRUE;
				}

				case OpInputAction::ACTION_REDO:
				{
					 child_action->SetEnabled(g_speeddial_manager->IsRedoAvailable());
					 return TRUE;
				}

				case OpInputAction::ACTION_SHOW_SPEEDDIAL_CONTENTS:
				{
					child_action->SetEnabled(g_speeddial_manager->HasLoadedConfig());
					return TRUE;
				}

				case OpInputAction::ACTION_FIND:
				case OpInputAction::ACTION_SHOW_ZOOM_POPUP_MENU:
				case OpInputAction::ACTION_PRINT_DOCUMENT:
				case OpInputAction::ACTION_PRINT_PREVIEW:
				case OpInputAction::ACTION_CUT:
				case OpInputAction::ACTION_COPY:
				case OpInputAction::ACTION_PASTE:
				case OpInputAction::ACTION_COPY_TO_NOTE:
				case OpInputAction::ACTION_SELECT_ALL:
				case OpInputAction::ACTION_STOP:
				{
					 child_action->SetEnabled(FALSE);
					 return TRUE;
				}
			}
			break;
		}

		case OpInputAction::ACTION_RELOAD:
		{
		 	 ReloadSpeedDial();
			 return TRUE;
		}

		case OpInputAction::ACTION_ZOOM_OUT:
		case OpInputAction::ACTION_ZOOM_IN:
		{
			 bool scale_up = action->GetAction() == OpInputAction::ACTION_ZOOM_IN;
			 g_speeddial_manager->ChangeScaleByDelta(scale_up);
			 return TRUE;
		}

		case OpInputAction::ACTION_ZOOM_TO:
		{
			 g_speeddial_manager->SetThumbnailScale(action->GetActionData() * 0.01);
			 return TRUE;
		}

		case OpInputAction::ACTION_UNDO:
		{
			 g_speeddial_manager->Undo(this);
			 return TRUE;
		}

		case OpInputAction::ACTION_REDO:
		{
			 g_speeddial_manager->Redo(this);
			 return TRUE;
		}

		case OpInputAction::ACTION_SHOW_SPEEDDIAL_CONTENTS:
		{
			// Switch between Shown and Folded
			 BOOL fold = !action->GetActionData();
			 g_speeddial_manager->SetState(fold?SpeedDialManager::Folded : SpeedDialManager::Shown);
			 OpStatus::Ignore(g_speeddial_manager->Save());
			 Show(true);
			 return TRUE;
		}

		case OpInputAction::ACTION_THUMB_CLOSE_PAGE:
		{
			const INT32 pos = g_speeddial_manager->FindSpeedDial(*action);
			const DesktopSpeedDial* entry = g_speeddial_manager->GetSpeedDial(pos);
			if (!IsReadOnly() && entry != NULL && !entry->IsEmpty())
			{
				CloseAllDialogs();
				m_thumbnails.Get(pos)->AnimateThumbnailOut(true);
			}
			return TRUE;
		}

		case OpInputAction::ACTION_SHOW_SPEEDDIAL_EXTENSION_OPTIONS:
		{
			const INT32 pos = g_speeddial_manager->FindSpeedDial(*action);
			const DesktopSpeedDial* entry = g_speeddial_manager->GetSpeedDial(pos);
			if (entry != NULL)
			{
				OP_ASSERT(entry->GetExtensionWUID().HasContent());

				// close any other dialogs first
				CloseAllDialogs();

				SpeedDialThumbnail* thumbnail = m_thumbnails.Get(pos);
				m_extension_prefs_controller = OP_NEW(ExtensionPrefsController, (*thumbnail));
				RETURN_VALUE_IF_NULL(m_extension_prefs_controller, TRUE);
				g_global_ui_context->AddChildContext(m_extension_prefs_controller);
				m_extension_prefs_controller->SetListener(this);
				if (OpStatus::IsError(g_desktop_extensions_manager->OpenExtensionOptionsPage(
								entry->GetExtensionWUID(), *m_extension_prefs_controller)))
				{
					OP_DELETE(m_extension_prefs_controller);
					m_extension_prefs_controller = NULL;
				}
			}
			return TRUE;
		}

		case OpInputAction::ACTION_SHOW_SPEEDDIAL_GLOBAL_CONFIG:
		{
			if (m_global_config_dialog)
			{
				CloseGlobalConfigDialog();
			}
			else
			{
				// close any other dialogs first
				CloseAllDialogs();

				m_global_config_dialog = OP_NEW(SpeedDialGlobalConfigDialog, ());
				if (m_global_config_dialog)
				{
					OpWidget *config_widget = GetWidgetByName("Speed Dial Global Configuration");
					if (config_widget)
					{
						if (GetScreenRect().Contains(config_widget->GetScreenRect()))
						{
							m_global_config_dialog->DialogPlacementRelativeWidget(config_widget);
						}
					}

					if (OpStatus::IsSuccess(m_global_config_dialog->Init(GetParentDesktopWindow())))
					{
						g_speeddial_manager->StartConfiguring(*GetParentDesktopWindow());
						m_global_config_dialog->SetDialogListener(this);
						m_global_config_dialog->OnThumbnailScaleChanged(g_speeddial_manager->GetThumbnailScale());
						g_input_manager->UpdateAllInputStates();
					}
					else
					{
						m_global_config_dialog = NULL;
					}
				}
			}
			return TRUE;
		}

		case OpInputAction::ACTION_THUMB_EDIT:
		case OpInputAction::ACTION_THUMB_CONFIGURE:
		{
			if (IsReadOnly())
				return TRUE;

			INT32 pos = g_speeddial_manager->FindSpeedDial(*action);
			if (pos < 0)
				pos = g_speeddial_manager->GetTotalCount() - 1;
			const DesktopSpeedDial* entry = g_speeddial_manager->GetSpeedDial(pos);
			if (entry != NULL && 0 <= pos && UINT32(pos) < m_thumbnails.GetCount())
			{
				const SpeedDialConfigController::Mode mode
						= action->GetAction() == OpInputAction::ACTION_THUMB_EDIT
								? SpeedDialConfigController::EDIT : SpeedDialConfigController::ADD;
				if (mode == SpeedDialConfigController::ADD)
					g_speeddial_manager->StartConfiguring(*GetParentDesktopWindow());

				OpStatus::Ignore(ConfigureSpeeddial(
							*m_thumbnails.Get(pos), OP_NEW(SpeedDialConfigController, (mode))));
			}
			return TRUE;
		}
	}
	return OpWidget::OnInputAction(action);
}