OP_STATUS PlatformGadgetUtils::GetAbsolutePath(const OpString& file_path,
		OpString& absolute_path)
{
	const int abs_pathname_length =
			GetFullPathName(file_path, 0, NULL, NULL) - 1;
	if (0 != abs_pathname_length)
	{
		if (NULL != absolute_path.Reserve(abs_pathname_length))
		{
			const int actual_length =
					GetFullPathName(file_path, abs_pathname_length + 1,
							absolute_path.DataPtr(), NULL);
			if (0 != actual_length)
			{
				OP_ASSERT(abs_pathname_length == actual_length);
				OP_ASSERT(abs_pathname_length == absolute_path.Length());
				return OpStatus::OK;
			}
		}
	}
	return OpStatus::ERR;
}
Example #2
0
void OpNumberEdit::OnChange(OpWidget *widget, BOOL changed_by_mouse /*= FALSE */)
{
	OP_ASSERT(widget == m_edit);
//	if (widget == m_edit)
	{
		if (listener)
		{
			listener->OnChange(this);
		}

		UpdateButtonState();
	}
}
Example #3
0
INT32 OpHotlistView::GetRootID()
{
	if (IsContacts())
		return HotlistModel::ContactRoot;
	else if (IsNotes())
		return HotlistModel::NoteRoot;
#ifdef WEBSERVER_SUPPORT
	else if (IsUniteServices())
		return HotlistModel::UniteServicesRoot;
#endif // WEBSERVER_SUPPORT
	OP_ASSERT(!"Unkown view type");
	return 0;
}
void SyncPasswordImprovementDialog::OnInit()
{
	ShowProgress(FALSE);

	OpEdit* edit = static_cast<OpEdit*>(GetWidgetByName(SyncConstant::OLD_PASSWD_EDIT));
	OP_ASSERT(edit);
	if (edit)
		edit->SetPasswordMode(TRUE);

	BindEditWithPasswordStrength(SyncConstant::NEW_PASSWD_EDIT, SyncConstant::NEW_PASSWD_STRENGTH);

	OpIcon* warning_icon = static_cast<OpIcon*>(GetWidgetByName(SyncConstant::WARNING_ICON));
	OP_ASSERT(warning_icon);
	if (warning_icon)
	{
		warning_icon->SetImage("Dialog Warning");
	}

	OpLabel* header_label = static_cast<OpLabel*>(GetWidgetByName(SyncConstant::HEADER_LABEL));
	OP_ASSERT(header_label);
	if (header_label)
	{
		header_label->SetRelativeSystemFontSize(SyncConstant::HEADER_LABEL_REL_SIZE);
		SetLabelInBold(SyncConstant::HEADER_LABEL);
	}

	OpLabel* error_label = static_cast<OpLabel*>(GetWidgetByName(SyncConstant::ERROR_LABEL));
	OP_ASSERT(error_label);
	if (error_label)
	{
		error_label->SetForegroundColor(OP_RGB(255, 0, 0));
	}

	OpEdit* confirm_passwd_edit =
			static_cast<OpEdit*>(GetWidgetByName(SyncConstant::CONFIRM_NEW_PASSWD_EDIT));
	OP_ASSERT(confirm_passwd_edit);
	if (confirm_passwd_edit)
		confirm_passwd_edit->SetPasswordMode(TRUE);
}
Example #5
0
OP_STATUS PlatformGadgetList::Create(PlatformGadgetList** gadget_list)
{
	OP_ASSERT(NULL != gadget_list);
	if (NULL == gadget_list)
	{
		return OpStatus::ERR;
	}

	*gadget_list = OP_NEW(UnixGadgetList, ());
	RETURN_OOM_IF_NULL(*gadget_list);

	return OpStatus::OK;
}
Example #6
0
void
MediaSourceImpl::PauseBuffering()
{
	OP_NEW_DBG("PauseBuffering", "MediaSource");
	OP_DBG((""));

	OP_ASSERT(m_state == LOADING && IsStreaming());

	m_use_url->SetAttribute(URL::KPauseDownload, TRUE);
	m_state = PAUSED;
	for (OpListenersIterator iter(m_listeners); m_listeners.HasNext(iter);)
		m_listeners.GetNext(iter)->OnIdle(this);
}
Example #7
0
OP_STATUS
ChatFileTransferManager::AddTransferItem(	ChatFileTransfer&	chat_transfer)
{
	OP_ASSERT(GetTransferItem(chat_transfer) == 0);

	OpString file_name;

	RETURN_IF_ERROR(chat_transfer.GetFileName(file_name));

	// Figure out where to save the file if we are receiving the file.
	OpFileLength dummy_resume;
	return AddTransferItem(chat_transfer, SEND, file_name, dummy_resume);
}
Example #8
0
OP_STATUS
ChatFileTransferManager::FileSendBegin(const ChatFileTransfer& chat_transfer)
{
	OpTransferItem* item = GetTransferItem(chat_transfer);
	if (item == 0)
		return OpStatus::ERR;

	TransferItem* transfer_item = (TransferItem *)(item);
	OP_ASSERT(transfer_item != 0);

	// Update status.
	return transfer_item->GetURL()->SetAttribute(URL::KLoadStatus, URL_LOADING);
}
Example #9
0
OP_STATUS
ChatFileTransferManager::FileReceiveCompleted(const ChatFileTransfer& chat_transfer)
{
	OpTransferItem* item = GetTransferItem(chat_transfer);
	if (item == 0)
		return OpStatus::ERR;

	TransferItem* transfer_item = (TransferItem *)(item);
	OP_ASSERT(transfer_item != 0);

	transfer_item->FinishedURLPutData();
	 return transfer_item->GetURL()->SetAttribute(URL::KLoadStatus, URL_LOADED);
}
Example #10
0
SSL_KEA_ACTION SSL_Certificate_st::ProcessMessage(SSL_ConnectionState *pending)
{
    OP_ASSERT(pending && pending->session && pending->key_exchange);

    pending->session->Site_Certificate = *this;
    if(pending->session->Site_Certificate.Error())
        return SSL_KEA_Handle_Errors;
#ifndef TLS_NO_CERTSTATUS_EXTENSION
    if(pending->session->sent_ocsp_extensions.GetLength() != 0 || pending->session->ocsp_extensions_sent)
        return SSL_KEA_No_Action;
#endif
    return pending->key_exchange->ReceivedCertificate();
}
void ExtensionsManagerDevListView::OnDeveloperExtensionAdded(
		const ExtensionsModelItem& model_item)
{
	ExtensionsManagerDevListViewItem* item = 
			OP_NEW(ExtensionsManagerDevListViewItem, (model_item));
	OP_ASSERT(item);
	if (!item)
	{
		return;
	}

	RETURN_VOID_IF_ERROR(AddToList(item));
}
Example #12
0
URL_DataDescriptor::~URL_DataDescriptor()
{
#ifdef DEBUG_LOAD_STATUS
	g_main_message_handler->UnsetCallBacks(this);
#endif
#ifdef _DEBUG_DD1
	/*
	if(position != url.ContentLoaded() || url.Status(FALSE) == URL_LOADING)
		int stop = 1;
		*/
#endif
#ifdef _DEBUG_DD1
	OpFileLength registered_len=0;
	url.GetAttribute(URL::KContentLoaded, &registered_len);
	PrintfTofile("urldd1.txt","\nDD Destructor- %s - %s - %lu:%lu (%u:%u)\n",
		DebugGetURLstring(url), (url.GetAttribute(URL::KLoadStatus) == URL_LOADING ? "Not Loaded" : "Loaded"),
		(unsigned long) position, (unsigned long) registered_len, buffer_used, buffer_len
		);
#endif
	OP_DELETE(sub_desc);

	if(is_using_file && storage)
		storage->DecFileCount();

	if(InList())
		Out();

	if(buffer)
	{
		if(url.GetAttribute(URL::KCachePolicy_NoStore))
			OPERA_cleanse_heap(buffer, buffer_len);
		else
			op_memset(buffer, 0, buffer_len);

		OP_DELETEA(buffer);
	}
	g_charsetManager->DecrementCharsetIDReference(charset_id);
	g_charsetManager->DecrementCharsetIDReference(parent_charset);
#ifdef DEBUG_LOAD_STATUS
	OP_ASSERT(dd_counter >0);
	dd_counter --;
#endif

#ifdef SELFTEST
	Context_Manager *mng=urlManager->FindContextManager(url.GetContextId());

	if(mng)
		mng->RemoveDataDescriptorForStats(this);
#endif // SELFTEST

}
Example #13
0
OP_STATUS GenericThumbnail::Init(const Config& config)
{
    m_config = config;

    SetSkinned(TRUE);

    RETURN_IF_ERROR(OpButton::Construct(&m_title_button, OpButton::TYPE_CUSTOM, OpButton::STYLE_IMAGE));
    OP_ASSERT(m_title_button != NULL);
    AddChild(m_title_button);
    m_title_button->SetEllipsis(g_pcui->GetIntegerPref(PrefsCollectionUI::EllipsisInCenter) == 1 ? ELLIPSIS_CENTER : ELLIPSIS_END);
    m_title_button->SetJustify(JUSTIFY_CENTER, FALSE);
    m_title_button->GetBorderSkin()->SetImage(m_config.m_title_border_image);
    m_title_button->SetIgnoresMouse(TRUE);

    RETURN_IF_ERROR(OpButton::Construct(&m_close_button, OpButton::TYPE_CUSTOM, OpButton::STYLE_IMAGE));
    OP_ASSERT(m_close_button != NULL);
    AddChild(m_close_button);
    m_close_button->GetBorderSkin()->SetImage(m_config.m_close_border_image);
    m_close_button->GetForegroundSkin()->SetImage(m_config.m_close_foreground_image);
    m_close_button->SetIgnoresMouse(TRUE);
    m_close_button->SetVisibility(FALSE);

    RETURN_IF_ERROR(OpProgressBar::Construct(&m_busy_spinner));
    OP_ASSERT(m_busy_spinner != NULL);
    AddChild(m_busy_spinner);
    m_busy_spinner->GetBorderSkin()->SetImage(m_config.m_busy_border_image);
    m_busy_spinner->SetSpinnerImage(m_config.m_busy_foreground_image);
    m_busy_spinner->SetType(OpProgressBar::Spinner);
    m_busy_spinner->SetIgnoresMouse(TRUE);
    m_busy_spinner->SetVisibility(FALSE);

    SetListener(this);

    m_blend.AddWidgetToBlend(this);
    m_blend.AddWidgetToBlend(m_title_button);

    return OpStatus::OK;
}
Example #14
0
OP_STATUS
ES_TimeoutTimerEvent::SetCallable(ES_Object *callable_, ES_Value* argv_, int argc_)
{
	OP_ASSERT(callable_);
	OP_ASSERT(!callable);
	OP_ASSERT(!program);

	callable = callable_;

	if (!runtime->Protect(callable))
	{
		callable = NULL;
		return OpStatus::ERR_NO_MEMORY;
	}

	if ((callable_argc = argc_) > 0)
	{
		if (!(callable_argv = OP_NEWA(ES_Value, argc_)))
		{
			callable_argc = 0;
			return OpStatus::ERR_NO_MEMORY;
		}

		for ( int i=0 ; i < argc_ ; i++ )
		{
			callable_argv[i] = argv_[i];

			if (callable_argv[i].type == VALUE_OBJECT && !runtime->Protect(callable_argv[i].value.object) ||
			    callable_argv[i].type == VALUE_STRING && !(callable_argv[i].value.string = SetNewStr(callable_argv[i].value.string)))
			{
				callable_argv[i].type = VALUE_UNDEFINED;
				return OpStatus::ERR_NO_MEMORY;
			}
		}
	}

	return OpStatus::OK;
}
Example #15
0
void OpSpeedDialView::HandleCallback(OpMessage msg, MH_PARAM_1 par1, MH_PARAM_2 par2)
{
	OP_NEW_DBG("OpSpeedDialView::HandleCallback", "speeddial");
	OP_DBG(("msg = %i", msg));
	OP_DBG(("this = %p", this));
	OP_DBG(("par1 = %i", par1));

	switch (msg)
	{
		case MSG_SCROLL_SPEED_DIAL_PAGE_TO_VIEW:
		{
			g_main_message_handler->UnsetCallBack(this, MSG_SCROLL_SPEED_DIAL_PAGE_TO_VIEW, MH_PARAM_1(this));

			const INT32 pos = par2;
			OP_ASSERT(0 <= pos && unsigned(pos) < m_thumbnails.GetCount());

			const OpRect r = m_thumbnails.Get(pos)->GetRect();
			if (m_content)
				m_content->SetScroll(r.y, TRUE);

			g_main_message_handler->SetCallBack(this, MSG_ANIMATE_THUMBNAIL, par1);
			g_main_message_handler->PostDelayedMessage(MSG_ANIMATE_THUMBNAIL, par1, pos, 100);
			return;
		}

		case MSG_ANIMATE_THUMBNAIL:
		{
			g_main_message_handler->UnsetCallBack(this, MSG_ANIMATE_THUMBNAIL, par1);

			const INT32 pos = par2;
			OP_ASSERT(0 <= pos && unsigned(pos) < m_thumbnails.GetCount());
			m_thumbnails.Get(pos)->AnimateThumbnailIn();
			return;
		}
	}

	OpWidget::HandleCallback(msg, par1, par2);
}
Example #16
0
void
Link::IntoStart(Head* list)
{
	OP_ASSERT(!InList());

    suc = list->first;
	if (suc)
		suc->pred = this;
	else
		list->last = this;

    list->first = this;
	parent = list;
}
OP_STATUS PageBasedAutocompleteItem::GetContents(OpTreeModelItem::ItemData* item_data)
{
	switch(item_data->column_query_data.column)
	{
		case 0:
			return GetIcon(item_data);
		case 1:
			return GetTextContent(item_data);
		default:
			OP_ASSERT(!"Unknown value");
	}

	return OpStatus::OK;
}
Example #18
0
HistorySiteFolder* HistorySiteFolder::Create(const OpStringC& title,
											 HistoryKey * key)
{
	OP_ASSERT(key);

	OpAutoPtr<HistorySiteFolder> site_folder(OP_NEW(HistorySiteFolder, (key)));

	if(!site_folder.get())
		return 0;

	RETURN_VALUE_IF_ERROR(site_folder->SetTitle(title), 0);

	return site_folder.release();
}
Example #19
0
void OpSpeedDialView::OnSpeedDialsLoaded()
{
	// This is for the case when Opera delays loading of speeddial.ini
	// until it gets IP-based country code (DSK-351304). Speed dial
	// tabs created before country check is finished will be initially
	// empty and have to be initialized when speeddial.ini is loaded.
	OP_ASSERT(m_thumbnails.GetCount() == 0);
	CreateThumbnails();
	if (!IsReadOnly())
	{
		m_config_button->Show();
	}
	// Plus button and background image are shown during relayout.
}
Example #20
0
/* static */ void
ES_DebugBuiltins::PopulateDebugClass(ES_Context *context, ES_Class_Singleton *prototype_class)
{
    OP_ASSERT(prototype_class->GetPropertyTable()->Capacity() >= ES_DebugBuiltinsCount);

    ES_Layout_Info layout;

    #define DECLARE_DEBUG_PROPERTY(class, property, attributes, type) prototype_class->AddL(context, JString::Make(context, #property), ES_Property_Info(attributes | CP), type, FALSE)

    DECLARE_DEBUG_PROPERTY(ES_DebugBuiltins, getHeapInformation,    DE | DD | RO, ES_STORAGE_OBJECT);
    DECLARE_DEBUG_PROPERTY(ES_DebugBuiltins, getObjectDemographics, DE | DD | RO, ES_STORAGE_OBJECT);

    #undef DECLARE_DEBUG_PROPERTY
}
Example #21
0
OP_STATUS OperaInstallerUI::Show()
{
	OP_ASSERT(m_opera_installer && !m_dialog);

	m_dialog = OP_NEW(InstallerWizard, (m_opera_installer));
	RETURN_OOM_IF_NULL(m_dialog);
	
	RETURN_IF_ERROR(m_dialog->AddListener(this));

	if (m_opera_installer->GetOperation() == OperaInstaller::OpUninstall)
		return m_dialog->Init(InstallerWizard::INSTALLER_DLG_UNINSTALL);

	return m_dialog->Init(InstallerWizard::INSTALLER_DLG_STARTUP);
}
Example #22
0
static opus_int64 op_ftell(void *_stream){
#if defined(_WIN32)
  /*_ftelli64() is not exposed until MSCVCRT80, and ftello()/ftello64() have
     the same problems as fseeko()/fseeko64() in MingW.
    See above for a more detailed explanation.*/
  opus_int64 pos;
  OP_ASSERT(sizeof(pos)==sizeof(fpos_t));
  return fgetpos((FILE *)_stream,(fpos_t *)&pos)?-1:pos;
#else
  /*This function actually conforms to the SUSv2 and POSIX.1-2001, so we prefer
     it except on Windows.*/
  return ftello((FILE *)_stream);
#endif
}
Example #23
0
void OperaInstallerUI::Pause(BOOL pause)
{
	if (pause)
		m_paused++;
	else
		m_paused--;

	OP_ASSERT(m_paused >= 0);
	if (m_paused < 0)
		m_paused = 0;

	if (m_paused == 0 && m_opera_installer->IsRunning())
		g_main_message_handler->PostMessage(MSG_WIN_INSTALLER_NEXT_STEP, (MH_PARAM_1)this, 0);
}
Example #24
0
void DownloadBase::FileDownloadCheckingFiles(UINT64 current, UINT64 total)
{
	OpTransferItem* item = GetTransferItem();
	if(item != 0)
	{
		TransferItem* transfer_item = (TransferItem *)(item);
		OP_ASSERT(transfer_item != 0);

		transfer_item->SetCalculateKbps(FALSE);
		transfer_item->SetCurrentSize(current);
		transfer_item->SetCompleteSize(total);
		transfer_item->Get_P2P_URL()->ForceStatus(P2P_URL::P2P_CHECKING_FILES);
	}
}
Example #25
0
OP_STATUS AdditionChecker::CheckForAddition(UpdatableResource::UpdatableResourceType type, const OpStringC& key)
{
	// Did you call Init()?
	OP_ASSERT(m_resolve_timer);

	// Only allow the known types. See AdditionChecker::KNOWN_TYPES[]
	if (!IsKnownType(type))
	{
		OP_ASSERT(!"Uknown resource type passed to addition checker!");
		return OpStatus::ERR;
	}

	// Only allow new items, don't cache same items twice.
	if (NULL == GetItem(type, key))
	{
		// Haven't seen this item before, save it among m_items as pending a resolve attempt.
		OpAutoPtr<AdditionCheckerItem> item(OP_NEW(AdditionCheckerItem, ()));
		RETURN_OOM_IF_NULL(item.get());
		RETURN_IF_ERROR(item->SetKey(key));
		item->SetType(type);
		RETURN_IF_ERROR(m_items.Add(item.get()));
		item.release();
	}
void FormElementOfInterest::DelayOnClick(void* arg/* = 0*/)
{
	MH_PARAM_1 par1 = reinterpret_cast<MH_PARAM_1>(this);
	MH_PARAM_2 par2 = reinterpret_cast<MH_PARAM_2>(arg);
	const OpMessage msg = MSG_FINGERTOUCH_DELAYED_CLICK;
	if (OpStatus::IsMemoryError(g_main_message_handler->SetCallBack(this, msg, par1)))
	{
		source->ReportOOM();
		return;
	}
	OP_ASSERT(g_main_message_handler->HasCallBack(this, msg, par1));
	g_main_message_handler->RemoveDelayedMessage(msg, par1, par2);
	g_main_message_handler->PostDelayedMessage(msg, par1, par2, 0);
}
Example #27
0
/* virtual */
OP_STATUS
ES_Thread::Unblock(ES_ThreadBlockType type)
{
	OP_ASSERT(GetBlockType() == type);

	if (blocked_by_foreign_thread != 0)
		SetBlockType(ES_BLOCK_FOREIGN_THREAD);
	else if (scheduler)
		return scheduler->Unblock(this, type);
	else
		SetBlockType(ES_BLOCK_NONE);

	return OpStatus::OK;
}
Example #28
0
void DataStream_SequenceBase::WriteRecordSequenceL(DataStream *target, BOOL start_after, DataStream *start_with_this, DataStream *stop_after_this)
{
	DS_DEBUG_Start();
	OP_ASSERT(target != this);

	int stepw = 0;
	DataStream *item = First();

	DS_Debug_Printf0("------------ Starting to Write Record ------------\n");
	if(start_with_this)
	{
		// Fast Forward
		while(item)
		{
			if(item == start_with_this && !start_after)
				break;

			if(item == stop_after_this)
				return;

			item = item->Suc();
			stepw++;

			if(item && start_with_this == item->Pred())
				break;
		}
	}

	WriteActionL(stepw++, (item && item->Pred() ? item->Pred()->GetItemID() : (uint32) DataStream_SequenceBase::STRUCTURE_START));
	while(item)
	{
		if(item->GetEnabledRecord())
			item->WriteRecordL(GetOutputTarget(target));

		WriteActionL(stepw++, item->GetItemID());

		BOOL is_last_element = (item == stop_after_this ? TRUE : FALSE);

		item = item->Suc();

		if(item && is_last_element)
		{
			DS_Debug_Printf0("------------ Finished Writing Record (1) ------------\n");
			return;
		}
	}
	WriteActionL(stepw++, DataStream_SequenceBase::STRUCTURE_FINISHED);

	DS_Debug_Printf0("------------ Finished Writing Record ------------\n");
}
// FIXME: OOM
OP_STATUS
OpScopeConsoleLogger::NewConsoleMessage(unsigned /* id */, const OpConsoleEngine::Message *message)
{
	OP_ASSERT(message != NULL);

	if (IsEnabled() && AcceptWindowID(message->window))
	{
		ConsoleMessage msg;
		RETURN_IF_ERROR(SetConsoleMessage(message, msg));
		RETURN_IF_ERROR(SendOnConsoleMessage(msg));
	}

	return OpStatus::OK;
}
/* static */
OP_STATUS ValidationErrorWindow::Create(ValidationErrorWindow*& window, FormObject* form_object, const uni_char* message)
{
	OP_ASSERT(form_object);
	OP_ASSERT(message);

	window = OP_NEW(ValidationErrorWindow, (form_object));
	if (!window)
	{
		return OpStatus::ERR_NO_MEMORY;
	}

	OpWidget* widget = form_object->GetWidget();
	OpWindow* parent_window = widget->GetParentOpWindow();
	OP_STATUS status = window->m_validation_bubble.CreateBubble(parent_window, message);
	if (OpStatus::IsError(status))
	{
		OP_DELETE(window);
		return status;
	}

	window->UpdatePlacementAndColors();
	return OpStatus::OK;
}