New Project: Eclipse?

To start on doing any android work, it turned out I needed to update Eclipse, because the version I had was one-too-old to actually download some of the add-ons you need for Android development. So I go download the latest Eclipse, a new version 4.2 (Juno) came out recently, so that’s what I grab.

Get it up and running and there’s some very noticeable changes to the UI. Not layout, appearance. The previously gray toolbar is now bright blue with this white streak at the top. And not only that, part of the toolbar (the perspective switcher) is a completely different color.

For whatever reasons, I found this to be extremely distracting. So I poked around in settings and found the “theme” options for Eclipse. This is the “Windows 7” look? This doesn’t look like any Windows 7 I know. Something looks off. So I tried Default theme and Classic theme and Windows 7 Classic, and Windows XP Olive was pretty much the only scheme that didn’t have that hideous blue toolbar, and that was because it had a green one. Oi!

Naturally I started to question whether you could install add-on themes or modify the themes. At first I was haivng a hard time finding what I was looking for because I kept finding eclipse text-editor color themes, color schemes for the text-editing component rather than themes for the UI for the entire application.

In this latest release of Eclipse they actually re-vamped the entire application theming support to use CSS to define some of the look and colors and whatnot. I found out where the CSS files for the schemes are, and tried tinkering around with them a little, finding that the solution of deleting (renaming) the CSS directory entirely produced the results I was most happy with initially. At least, it looked more like the old eclipse.

So the needs I was seeing where that (A) this new scheming support is quite poorly documented, probably because the developers are too busy coding it to actually document how to design a custom scheme and what things you can modify. (B) the plugins to add custom schemes are quite limited and hard to find, and the one I found that was seemingly decent overall was having some issues with a self-signed HTTPS certificate causing the program to reject installing the plugin from the update site. I did eventually get it working in a sub-optimal manner, so I am using that theme now to make eclipse a little less ugly.

But it got me thinking whether maybe this was an area I could contibute to, helping to make the new UI themes more accessible in terms of documentation or plugins to download and install other people’s custom themes easily or something along those lines.

Alternatively, maybe I could just make a plugin to fix some of those “issues” that I’ve never liked about Eclipse? (the menu bloat! the menu bloat!) (what? you can’t right click on the toolbar and select customize? Is that a bug or by design?)

There is a part of me that feels almost like a traitor, as a former Netbeans developer, to even consider contributing to Eclipse. But like how the old saying goes of how “if you can’t beat them join them”, my personal take is that Oracle is not doing justice to Netbeans in their support for the platform. They had some really cool and unique things they were working to do with the platform that nobody else had done or done well that could have pushed them to the forefront of the IDE market in unique ways, but when they eliminated all US-based development of the platform (Ok, so that was right before Oracle’s time, details) the message it sends about the sustainability of their platform long term wasn’t “we’re focusing our development efforts on the core feature of the IDE that are most popular” but rather “this just isn’t as important to us as it once was, we’re moving on to other things to focus our resources on”. They could be doing a lot more to push the platform, but they’re not. Eclipse, on the other hand, aside from it’s current and/or former support from IBM trying to one up their competition, has the oomph of having successfully recruited Google to push Eclipse as *THE* IDE of choice for Android. You want the latest greatest technologies that are on the rise all coming to your platform if you’re going to be a market leader of a platform. They seem to have some strategy points there, whether or not I personally like certain things about the IDE.

But maybe some of those things I wish were different about the IDE are things that could be improved upon? Maybe there’s a place I could contribute to make it suck less? And to be honest, it doesn’t suck that bad feature-wise, it’s mostly the cosmetics that bug me. The whole interface looks a bit ADD with everything and the kitchen sink thrown in whether you need it or not, and every plugin thinks it is the most important plugin ever and is filling your top level menus with all kinds of items that aren’t as important to you as they apparently are to someone else. I prefer a more streamlined interface that doesn’t have so much visual clutter overwhelming me for all these features I rarely use. But what’s to say it wouldn’t be possible to make a plugin that automatically condenses menu segments into sub-menus like they ought to be? It might be difficult, but it might not be impossible.

New Project: Android Apps?

Another project idea that crossed my mind was getting back into doing Android programming. Android continues to be gaining in market share, and I happen to have an Android phone I could test on. Writing Android apps is a potentially marketable skill, and one that would potentially lend itself to part-time contract work, should I wish to look for that sort of work. A project in this arena would both refresh my memory, expand my knowledge, and give me a portfolio to show for my skills. “Oh, yes, I could write an app for you. You want to know I’m capable? Well, have a look at some of the stuff I’ve done before”

