GSOC Project TSE Week 10

by SR13 | August 12, 2017

Hi, everyone! 0/

Tick-Tock is coming to an end, and the next week is perhaps the last week of coding before final evaluation starts! ;P But let's be calm and discuss what happened last week. And as promised, I managed to get some demonstrable snaps this time. So, here we go!


As told in my last blog, we got some flashy new icons for the stobject modules I worked on. The above pic shows the battery in charging mode. (Notice that the tiny lightning is replaced with hot 'plug' ;P) Last time I also told that I was working on auto showing/hiding the safely removable device icon. Though I am still using the experimental enumeration function, the test results look good. I tested on win XP virtual machine with my USB pen drive.

Basically, Shell_NotifyIcon() is used to handle all the icon notification features. But as I had told earlier, the stobject and its csystray was already implemented and it provided its own NotifyIcon() function for handling this things. (of-course using Shell_NotifyIcon() internally. ;P) But it didn't provide the necessary interface (parameters) to handle icon hiding. One solution was to actually ADD and DELETE the icon and simulate the hiding. But it felt inefficient and since hiding was supported by the API, it felt superfluous too. So what I did was, I just added a default parameter to existing csystray:: NotifyIcon() and added some code for handling the hiding state. Thus it not only added the hiding capability to that function but also maintained the compatibility with other modules which were using that function. And thanks to devs they also showed the green light to change and adapt the existing code. :)

But when the icon should be hidden? As you must have guessed, when no safely removable device is attached the icon remains hidden and it pops whenever one or more such devices are plugged in. For that, it maintains a list of the devices attached using an ATL:: CSimpleArray. That list is also used to populate the context-menu of the icon, showing the attached devices. And then comes the obvious feature, without which this module is useless! That important feature is ejection of the device. For that, I use CM_Request_Device_Eject_Ex() on the device clicked by the user from the list.

Okay, enough chit-chat today, lets straight away see the demonstration via pics:

  1. When you plug in the device (USB Pendrive in this case), the 'Safely Remove Hardware and Eject Media' icon will popup! w10.2
  2. When you click on the icon, a context-menu with a list of safely removable devices will be shown: w10.4
  3. If the device is under use (some program is open from the device) then it would warn you with a dialog! w10.3
  4. If the device is ejected successfully, it would inform you of the same with the cute notification balloon! (Actually, this pic is a spoiler in disguise ;P) w10.5
  5. When no more devices are available for safe removal, the icon goes to play hide and seek! w10.6

So that's the crust of how a 'Safely Remove Device' module should work. But still, some hacks and fixes are required besides the enumeration problem which is the core of this entire module. Another thing which I forgot to mention was that I fixed a bug which didn't pop the icon after restarting, even when a device was plugged in before the restart. (like when you kill and restart explorer!)

That's all for the week, but you might have been wondering that I didn't explain much about the balloon! And that my friends, is for the next time!

Stay tuned, and be awesome! ;)

#Some Important links to fast track:
  1. List of Milestones and plan
  2. Present history of commits
  3. Code Repository: Phase 3