aMSN Forums
May 20, 2018, 08:54:56 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: New forum for aMSN !!
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: DBusStateChanger 0.95 - Change your state automatically!  (Read 17581 times)
deadvirus
Newbie

Offline Offline

Posts: 26


View Profile
« on: November 17, 2009, 12:51:00 am »

Hello,

The main purpose of this plugin is to change aMSN to away when screensaver starts, and back to previous state when it ends. For example when you lock your screen aMSN will change to Away, and when you unlock it will restore previous state.

DBusStateChanger is a plugin that allows you aMSN to change your state to Away when some (defined) D-Bus signal is received, and back to the previous state when some other (defined) signal is received.

It only works on a system with D-Bus.
You may need to change its configuration in order for it to works. It's pre-configured to work with Ubuntu 9.10 Screensaver start/stop.
The most easy way to find the correct signals to configure it is to run $dbus-monitor and check the signal you want to use.

If you need any help or have any suggestion/request, just post here Smiley

DOWNLOAD [v.0.95 - 2009-12-03]:
http://www.filefactory.com/file/a1f784f/n/DBusStateChanger.zip
Logged
kakaroto
Administrator
Super Power User
*****
Offline Offline

Posts: 9428


View Profile WWW
« Reply #1 on: November 17, 2009, 07:44:48 pm »

awesome stuff! we'll upload it to the website soon! Thanks for sharing!
Logged

KaKaRoTo
billiob
Administrator
Super Power User
*****
Offline Offline

Posts: 1352


View Profile
« Reply #2 on: November 17, 2009, 09:11:26 pm »

Can you send me the file by email (my nick at gmail dot com) since rapidshare sucks hard ?
Logged
deadvirus
Newbie

Offline Offline

Posts: 26


View Profile
« Reply #3 on: November 17, 2009, 11:01:01 pm »

Quote from: "kakaroto"
awesome stuff! we'll upload it to the website soon! Thanks for sharing!


Thanks Cheesy
I'm glad to help!


Quote from: "billiob"
Can you send me the file by email (my nick at gmail dot com) since rapidshare sucks hard ?


I've upload the file to some more hosts (check the first post), can you download from one of them?
Logged
kakaroto
Administrator
Super Power User
*****
Offline Offline

Posts: 9428


View Profile WWW
« Reply #4 on: November 17, 2009, 11:45:05 pm »

