General :  K-Meleon Web Browser Forum
General discussion about K-Meleon 
Prefs panel - browser identification fix
Posted by: asmpgmr
Date: March 30, 2003 12:28AM

Currently in the Prefs - Privacy panel, the browser identification is blank until the list is accessed and if the value is changed then the next time K-Meleon is started this isn't reflected in the prefs panel. This change to PreferencesDlg.cpp should fix that, note the char variable pref must be 34 not 32 for kmeleon.privacy.useragent%d.string which is why the routine OnComboChanged is affected also.

BOOL CPreferencePage::OnInitDialog(){
switch (idd) {
case IDD_PREFERENCES_PRIVACY:
char buf[256], uabuf[256], pref[34];
int x=0,y,index=0;
do {
sprintf(pref, "kmeleon.privacy.useragent%d.name", x);
theApp.preferences.GetString(pref, buf, "");
if (*buf)
SendDlgItemMessage(IDC_COMBO, CB_ADDSTRING, 0, (LONG) buf);
x++;
} while (*buf);

theApp.preferences.GetString("general.useragent.override", uabuf, "");
if (*uabuf) {
for (y=0; y<x; y++) {
sprintf(pref, "kmeleon.privacy.useragent%d.string", y);
theApp.preferences.GetString(pref, buf, "");
if (strcmp(buf, uabuf) == 0)
index=y;
}
}
SendDlgItemMessage(IDC_COMBO, CB_SETCURSEL, index, 0);
break;
}

CDialog::OnInitDialog();

return FALSE; // return TRUE unless you set the focus to a control
}


