void SecurityPasswordDialog::OnChange(OpWidget *widget, BOOL changed_by_mouse)
{

	// if we add a new password, make sure to inform the user about required quality of password
	if (m_callback && m_callback->GetMode() == OpSSLListener::SSLSecurityPasswordCallback::NewPassword)
	{
		OpString newpassword;
		OpString confirmpassword;

		GetWidgetText("Password_edit", newpassword);
		GetWidgetText("Confirm_password_edit", confirmpassword);

		m_ok_enabled = newpassword.Compare(confirmpassword) == 0 && ChangeMasterPasswordDialog::CheckPasswordPolicy(&confirmpassword);
		EnableButton(0, m_ok_enabled);

		if(ChangeMasterPasswordDialog::CheckPasswordPolicy(&newpassword))
		{
			SetWidgetText("Password_info_label",Str::SI_MSG_SECURE_ASK_NEW_PASSWORD_AGAIN);	
		}
		else
		{
			SetWidgetText("Password_info_label", Str::SI_MSG_SECURE_ASK_UPDATE_PASSWORD);		
		}
	}

	Dialog::OnChange(widget, changed_by_mouse);
}
示例#2
0
UINT32 GoToPageDialog::OnOk()
{
	OpString url;
	GetWidgetText("Address_field", url);

	GoToPage(url, 0);

	return 0;
}
示例#3
0
BOOL CookieEditDialog::OnInputAction(OpInputAction* action)
{
	if( action->GetAction() == OpInputAction::ACTION_OK )
	{
		if( m_cookie )
		{
			OpString name, value, old_name, old_value;
			OpString8 tmp;

			old_name.Set( m_cookie->Name() );
			old_value.Set( m_cookie->Value() );

			GetWidgetText("Name_edit", name );
			GetWidgetText("Value_edit", value );

			tmp.Set(name.CStr());
			m_cookie->SetName(tmp.CStr());
			tmp.Set(value.CStr());
			m_cookie->SetValue(tmp.CStr());


			time_t t;
			if( GetTime((OpEdit*)GetWidgetByName("Expire_date_edit"), (OpEdit*)GetWidgetByName("Expire_time_edit"), t) )
			{
				m_cookie->SetExpires( t );
			}

			if( GetTime((OpEdit*)GetWidgetByName("Last_visited_date_edit"), (OpEdit*)GetWidgetByName("Last_visited_time_edit"), t) )
			{
				m_cookie->SetLastUsed( t );
			}

			if( m_listener )
			{
				m_listener->OnCookieChanged( m_cookie, old_name.CStr(), old_value.CStr() );
			}

		}
	}
	return Dialog::OnInputAction(action);
}
示例#4
0
static void
GL_Button (int n)
{
    int index;
    n = gamesOptions[n].value; // use marker in option rather than n itself, for more easy adding/deletng of buttons
    if (n == 6) { // close
	PopDown(GameListDlg);
	return;
    }
    if (n == 3) { // thresholds
	LoadOptionsPopUp(GameListDlg);
	return;
    }
    if (n == 9) { // tags
	GameListOptionsPopUp(GameListDlg);
	return;
    }
    index = SelectedListBoxItem(&gamesOptions[0]);
    if (n == 7) { // load
	if (index < 0) {
	    DisplayError(_("No game selected"), 0);
	    return;
	}
    } else if (n == 5) { // next
	index++;
	if (index >= listLength || !list[index]) {
	    DisplayError(_("Can't go forward any further"), 0);
	    return;
	}
	HighlightWithScroll(&gamesOptions[0], index, listEnd);
    } else if (n == 8) { // prev
	index--;
	if (index < 0) {
	    DisplayError(_("Can't back up any further"), 0);
	    return;
	}
	HighlightWithScroll(&gamesOptions[0], index, listEnd);
    } else if (n == 2 || // narrow
               n == 4) { // find position
	char *text;
	GetWidgetText(&gamesOptions[1], &text);
        safeStrCpy(filterString, text, sizeof(filterString)/sizeof(filterString[0]));
        GameListPrepare(True, n == 2); GameListReplace(0);
        return;
    }

    index = atoi(list[index])-1; // [HGM] filter: read true index from sequence nr of line
    if (cmailMsgLoaded) {
	CmailLoadGame(glc->fp, index + 1, glc->filename, True);
    } else {
	LoadGame(glc->fp, index + 1, glc->filename, True);
    }
}
示例#5
0
void GoToPageDialog::OnChange(OpWidget *widget, BOOL changed_by_mouse)
{
	if(widget->IsNamed("Nick_field"))
	{
		OpString nick;
		GetWidgetText("Nick_field", nick);

		if(g_hotlist_manager->HasNickname(nick, NULL, FALSE, TRUE))
		{
			CloseDialog(FALSE,FALSE,TRUE);
			OpenNickname(nick,FALSE);
		}
	}
}
示例#6
0
// the bold argument says 0 = normal, 1 = bold typeface
// the colorNr argument says 0 = font-default, 1 = gray
void
ScrollToCursor (Option *opt, int caretPos)
{
    Arg args[10];
    char *s;
    int len;
    GetWidgetText(opt, &s);
    len = strlen(s);
    if(caretPos < 0 || caretPos > len) caretPos = len;
    if(caretPos > len-30) { // scroll to end, which causes no flicker
        static XEvent event;
        XtCallActionProc(opt->handle, "end-of-file", &event, NULL, 0);
        return;
    }
    // the following leads to a very annoying flicker, even when no scrolling is done at all.
    XtSetArg(args[0], XtNinsertPosition, caretPos); // this triggers scrolling in Xaw
    XtSetArg(args[1], XtNdisplayCaret, False);
    XtSetValues(opt->handle, args, 2);
}
UINT32 GroupPropertiesDialog::OnOk()
{
	if( m_group )
	{
		HotlistManager::ItemData item_data;

		GetWidgetText("Name_edit", item_data.name);

		if(g_hotlist_manager->RegisterTemporaryItem( m_group,m_parent_id))
		{
			// New item
			g_hotlist_manager->SetItemValue( m_group, item_data, TRUE );
		}
		else
		{
			// The item was only modified
			g_hotlist_manager->SetItemValue( m_group, item_data, TRUE );
		}
	}

	return 0;
}
示例#8
0
static void
SpinCallback (Widget w, XtPointer client_data, XtPointer call_data)
{
    String name, val;
    Arg args[16];
    char buf[MSG_SIZ], *p;
    int j = 0; // Initialisation is necessary because the text value may be non-numeric causing the scanf conversion to fail
    int data = (intptr_t) client_data;
    Option *opt = dialogOptions[data >> 8] + (data & 255);

    XtSetArg(args[0], XtNlabel, &name);
    XtGetValues(w, args, 1);

    GetWidgetText(opt, &val);
    sscanf(val, "%d", &j);
    if (strcmp(name, _("browse")) == 0) {
	char *q=val, *r;
	for(r = ""; *q; q++) if(*q == '.') r = q; else if(*q == '/') r = ""; // last dot after last slash
	if(!strcmp(r, "") && !currentCps && opt->type == FileName && opt->textValue)
		r = opt->textValue;
	Browse(data>>8, opt->name, NULL, r, opt->type == PathName, "", &p, (FILE**) opt);
	return;
    } else
UINT32 ReportSiteProblemDialog::OnOk()
{
	OpString address, comment, complete;

	GetWidgetText("Page_address_edit", address);
	GetWidgetText("Comment_edit", comment);

	// Using same escaping as we do for Google
	XMLEscapeString(comment);

	OpString on;
	OpString off;
	on.Set("on");
	off.Set("off");

	OpString identify_as;

	if (m_user_agent.FindI("msie") != KNotFound)
	{
		identify_as.Set("msie");
	}
	else if(m_user_agent.FindI("mozilla") != KNotFound)
	{
		identify_as.Set("mozilla");
	}
	else
	{
		identify_as.Set("opera");
	}

	if (m_images.HasContent())
	{
		m_images.MakeLower();
	}

	OpString category;

	OpDropDown* dropdown = (OpDropDown*) GetWidgetByName("Category_dropdown");
	if (dropdown)
	{
		int selected = dropdown->GetSelectedItem();

		switch (selected)
		{
		case 1:
			category.Set("minor");
			break;
		case 2:
			category.Set("major");
			break;
		case 3:
			category.Set("unusable");
			break;
		case 0:
		default:
			category.Set("unspecified");
			break;
		}
	}

	complete.Set("<?xml version=\"1.0\"?>\n<sitereport version=\"1.0\">\n");
	complete.Append(" <page>\n  <url>");
	complete.Append(address);
	complete.Append("</url>\n");
	complete.Append("  <render mode=\"");
	complete.Append(m_strict_mode ? "strict" : "quirks");
	complete.Append("\"/>\n");
	complete.Append(" </page>\n");
	complete.Append(" <client>\n  <capabilities>\n");
	complete.Append("   <encoding>");
	complete.Append(m_encoding);
	complete.Append("</encoding>\n");
	complete.Append("   <popup block=\"");
	complete.Append(m_popups);
	complete.Append("\"/>\n   <java state=\"");
	complete.Append(m_java ? on : off);
	complete.Append("\"/>\n   <plugins state=\"");
	complete.Append(m_plugins ? on : off);
	complete.Append("\"/>\n   <javascript state=\"");
	complete.Append(m_javascript ? on : off);
	complete.Append("\" errors=\"off\"/>\n   <referrer state=\"");
	complete.Append(m_referrer_logging ? on : off);
	complete.Append("\"/>\n   <proxy state=\"");
	complete.Append(m_proxy ? on : off);
	complete.Append("\"/>\n   <images state=\"");
	complete.Append(m_images);
	complete.Append("\"/>\n   <cookies normal=\"");
	complete.Append(m_cookies ? "accept" : "reject");
	complete.Append("\" thirdparty=\"");
	complete.Append(m_cookies3 ? "accept" : "reject");
	complete.Append("\"/>\n");
	complete.Append("   <identify as=\"");
	complete.Append(identify_as);
	complete.Append("\"/>\n");

	// not completed, don't forget to add to "Advanced" field:

	OpString buildno, version, opsys;

	buildno.Set(VER_BUILD_NUMBER_STR);
	version.Set(VER_NUM_STR);
	opsys.Set(g_op_system_info->GetPlatformStr());

	complete.Append("   <patch state=\"");
	complete.Append("on"); // on|off|partial
	complete.Append("\"/>\n");
	complete.Append("   <version buildno=\"");
	complete.Append(buildno);
	complete.Append("\" version=\"");
	complete.Append(version);
	complete.Append("\" opsys=\"");
	complete.Append(opsys);
	complete.Append("\"/>\n");
	complete.Append("   <contlang>");
	complete.Append("en"); // q-string
	complete.Append("</contlang>\n");
	complete.Append("   <css mode=\"author\"/>\n"); // author|user

	// end not completed section

	complete.Append("  </capabilities>\n");
	complete.Append(" </client>\n");
	complete.Append(" <comment>");
	complete.Append(comment);
	complete.Append("</comment>\n");
	complete.Append(" <category>");
	complete.Append(category);
	complete.Append("</category>\n");
	complete.Append("</sitereport>");

	OpString8 complete8;
	complete8.SetUTF8FromUTF16(complete.CStr());

	URL content_url = urlManager->GetNewOperaURL();
	content_url.Unload();
	content_url.ForceStatus(URL_LOADING);
	content_url.SetAttribute(URL::KMIME_ForceContentType, "application/xml;charset=utf-8");
	content_url.WriteDocumentData(URL::KNormal, complete8.CStr(), complete8.Length());
	content_url.WriteDocumentDataFinished();
	content_url.ForceStatus(URL_LOADED);

	OpString post_address;
	post_address.Set("http://xml.opera.com/sites/");

	URL form_url = urlManager->GetURL(post_address.CStr(), UNI_L(""), true);
	form_url.SetHTTP_Method(HTTP_METHOD_POST);

	Upload_Multipart *form = OP_NEW(Upload_Multipart, ());

	if (form)
	{
		TRAPD(op_err, form->InitL("multipart/form-data"));
		OpStatus::Ignore(op_err);
				
		Upload_URL *element = OP_NEW(Upload_URL, ());
		if (element)
		{
			TRAP(op_err, element->InitL(content_url, NULL, "form-data", "xmldata", NULL, ENCODING_NONE));
			TRAP(op_err, element->SetCharsetL(content_url.GetAttribute(URL::KMIME_CharSet)));
			
			form->AddElement(element);
			TRAP(op_err, form->PrepareUploadL(UPLOAD_BINARY_NO_CONVERSION));
		
			form_url.SetHTTP_Data(form, TRUE);
		
			URL_InUse* url_inuse = OP_NEW(URL_InUse, ()); // SMALL LEAK - FIXME
			if (url_inuse)
			{
				url_inuse->SetURL(form_url);
			
				URL url2 = URL();
#ifdef _DEBUG
				// Not silent loading:
				BOOL3 open_in_new_window = YES;
				BOOL3 open_in_background = MAYBE;
				Window *feedback_window;
				feedback_window = windowManager->GetAWindow(TRUE, open_in_new_window, open_in_background);
				feedback_window->OpenURL(form_url, DocumentReferrer(url2), true, FALSE, -1, true);
#else
				//  Silent loading:
				form_url.Reload(g_main_message_handler, url2, TRUE, FALSE);
#endif
			}
		}
		else
			OP_DELETE(form);
	}
示例#10
0
BOOL GoToPageDialog::OnInputAction(OpInputAction* action)
{
	switch (action->GetAction())
	{
		case OpInputAction::ACTION_GO_TO_PAGE:
		case OpInputAction::ACTION_GO_TO_TYPED_ADDRESS:
		{
			OpString url;
			GetWidgetText("Address_field", url);

			CloseDialog(FALSE);

			GoToPage(url, action);

			return TRUE;
			break;
		}
		case OpInputAction::ACTION_GO:
		{
			OpEdit* widget = (OpEdit*) GetWidgetByName("Nick_field");
			if(widget)
			{
				OpString nick;
				GetWidgetText("Nick_field", nick);

				if(g_hotlist_manager->HasNickname(nick, NULL, TRUE, TRUE))
				{
					CloseDialog(FALSE);
					OpenNickname(nick,TRUE);
				}
			}
			return TRUE;
			break;
		}

		case OpInputAction::ACTION_PASTE_AND_GO:
		case OpInputAction::ACTION_PASTE_AND_GO_BACKGROUND:
		{
			OpString text;
			g_desktop_clipboard_manager->GetText(text);
			if (text.HasContent())
			{
				OpAddressDropDown* dropdown = (OpAddressDropDown*) GetWidgetByName("Address_field");
				if (dropdown)
					dropdown->EmulatePaste(text);

				// This is a bit tricky. Paste&Go has a default shortcut that includes Ctrl and Shift which
				// normally redirects a url to a new tab. That is why we test IsKeyboardInvoked() below. In
				// addition the 'NewWindow' pref tells us to open in a new tab/window no matter what (DSK-313944)
				if (g_pcdoc->GetIntegerPref(PrefsCollectionDoc::NewWindow))
				{
					if (g_application->IsSDI())
						g_input_manager->InvokeAction(OpInputAction::ACTION_OPEN_URL_IN_NEW_WINDOW, 0, text.CStr());
					else
					{
						BOOL bg = action->GetAction() == OpInputAction::ACTION_PASTE_AND_GO_BACKGROUND;
						g_application->GoToPage(text, TRUE, bg, TRUE, NULL, (URL_CONTEXT_ID)-1, action->IsKeyboardInvoked());
					}
				}
				else
				{
					BOOL bg = action->GetAction() == OpInputAction::ACTION_PASTE_AND_GO_BACKGROUND;
					g_application->GoToPage(text, bg, bg, TRUE, NULL, (URL_CONTEXT_ID)-1, action->IsKeyboardInvoked());
				}
				CloseDialog(FALSE);
			}
			return TRUE;
			break;
		}

#ifdef _X11_SELECTION_POLICY_
		case OpInputAction::ACTION_PASTE_SELECTION_AND_GO:
		case OpInputAction::ACTION_PASTE_SELECTION_AND_GO_BACKGROUND:
		{
			OpString text;
			g_desktop_clipboard_manager->GetText(text, true);
			if (text.HasContent())
			{

				OpAddressDropDown* dropdown = (OpAddressDropDown*) GetWidgetByName("Address_field");
				if (dropdown)
					dropdown->EmulatePaste(text);

				BOOL bg = action->GetAction() == OpInputAction::ACTION_PASTE_SELECTION_AND_GO_BACKGROUND;
				if (g_pcdoc->GetIntegerPref(PrefsCollectionDoc::NewWindow))
				{
					if (g_application->IsSDI())
						g_input_manager->InvokeAction(OpInputAction::ACTION_OPEN_URL_IN_NEW_WINDOW, 0, text.CStr());
					else
						g_application->GoToPage(text, TRUE, bg, TRUE, NULL, (URL_CONTEXT_ID)-1, action->IsKeyboardInvoked());
				}
				else
					g_application->GoToPage(text.CStr(), bg, bg, TRUE, NULL, (URL_CONTEXT_ID)-1, action->IsKeyboardInvoked());
			}
			return TRUE;
		}
#endif
		case OpInputAction::ACTION_OPEN_URL_IN_CURRENT_PAGE:
		{
			// If Opera is configured not to reuse pages, it should be opened 
			// in a new page or new window instead of in the current page
			if (g_pcdoc->GetIntegerPref(PrefsCollectionDoc::NewWindow))
			{
				if (g_application->IsSDI())
					g_input_manager->InvokeAction(OpInputAction::ACTION_OPEN_URL_IN_NEW_WINDOW, action->GetActionData(), action->GetActionDataString(), this);
				else	// tabbed or MDI
					g_input_manager->InvokeAction(OpInputAction::ACTION_OPEN_URL_IN_NEW_PAGE, action->GetActionData(), action->GetActionDataString(), this);
				CloseDialog(FALSE);
				return TRUE;
			}
		// fall through
		}
		case OpInputAction::ACTION_OPEN_URL_IN_NEW_PAGE:
		case OpInputAction::ACTION_OPEN_URL_IN_NEW_BACKGROUND_PAGE:
		case OpInputAction::ACTION_OPEN_URL_IN_NEW_WINDOW:
		{
			CloseDialog(FALSE);
			// Do not kill the action, underlying components will handled it (application),
			// only close the dialog because the user is done entering a url in the addressdropdown
			return FALSE;
		}
		
	}

	return Dialog::OnInputAction(action);
}