Thursday, May 18, 2006

wxWidgets code to launch browser

In wxWidgets, which is a wonderful multi-platform GUI C++ library loaded with really coool helper functions which works in Windows, Linux and OSX (and more), has a method called LaunchDefaultBrowser, which has lots of issues with MIME types, blah, blah.

So, as I'm sick of LaunchDefaultBrowser, which seems to always call epiphany browser under GNU/Linux, I decided to write a function to call a browser according to certain needs/parameters. So,

This function searches the PATH environment variable for this commands (according to no articular preference):

firefox
firefox-bin
mozilla
mozilla-bin
opera
konqueror
epiphany

It can probably be enhanced by some checks, but here you are:

void MainFrame::ExecuteURL(const wxString &link)
{

// variable declarations
wxArrayString browsers;
wxPathList path_list;
bool BrowserWasFound = false;
unsigned int i = 0;
wxString path;

// Add directories to wxPathList's search path from PATH environment variable
path_list.AddEnvList(wxT("PATH"));

// Add browsers filenames. First item = most priority
browsers.Add(wxT("firefox"));
browsers.Add(wxT("firefox-bin"));
browsers.Add(wxT("mozilla"));
browsers.Add(wxT("mozilla-bin"));
browsers.Add(wxT("opera"));
browsers.Add(wxT("konqueror"));
browsers.Add(wxT("epiphany"));

for (i = 0; i < browsers.GetCount(); i++) {
path = path_list.FindAbsoluteValidPath(browsers[i]);
if (path.IsEmpty()) {
continue;
} else {
BrowserWasFound = true;
break;
}
}

browsers.Clear();

if (BrowserWasFound) {
path += wxT(" ");
path += link;
::wxExecute(path);
} else {
wxMessageBox(wxT("No browser has been found."),MessageBoxHeader);
}
}

Hope it gets to be useful!

Labels:

Slashdot   Liked it? Submit this post to Slashdot!
posted by Arturo 'Buanzo' Busleiman @ 7:07 AM  
2 comments

Sunday, May 14, 2006

Protect your eMail users from Phishing

Hi!

If you are going to use an antivirus email-scanning (or header/subject rewriting) engine, try Clamscan. It detects most phishing scams out there, although it needs help on adding non-english-based scams :)

Tip of the week ;)

Labels:

Slashdot   Liked it? Submit this post to Slashdot!
posted by Arturo 'Buanzo' Busleiman @ 7:37 AM  
0 comments

OFFTOPIC - Fruityloops on GNU/Linux

Hi!

Today, I've discovered that Hydrogen 0.9.3 contains a hidden piano roll note's pitch editor that you can enable by:

1) running hydrogen
2) exiting
3) editing ~/.hydrogen/hydrogen.conf
4) replacing <usepitcheditor>false</usepitcheditor> with <usepitcheditor>true</usepitcheditor>
5) running hydrogen again

Now, in the UI, you'll notice a new button under "velocity" in the note editor.

Enjoy!

Labels:

Slashdot   Liked it? Submit this post to Slashdot!
posted by Arturo 'Buanzo' Busleiman @ 7:12 AM  
0 comments