void CPreferencePage::OnComboChanged() {
...
int index;
char buf[256], pref[34];
...

Options: ReplyQuote
Re: Prefs panel - browser identification fix
Posted by: MonkeeSage
Date: March 30, 2003 01:01AM

asmpgmr:

That worked, but if you have a custom useragent string, it still selects "default" in the combo box--but this is actually correct, I think, because while the custom string is not stored in useragent0.name, it is actually the default for the browser -- because by making a custom useragent string, you have overridden the real default.


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Prefs panel - browser identification fix
Posted by: asmpgmr
Date: March 30, 2003 02:55AM

Minor change for the case of a custom useragent string:


BOOL CPreferencePage::OnInitDialog(){
switch (idd) {
case IDD_PREFERENCES_PRIVACY:
char buf[256], uabuf[256], pref[34];
int x=0,y,index=-1;
do {
sprintf(pref, "kmeleon.privacy.useragent%d.name", x);
theApp.preferences.GetString(pref, buf, "");
if (*buf)
SendDlgItemMessage(IDC_COMBO, CB_ADDSTRING, 0, (LONG) buf);
x++;
} while (*buf);

theApp.preferences.GetString("general.useragent.override", uabuf, "");
if (*uabuf) {
for (y=0; y<x; y++) {
sprintf(pref, "kmeleon.privacy.useragent%d.string", y);
theApp.preferences.GetString(pref, buf, "");
if (strcmp(buf, uabuf) == 0)
index=y;
}
}
else
index=0;
if (index >= 0)
SendDlgItemMessage(IDC_COMBO, CB_SETCURSEL, index, 0);
break;
}

CDialog::OnInitDialog();

return FALSE; // return TRUE unless you set the focus to a control
}

void CPreferencePage::OnComboChanged() {
...
int index;
char buf[256], pref[34];
...

Options: ReplyQuote
Re: Prefs panel - browser identification fix
Posted by: asmpgmr
Date: March 30, 2003 03:22AM

On second thought maybe it should be left as in my original fix. If someone manually set the string then they likely wouldn't be using the prefs menu anyway. In any case once the combo box is activated, blank entry will never reappear so it probably shouldn't appear in the first place which is what the newer code would do for a custom useragent string.

Options: ReplyQuote
Re: Prefs panel - browser identification fix
Posted by: asmpgmr
Date: March 30, 2003 03:36AM

MonkeeSage,

Well which do you think is better in the case of a custom useragent string - initially displaying a blank entry in the list combo box or Default ?

Options: ReplyQuote
Re: Prefs panel - browser identification fix
Posted by: asmpgmr
Date: March 30, 2003 03:48AM

Actually it has to be the newer code for two reasons - kmeleon.privacy.useragent0.name doesn't necessarily have to be "Default" and if you scroll down and back up in the list that entry will then appear as blank or whatever kmeleon.privacy.useragent0.string is set to anyway.

Options: ReplyQuote
Re: Prefs panel - browser identification fix
Posted by: asmpgmr
Date: March 30, 2003 02:55PM

I came up with a better idea, the Default entry should be inherit in the code and always use general.useragent.override, this allows that pref to be directly edited via the panel and you'll always be able to see it. If it's not set then Default will be blank as always. Note with this change the kmeleon.privacy.useragent0 prefs will never be used but the others (kmeleon.privacy.useragent1 and up) will be used as before.


BOOL CPreferencePage::OnInitDialog(){
switch (idd) {
case IDD_PREFERENCES_PRIVACY:
char buf[256], uabuf[256], pref[34];
int x=1,y,index=0;
SendDlgItemMessage(IDC_COMBO, CB_ADDSTRING, 0, (LONG) "Default");
do {
sprintf(pref, "kmeleon.privacy.useragent%d.name", x);
theApp.preferences.GetString(pref, buf, "");
if (*buf)
SendDlgItemMessage(IDC_COMBO, CB_ADDSTRING, 0, (LONG) buf);
x++;
} while (*buf);

theApp.preferences.GetString("general.useragent.override", uabuf, "");
if (*uabuf) {
for (y=1; y<x; y++) {
sprintf(pref, "kmeleon.privacy.useragent%d.string", y);
theApp.preferences.GetString(pref, buf, "");
if (strcmp(buf, uabuf) == 0)
index=y;
}
}
SendDlgItemMessage(IDC_COMBO, CB_SETCURSEL, index, 0);
break;
}

CDialog::OnInitDialog();

return FALSE; // return TRUE unless you set the focus to a control
}

void CPreferencePage::OnComboChanged() {
switch (idd) {
case IDD_PREFERENCES_PRIVACY:
int index;
char buf[256], pref[34];

index = SendDlgItemMessage(IDC_COMBO, CB_GETCURSEL, 0, 0);
if (index == 0)
theApp.preferences.GetString("general.useragent.override", buf, "");
else {
sprintf(pref, "kmeleon.privacy.useragent%d.string", index);
theApp.preferences.GetString(pref, buf, "");
}

if (*buf)
SetDlgItemText(IDC_EDIT_USERAGENT, buf);
else
SetDlgItemText(IDC_EDIT_USERAGENT, "");

break;
}
}

Options: ReplyQuote
Re: Prefs panel - browser identification fix
Posted by: MonkeeSage
Date: March 30, 2003 07:59PM

Works well. smiling smiley


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Prefs panel - browser identification fix
Posted by: asmpgmr
Date: March 30, 2003 08:54PM

I opened bug 433 for this issue.

Options: ReplyQuote
Re: Prefs panel - browser identification fix
Posted by: Uwe Engel,
Date: April 19, 2003 08:14PM

HI,

I am new to this browser and I really don `t know where I can find the mentioned "PreferencesDlg.cpp". When I put the code into a macro, I always get an error "bad macro..." Please let me know how I can proceed.

thanx

uwe engel

Options: ReplyQuote
Re: Prefs panel - browser identification fix
Posted by: alain.aupeix@wanadoo.fr
Date: April 20, 2003 02:35AM

It's not a macro, it's the program.

The level just over :-))

Options: ReplyQuote
Re: Prefs panel - browser identification fix
Posted by: uwe engel
Date: April 21, 2003 10:06AM

thanx for your answer, but - where do I find "PreferencesDlg.cpp". It`s not in the programm folder of k-meleon, it`s nowhere..., do I need a special programm to change this file ?

Options: ReplyQuote
Re: Prefs panel - browser identification fix
Posted by: MonkeeSage
Date: April 21, 2003 02:45PM

It is part of the source code used to build the binary (k-meleon.exe).


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Prefs panel - browser identification fix
Posted by: uwe engel
Date: April 21, 2003 05:26PM

Ok, I think I am not that good as a programmer to change the source code now. Is it possible to get an update of k-meleon with this fixed bug or you could sent me your fixed k-meleon.exe via mail ? (mail to : label@layton-stone.com)

thank very much

Uwe Engel

Options: ReplyQuote


K-Meleon forum is powered by Phorum.