I have been pondering what sort of app I’d want to write. A game? Maybe a game timer? The last time I visited my sister we were playing Taboo, and the sand timer wasn’t cutting it…the timer-watcher would forget to keep watching. So my dad ended up pulling out his iphone and setting a stopwatch alarm on there to time the remaining rounds. Would a dedicated android app potentially be more useful or work better? There seem to be chess timers out there, various other sorts of game timers, and the like. You can even download an app that IS Taboo in non-box form. Each one was riddled with its own sorts of issues, that one looks to specialized, not easy to use for just replacing the timer from this or that game, not pretty to look at, not intuitive, etc. Things have been written, but nothing that would be as simple as I’d like, while adding more useful functionality than just using the stopwatch. Like I might want the game-time for popular games pre-populated so I don’t have to remember whether boggle uses a 3 minute timer or a 1 minute timer. I might want optional “loud ticking” or some other auditory warning when time is running out. I want to just click a button or two when I launch the app so I can get going quick. 3 minute timer, go. Easy to pause. Without a lot of fuss out of the box, making it take less time to set up than a general stopwatch program. If you could make the user-interface dead-simple and easy to use, AND aesthetically pleasing, there might be an app worth the trouble of making.

Trying to solve an actual problem on my phone revealed another potential project. My phone’s been having frequent sudden drops in amount of battery available. It’s also had some problems with wake-lock freezing the phone, and some dead-zones due to some geographical features of where I’m trying to use my phone. So I’ve been trying to passively monitor why my phone’s battery is going from lots of juice to “charge me RIGHT now”. Android has a built in battery monitor graph, but you can’t zoom in on the graph, which seems to be a big problem because I see this big drop that happened four hours ago and I can’t zoom in to see what time that was…was that when someone called or texted? Or around the time of day I pulled the battery? Was the screen on? Was I using the phone? Did I receive a voice call? And for that matter, why is my phone being awake so much when I’m not using it? Is there something eating my battery that needs to be uninstalled Some of these things you can tell from the built in battery monitor, some you can’t directly. I looked at 3rd party apps, and there was one that had a semi-decent historical graph which showed voice calls in addition to what android shows by default, but I didn’t like some of the other things it came with, like doing it’s own logging (wasting battery) and monitoring other apps for hogging the battery (again, wasting more battery). So I keep finding myself wanting better battery use graph that allows zooming. When you start showing 8 hours on a 2″ wide screen, you start to not see a lot of detail. I’d want something that just looks at existing system logs if they’re exposed (they must be somehow because one of the apps I downloaded appears to be replicating the battery use module slightly better) and gives clues as to what was going on then, so I can trace it to whether that unexpected drop was not so unexpected after all, or whether I need to look into whether something is using too much battery that shouldn’t be for unnecessary updates, mis-configured etc.

New Project: Porting PopTrayU to FreePascal?

Poking around on the internet for one reason or another (maybe I was browsing posts about Delphi on the Programmers Stack Overflow/Exchange site?), I came across something interesting. Lazarus, the open-source IDE for Free Pascal. 

Lazarus is an open source equivalent to Delphi. Well, not exactly equivalent, but pretty close.. It comes with (not terribly well documented at the moment) tools to port Delphi code to Free Pascal, and comes with the Lazarus Component Library (LCL) which is very similar to Delphi’s Visual Component Library (VCL).

The idea of porting PopTrayU to an open source development platform instead of an expensive closed source one (namely: Delphi XE) is very much in the spirit of open-source development. It was always one of the dreams of Renier (the original PopTray developer) to port PopTray to a free platform, and he indicated he might be interested in continuing to develop the app if it could be ported. And it would save me the expense of upgrading to Delphi XE to fix some various bugs.

I’d previously looked into porting PopTray to the free version of Turbo Delphi 2006, but my feasibility analysis results were that it was not feasible. That version of Delphi, aside from being discontinued/no longer supported or “officially” available, was that it left out a key feature (namely, 3rd party component support).

Free Pascal and Lazarus, from what I’ve said so far looks more promising as far as being feasible. Indy components has been ported to Free Pascal, which is a key stepping stone, though investing whether I’d have to port to Indy 10 first or not remains to be determined. So far everything else I’ve been reading looks like it would “probably” be possible without significant loss of critical features, but it wouldn’t be a plug and play transition, you have to rename a bunch of things and change the imports, and some of the UI might get mangled porting it so you might have to redraw parts of the UI. But so far haven’t come across any definite showstoppers.