hehe, would have been eaiser to just email it to him and he would have uploaded it to SVN and released it in the website so it would have been easier for everyone to get it! Smiley
anyways, I've taken a quick look at the code, and I've got some small issues with it, not much, it's still very nice for someone's first take into Tcl Smiley
You don't need to fix them, I'll fix them myself later if I get time since it's all minor.. but let me list them for you so you would learn from your mistakes Smiley
1 - the description of the plugin says it switches back when another signal is received, actually, it's for the same signal, just a different 'value'
2 - your Init opens dbus-monitor, but it shouldn't because you set your config values in the Init, so you will always ignore the user's settings.. aMSN also will call your Init with no config values, then after the Init is called, it will set the config array of your plugin's namespace correctly.. you should register for the 'Load' plugin event (and make sure the plugin that got loaded was yours) to get notified when your config is available for you to use.
3 - you should also listen to the PluginConfigured event in case a user changes the config, so you'd close the dbus-monitor channel and reopen it with the new config.
4 - when you do the open, you should catch it to make sure it works, in case someone tries to run it without having dbus-monitor (or on windows/mac where it's not available). and unload the plugin if it's not possible to run dbus-monitor (after showing a pop up window warning)
5 - The previous status should be saved in a namespace variable, not a config, it doesn't need to be saved to disk when you exit amsn, right ?
6 - the previous status should be set in the Init, imagine someone has amsn launch and locks the screen before it finishes launching.. then he unlocks, what status should be put there? you only set the prevState when you get 'locked', so you should instead initialize it properly in the Init
7 - You check the status with HDN, it's wrong, HDN is 'Hidden', which is 'appear offline', you should also check for FLN (offline) in case someone has the plugin loaded but is not connected at all.
8 - You never check the 'eof' of the channel if you're hidden, what if dbus-monitor crashed, the channel gets an error/eof and the readable callback gets called forever, you do 'gets' but never check eof in order to close the channel.
9 - actually, if [eof] is true, you should close the channel, not just ignore it, otherwise, you get an infinite loop.
10 - why do you 'concat' your value ? and have that extra '$' at the end? doesn't it cause an error since '$' is for variable dereferencing? you should do 'set regAway "${dbus_away_signal}\$"'

everything else seems good Smiley

If you have free time and you wish to fix it, then feel free to do it, I don't know when i'll get enough free time to do it. otherwise, leave it to me Smiley
Thanks again, good job!
Logged

KaKaRoTo
deadvirus
Newbie

Offline Offline

Posts: 26


View Profile
« Reply #5 on: November 18, 2009, 12:10:04 am »

Quote from: "kakaroto"
hehe, would have been eaiser to just email it to him and he would have uploaded it to SVN and released it in the website so it would have been easier for everyone to get it! Smiley
anyways, I've taken a quick look at the code, and I've got some small issues with it, not much, it's still very nice for someone's first take into Tcl Smiley
You don't need to fix them, I'll fix them myself later if I get time since it's all minor.. but let me list them for you so you would learn from your mistakes Smiley
1 - the description of the plugin says it switches back when another signal is received, actually, it's for the same signal, just a different 'value'
2 - your Init opens dbus-monitor, but it shouldn't because you set your config values in the Init, so you will always ignore the user's settings.. aMSN also will call your Init with no config values, then after the Init is called, it will set the config array of your plugin's namespace correctly.. you should register for the 'Load' plugin event (and make sure the plugin that got loaded was yours) to get notified when your config is available for you to use.
3 - you should also listen to the PluginConfigured event in case a user changes the config, so you'd close the dbus-monitor channel and reopen it with the new config.
4 - when you do the open, you should catch it to make sure it works, in case someone tries to run it without having dbus-monitor (or on windows/mac where it's not available). and unload the plugin if it's not possible to run dbus-monitor (after showing a pop up window warning)
5 - The previous status should be saved in a namespace variable, not a config, it doesn't need to be saved to disk when you exit amsn, right ?
6 - the previous status should be set in the Init, imagine someone has amsn launch and locks the screen before it finishes launching.. then he unlocks, what status should be put there? you only set the prevState when you get 'locked', so you should instead initialize it properly in the Init
7 - You check the status with HDN, it's wrong, HDN is 'Hidden', which is 'appear offline', you should also check for FLN (offline) in case someone has the plugin loaded but is not connected at all.
8 - You never check the 'eof' of the channel if you're hidden, what if dbus-monitor crashed, the channel gets an error/eof and the readable callback gets called forever, you do 'gets' but never check eof in order to close the channel.
9 - actually, if [eof] is true, you should close the channel, not just ignore it, otherwise, you get an infinite loop.
10 - why do you 'concat' your value ? and have that extra '$' at the end? doesn't it cause an error since '$' is for variable dereferencing? you should do 'set regAway "${dbus_away_signal}\$"'

everything else seems good Smiley

If you have free time and you wish to fix it, then feel free to do it, I don't know when i'll get enough free time to do it. otherwise, leave it to me Smiley
Thanks again, good job!


Oh sorry, I thought that uploading it to different hosts will be better xD (stupid me).

Thanks for looking into the code! Cheesy
I'll try to find some time to correct at least some of the problems. I'll let you know if I do so.
Logged
deadvirus
Newbie

Offline Offline

Posts: 26


View Profile
« Reply #6 on: November 26, 2009, 06:23:44 pm »

I've solved the problems kakaroto pointed out. Should I mail it to billiob?
By the way, should I add the "cvs" thing to the info.xml file? Or you guys take care of that?

EDIT: I've uploaded it to INeedUp (link in first post)
Logged
billiob
Administrator
Super Power User
*****
Offline Offline

Posts: 1352


View Profile
« Reply #7 on: November 28, 2009, 02:58:58 pm »

You should only modify the files from the svn. This means you should not remove those "cvs" things.
I've updated the svn.
Logged
deadvirus
Newbie

Offline Offline

Posts: 26


View Profile
« Reply #8 on: November 28, 2009, 03:53:25 pm »

Quote from: "billiob"
You should only modify the files from the svn. This means you should not remove those "cvs" things.
I've updated the svn.

Can you explain how should I update the plugin latter?
Logged
billiob
Administrator
Super Power User
*****
Offline Offline

Posts: 1352


View Profile
« Reply #9 on: November 28, 2009, 04:02:14 pm »

don't remove lines and don't touch lines below cvs_version (and included)
Logged
deadvirus
Newbie

Offline Offline

Posts: 26


View Profile
« Reply #10 on: November 28, 2009, 04:03:14 pm »

Quote from: "billiob"
don't remove lines and don't touch lines below cvs_version (and included)

I know that. But how can I update SVN? Or should I just post it here?
Logged
billiob
Administrator
Super Power User
*****
Offline Offline

Posts: 1352


View Profile
« Reply #11 on: November 28, 2009, 04:03:48 pm »

post here
Logged
deadvirus
Newbie

Offline Offline

Posts: 26


View Profile
« Reply #12 on: December 03, 2009, 01:45:44 am »

Version 0.95 changes:
-Fixed bug that will pop up A LOT of windows showing an error message when DBus-monitor closes unexpectedly.
-Fixed bug that would not stop the dbus-monitor process when the plugin is unloaded. (this could lead to have a lot of dbus-monitor processes running if someone stopped and started the plugin many times).
Logged
kakaroto
Administrator
Super Power User
*****
Offline Offline

Posts: 9428


View Profile WWW
« Reply #13 on: December 03, 2009, 07:16:10 am »

cool,
by the way, from my 10 points above, which ones did you get time to fix?
Sorry by the way, I got too busy lately and couldn't do a thing.
Logged

KaKaRoTo
deadvirus
Newbie

Offline Offline

Posts: 26


View Profile
« Reply #14 on: December 03, 2009, 01:16:07 pm »

Quote from: "kakaroto"
cool,
by the way, from my 10 points above, which ones did you get time to fix?
Sorry by the way, I got too busy lately and couldn't do a thing.


I think I have fixed all of them! Smiley

Thanks.
Logged
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!