At the moment, the biggest risk for showstopping problems would be if there is a missing library eg “things that are very windows specific” may be missing. But nothing specific yet. There would definitely be some hurdles to fix the unicode issues, but that’s to be expected and certainly fixable. Even though Free Pascal is multi-platform, the probram would still only run on Windows, because of Indy and it’s limited compatibility with other platforms.

So that’s on my todo list. And in between downloading Lazarus and now, they’ve already gone from version 0.8 to 1.0 of the IDE. Actively developed and being improved regularly is a positive sign to look for.

New Project: Semagic?

An initial contender for my next hobby project was contributing to Semagic. It’s an open source blogging tool, it’s written in C++. I’ve been using it for a long time to manage personal blogs and my old tech blog on livejournal, and for the most part, it works quite well and is fairly robust. But keeping with the times, I’ve moved my tech blog to a self-hosted wordpress blog where I retain greater control and have a lot more ability to customize the blog. But, even with all the fancy javascript driven (html5?) “auto-save” stuff on the post a new entry admin page, I’ve already lost multiple blog entries to random irrecoverable errors that happen only sporadically after you press post or save draft.

So then I started looking into native applications to use as editors for my posts for wordpress, rather than using the web interface. There’s really not a whole lot out there. A couple that weren’t very robust or feature-complete and were not open source, one from Microsoft that may or may not have been part of a business unit that was disbanded, oh, and it turns out Semagic does have some rudimentary support to post to wordpress IF you can figure out the settings right (they’re not very well documented).

So I started looking into that. It’s a one-man project, so a lot of things aren’t very well documented, like, say, what IDE you even need to compile the project. I did poke around in the project’s feature requests and bug tracker to evaluate whether there looks like stuff I could help with. Probably so. I thought for starters I could fix an easy one and see how that goes, as far as patches being accepted or whether the project was unreceptive to contributions. So I updated the icon to have a Vista/Win7 resource. I took the largest bitmap I could find of the application’s logo/icon (turned out to be the one on the login screen), and traced it with a vector-editing program (corel draw), to come up with a scalable version of the logo, not straying from it’s existing design, and then converted it back to a bitmap image at the proper size and added the appropriate shadows. So that was kind of fun, and here’s what I came up with:


Two versions, one following the design of the smaller icon views, and one that includes the spiral that would have been too much detail for smaller views.

But anyway, as far as moving on to actually starting to edit any code, it turns out you need Visual Studio 6 to compile. The author had attempted to port it to Visual Studio 2005, but was unsuccessful in finding the right combination of switches and flags and changes to fully compile with the new IDE. I actually at one time had Visual Studio 6. It’s not currently on my machine, as it’s quite a bit “obsolete” to the same era as Delphi 7. In fact, I think the disk is at my parents house in a box somewhere, so not convenient to re-install, and if I want it, I may have to wait till the next time I visit them to look for it.

But, seeing whether I could port it to build on a newer version of visual studio, say the free version of Visual Studio 2010, since that’s what’s current (Visual Studio may imminently release the free version of Visual Studio 2012, but it wasn’t out yet when I looked). On the one hand, that’s tough to try to jump into an unfamiliar project in a language you don’t have expert mastery over all the compilation settings, without at least having gotten your configuration working in a known environment (Say, VS6), but on the other hand, that puts you in a modern free IDE which is ideal for open source development, where you wouldn’t have to hack the Vista/Win7 icon resources into the EXE *after* you build it (there’s a 3rd party app that will replace the icon resource on a completed EXE) and might be able to make it look a little sleeker on modern OSes, so it’s not without it’s merit.

But, to install Visual Studio 2010, even the free edition, you need to have all the latest service packs installed. For Vista that means service pack 2. So I started working on installing all the hotfixes and service packs on old dying laptop that’s already had it’s motherboard replaced once only has Vista. That went well, until I got to trying to install service pack 1. Somewhere along the way after a reboot or three, it froze and stopped installing. After waiting several hours, I was quite certain it was frozen and not just “still busy” and had to reboot and the recovery tool couldn’t repair my service pack upgrade (perhaps a hardware driver conflict?) and the only option I had to get back to a working computer was to rollback the installation of the service pack.

All in all, I have to say, Microsoft has done quite a robust job at their recovery tools for software upgrades, and I was pleased I wasn’t at the point like you would be in the olden days where you’d have to reformat and reinstall the OS to recover. But that left me at the point of not having service pack 1 let alone 2 installed, and hesitant about whether it’s worth risking killing another motherboard/making the computer inoperable, especially when I had some other more important stuff (like tax related things) that really needed to be done on *that* computer if at all possible in the meantime. So I set that project aside for now. It’s still on my radar. It’s still one I’d like to contribute to, the wordpress support in it is far from feature-complete, and not terribly well documented. Examples: I was afraid I was going to lose my configuration settings for my other blog just to set up posting to WordPress (turns out it doesn’t, the dialog just needs a couple UI things clarified). It doesn’t seem like you can post as a draft to have your draft saved on the server, but unpublished. Etc. But it’s on hold until either I can get ahold of my disk(s) for visual studio 6, or I get a new laptop that is not going to buckle and die at the mere thought of installing the latest service packs. Or until I find room for an external monitor to hook up to my netbook… Projects for another day I guess.

New Project?

I’ve been thinking for a while about finding a secondary project to get involved in. While I could probably find plenty of things to do with PopTrayU, it would be more practical, career-wise to also keep myself fresh with a programming in a language that’s a bit more in demand for paying jobs, so I’m fresh on the draw when I find something aweseome I want to interview for.

So I started thinking about what sort of project to do. At first nothing was coming to mind, and browsing open source project sites wasn’t particularly inspiring. But I gave the idea of a project some time to simmer. And then I ended up coming up more than enough ideas which I will write more about in separate posts 🙂

New Project?

I’ve been thinking for a while about finding another project to get involved in. While I could probably find plenty of things to do with PopTrayU, I kind of wanted to round out my development time with a language that’s a little more in demand for paying jobs, and round out my involvement to include another open source project or two.

HTML Email Preview

One of the complaints I’ve heard about the feature of having html preview of emails is that spam-bots often track whether emails are read by embedding a unique image, and tracking if the image gets downloaded. It’s a legitimate concern, one I was well aware of when I added the HTML preview option. But it came down to being a value vs. risk proposition.

The HTML preview window in PopTrayU
The HTML preview window in PopTrayU

For version 1.0 of the feature, that seemed like a perfectly reasonable risk to accept. When I check my email from my phone, it displays in HTML and doesn’t have an option to disable loading images either. And, if like me, you run your email through a really good spam filter (like Gmail), you aren’t getting a lot of spam in your inbox in the first place. But that’s not necessarily the case for people using PopTrayU to check their ISP email account, which is a very common use case.

But that doesn’t mean it shouldn’t be somehow addressed in subsequent releases.

Initially, when I’d looked into HTML components, my first choice was a native Delphi HTML rendering component. But upon investigation, the component was too old and did not support CSS at all, which was a deal-breaker since font tags are completely deprecated these days. I mean, I could have added CSS support myself, but that is an extremely complex feature to implement correctly, with many corner cases. You’re pretty much writing a web-browser minus the network connections part. Much bigger scope than I was willing to take on.

So my second strategy was to use the TWebBroswer control to render the HTML, which is essentially a wrapper for an embedded internet explorer window. You get the HTML rendering almost for free with that technique. But…Internet explorer has this known bug that the “offline mode” flag in the component is completely ignored, and it decides whether you are online by a global registry setting or whether an internet connection is present. Less than ideal for this purpose. Any external content is really undesirable for spam email previewing.

So then I looked into maybe I could just pre-process the HTML and strip out the images. Removing <img> tags wasn’t too difficult. You can either do that with a regular expression or a for loop iterating through the characters in the message. Well, it turns out to be a little more complex than that. Images don’t just come from <img> tags anymore. Images are embedded in CSS that’s slapped in the body section of the message using url(…) syntax. Images are embedded through inline CSS. Almost any CSS component could have an image as part of a background or bullet image or border or any number of other places. And then you need to strip out any javascript, because that might be loading images or external content, so there go onclick, onload, and other properties that could be on any element in the document. And you need to get rid of external css files, you need to get rid of object tags, maybe even image maps. Point is, it gets really complex really fast.

After realizing how many loopholes there could be in pre-processing, I came back to the conclusion that pre-processing isn’t the “right” strategy. It’s a hack, that might work most of the time, but it’s never going to be as sure-fire as doing it right. The right way would be to block the requests at the network level or the browser level. Oh, you want to request a file off the internet? No, you haven’t clicked the magic button that says this is trusted content, forbidden.

Which brings me back to offline mode and that annoying bug that IE ignores the offline mode parameter. Why did they even bother putting that in their spec for the interface to their WebBrowser control in the first place? I’m sure there’s some technical reason they decided to not handle the parameter correctly. They even have a knowledge base article for a very old version of IE (IE5?), explaining the issue, and that there are no known workarounds. Very helpful.

Then I started to look into other replacements for the TWebBrowser control. There was one that initially looked promising, a firefox component that attempted to be a direct replacement for the TWebBrowser. So close, in fact, that you can patch a compiled EXE to put it in without touching the code. But…there were some big buts. But the newest version it comes for is Firefox 1.5, a seven year old version. This code is not maintained, it does not have bug fixes, it’s poorly documented, nevermind the possible security issues. Oh, plus it doesn’t implement any of the “more complex” aspects of the TWebBrowser interface, for example, it can’t create the page from a memory stream rather than from a file on the hard drive, so then I’d have to start littering the hard drive with unnecessary temp files. And even if I changed the code to do that, there’s no guarantees I’d be able to get it to work at all.

Then there’s a Google Chrome Frame. It’s not a direct replacement, and is not an activex control like the TWebBrowser or the Firefox browser component. It only supports HTTP requests (not file) unless you muck around with some settings, probably have to start writing temp files, etc. I haven’t played with it enough to assess whether it would be a feasible option or not.

One thing I did implement was adding some logic that if a message is marked as spam when you hit preview, it switches to plain-text view instead of HTML automatically. At least that solves the problem of how do you preview a message that might be spam, without having to open another non-spam email and switch tabs and then close the window and preview the spam message. That was a step in the right direction.

And then I also figured out that if you set “offline mode” in any internet explorer window, they ALL go offline, including the embedded browser window in PopTrayU. So, if you really don’t want external content to load, all you have to do is set IE offline. Of course, then you cant surf the internet in IE at the same time. But if you’re pretty serious about security, there’s a good chance you don’t use IE as your primary browser anyhow. So that’s one option. A workaround. Less than ideal for some users. But may be totally sufficient for others. Potentially I could pragmatically enter offline mode before rendering the page and then return to online mode after, affecting other IE windows as well, though that would affect other IE windows doing stuff in the background (hope you don’t have a big file download going on in the background!).

So then I get back to debating whether I should just nix the whole experimental “hide images” feature entirely, because it’s just not worth the trouble of making it work, or keep pressing in to try to find a way to make it work that’s going to be a lot of work for a modest return. There are plenty of other features and bugs and refactoring that could easily occupy my time instead. Decisions…

Writing a string to a stream in Delphi

There are two tricks to this. Most of this comes from what Embarcadero suggests on how to write a string to a stream. Another website suggested multiplying the length times the number of bytes to make sure the code works on both unicode and non-unicode builds, something one would be wise to consider when developing legacy code on Delphi 7, that may someday get ported to a newer version. One less thing to worry about later.

procedure WriteStringToStream(stream: TStream; const appendText: string);
begin
  stream.WriteBuffer(Pointer(appendText)^, Length(appendText)*SizeOf(Char));
end;

Solutions

I finally found a solution to how to get raw emails with arbitrary, possibly modified headers, strange encodings, etc. into PopTrayU for testing, Test Catch-all Email Server, a java-based POP3 email server for windows and other platforms.

Finding the right POP3 server was tricky and took a lot of research and mis-starts. I kept finding programs that looked to complex to learn, poorly documented, unclear whether they could even solve my problem, ones that would require re-compiling with a bit of non-trivial modification, not to mention headaches of getting the configuration set up to even build… but once I found the right program, it turned into a breeze, and I didn’t have to edit any code at all.

Setting up test catch all mail server was as simple as described on their website:

  • Download and extract the latest release.
  • Open the mail.bat file and edit the JES_HOME variable to match the directory you installed the catch all server at.
  • Run mail.bat
  • All mail without a mailbox setup will be delivered to: The password for this mailbox is test.

By default it uses a flat-file store for the emails, so I just had to locate the /users/ folder and create a new text file with the same extension as the other files (.loc) which contains a single raw email I want on my mail server. I set poptrayu to download from localhost with the login, and it worked flawlessly.

Now I will be well on my way to creating a more comprehensive suite of test-cases and solving bigger more-important problems, like code-page encoding conversions causing an integer parse error.

Show Modal in Delphi

I was looking today at whether I could fix that annoying bug where a modal error message is shown, and if you switch to another application, when you switch back, the modal dialog gets “lost” behind the main window that’s now inactive, so you have to jump through alt-tab hoops to re-activate the window that you’re trying to acknowledge/close.

The first relevant post I came across on Stack Exchange basically said, newer versions of Delphi add some properties like setting the parent of a popup, to overcome this problem. If on the other hand you are using Delphi 7…

Again? Another problem that just upgrading Delphi would fix without a convoluted workaround? It’s not a trivial upgrade to make the app work on a newer version of Delphi, but I could be trading one bucket of problems for another….I just wish there was an edition of Delphi that wasn’t so expensive, or I probably would have already.