Author Topic: How to get a message in that pop-up status window  (Read 16450 times)

freymann

  • Douchebag
  • Guru
  • *
  • Posts: 380
    • View Profile
How to get a message in that pop-up status window
« on: October 21, 2008, 10:40:03 pm »
I'm working on a little idea of mine..

I usually watch LMCE with either my Notebook or iPod Touch nearby, and flip the device on about every 30 minutes to check for new emails. I was thinking... wouldn't it be nice to have something running on the core that can check my mail accounts and alert me when new messages come in?

Just a quick little status window in the top left corner of the screen with something like:

New Message From: <name>
Subject: <subject>

Something that pops up for a second or two then disappears.

I'm already tinkering with a simple PHP script and class and have it spitting out that information to my terminal window. The next step is to find a way to have LMCE display that on the screen.

Can that be done by writing to a log file or do I need to send a command to the dcerouter some how through PHP?

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: How to get a message in that pop-up status window
« Reply #1 on: October 22, 2008, 02:00:35 am »
Yes, you can use the MessageSend command to do this.

http://wiki.linuxmce.org/index.php/MessageSend

Basically, the format of the messagesend command would be something like:

Code: [Select]
/usr/pluto/bin/MessageSend localhost 0 -305 1 809 9 "Testing" 70 "" 182 "10" 251 ""

a quick breakdown:

localhost = the dcerouter
0 = the from device.. nonsensical in this case, so 0
-305 = a virtual device, stating all orbiters in the house
1 = the message type.. 1 = a command
809 = the message # (in this case, command #809 is Display Alert)
the rest are parameter hashes
9 = Text
182 = message timeout (how long it stays on screen)

That should give you enough to get started. And yes, before you ask, you can do it.. the trick is knowing what to send where.

-Thom

freymann

  • Douchebag
  • Guru
  • *
  • Posts: 380
    • View Profile
Re: How to get a message in that pop-up status window
« Reply #2 on: October 22, 2008, 03:15:09 am »
Yes, you can use the MessageSend command to do this.

http://wiki.linuxmce.org/index.php/MessageSend

Basically, the format of the messagesend command would be something like:

Code: [Select]
/usr/pluto/bin/MessageSend localhost 0 -305 1 809 9 "Testing" 70 "" 182 "10" 251 ""

 Oh that's a beauty!

 My test script is checking a couple of accounts and I'm receiving the little status window in the top left of the screen.

 When I tidy this up I'll make it available to all.

 Thanks!

freymann

  • Douchebag
  • Guru
  • *
  • Posts: 380
    • View Profile
Re: How to get a message in that pop-up status window
« Reply #3 on: October 22, 2008, 04:29:12 am »
So far tonight, if I'm at the main screen, the little pop up notices appear fine, but if I'm watching a video, I don't see the pop up.

If I'm watching TV through MythTV or watching a video, and the picture is taking up the screen, is it possible to get the pop up in this mode? I've been testing while viewing video on my Dell Notebook, which is a MD using UI1.

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: How to get a message in that pop-up status window
« Reply #4 on: October 22, 2008, 04:33:01 am »
yes, look up the parameters for the display alert command.

you can go into wizard > devices > orbiter... find an orbiter, any orbiter, select Advanced... then select Send Command to Device

select Display Alert, you'll then see the command parameters it can accept.

the rest is left as an exercise to the reader.

-Thom

freymann

  • Douchebag
  • Guru
  • *
  • Posts: 380
    • View Profile
Re: How to get a message in that pop-up status window
« Reply #5 on: October 22, 2008, 04:52:52 am »
yes, look up the parameters for the display alert command.

you can go into wizard > devices > orbiter... find an orbiter, any orbiter, select Advanced... then select Send Command to Device

select Display Alert, you'll then see the command parameters it can accept.

 Thanks Thom.

 When I did that, I got the same parameters that you gave me above and the message appears if I'm looking at UI1's menu screen but it doesn't appear while watching video playback (well, except that if I try a sample 'test' it uses a specific orbiter # instead of the generic 305 all orbiters device.

 I'll tinker some more, but if it won't pop up a notice while watching video then it defeats my idea.

 Interesting stuff though!

 

colinjones

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 3003
    • View Profile
Re: How to get a message in that pop-up status window
« Reply #6 on: October 22, 2008, 05:22:00 am »
Wouldn't it be the #251 interruption parameter? Looks like it defaults to blank or 0, perhaps try 1, 2, 3, 4, 8, 16 etc?

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: How to get a message in that pop-up status window
« Reply #7 on: October 22, 2008, 05:30:32 am »
hopefully, everyone is reading this....

web admin...

notice that when i told you to do a send command, and select display alert.. there was a command...

go to advanced > dce > commands

do a find on the page, for 809

it should be, display alert

you'll notice that it will show which devices use this command etc...

click on display alert.

you will see the parameters that this command can send... normally, the comments section would have a list of what each parameter can take.. in this case, it's not specified.. only that it's an integer for Interruption...

searching through the source code, we find a function, okayToInterrupt... we see a reference to several constants:

Code: [Select]
bool Orbiter::OkayToInterrupt( int iInterruption )
{
        if( iInterruption==interuptAlways )
                return true;

        if( m_dwPK_Device_NowPlaying )
                // If it's video it's always false.  If it's audio only, it's true only if there's no video
                return m_bContainsVideo ? false : iInterruption==interuptOnlyAudio;

        // Nothing is playing.  So unless it's interuptNever and there's an outside application we're ok
        if( (iInterruption==interuptNever || iInterruption==interuptOnlyAudio) && m_sActiveApplication_Window.empty()==false )
                return false;
        return true;
}

looking further, I do a grep inside src/

Code: [Select]
grep -rin "interuptOnlyAudio" *
Gen_Devices/AllScreens.h:37:            interuptOnlyAudio=3 /* will not interrupt a web browser, only when audio is playing */

ah, here we go.. a variable. odd.. not a constant... but at least we know now.. looking around that area, we see:

Code: [Select]
        enum eInterruption {interuptAlways=0, /* always interupt his activity and change screens */
                interuptNever=1, /* never interupt, only change the screen if the system is idle */
                interuptNoVideo=2, /* will interrupt a web browser but not a movie */
                interuptOnlyAudio=3 /* will not interrupt a web browser, only when audio is playing */
        };


So there you go. Four values that you can put into interruption, to trigger how the alert is displayed.

This concludes tonight's lesson on code forensics and analysis.

-Thom

colinjones

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 3003
    • View Profile
Re: How to get a message in that pop-up status window
« Reply #8 on: October 22, 2008, 06:16:05 am »
COOL! That explained a lot on how to find these things. DAMN! I wish the forums site had the ability to book mark threads and posts to come back to later - I've often wanted that for reference, now more than ever :)

hari

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 2428
    • View Profile
    • ago control
Re: How to get a message in that pop-up status window
« Reply #9 on: October 22, 2008, 09:37:54 am »
that's why we have a wiki :-p
rock your home - http://www.agocontrol.com home automation

colinjones

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 3003
    • View Profile
Re: How to get a message in that pop-up status window
« Reply #10 on: October 22, 2008, 01:36:49 pm »
whatever

freymann

  • Douchebag
  • Guru
  • *
  • Posts: 380
    • View Profile
Re: How to get a message in that pop-up status window
« Reply #11 on: October 22, 2008, 02:35:19 pm »
notice that when i told you to do a send command, and select display alert.. there was a command...

Awh, I missed that little bread crumb... the "interrupt" command you are speaking about...


Quote
Code: [Select]
        enum eInterruption {interuptAlways=0, /* always interupt his activity and change screens */
                interuptNever=1, /* never interupt, only change the screen if the system is idle */
                interuptNoVideo=2, /* will interrupt a web browser but not a movie */
                interuptOnlyAudio=3 /* will not interrupt a web browser, only when audio is playing */
        };


So there you go. Four values that you can put into interruption, to trigger how the alert is displayed.

 Thanks Thom. This information is great!

 I take this to mean the interrupt value can be 0, 1, 2, or 3. Is that correct?

 Otherwise I'm not sure how you would include interuptAlways=0 on the MessageSend command line.

 No matter what number I use it never displays the pop up notice while I'm watching a video on my MD. I will take the notebook to the core and the living-room and send a command to the orbiter on those machines directly from the web-admin to see if they react differently.


totallymaxed

  • LinuxMCE God
  • ****
  • Posts: 4660
  • Smart Home Consulting
    • View Profile
    • Dianemo - at home with technology
Re: How to get a message in that pop-up status window
« Reply #12 on: October 22, 2008, 06:50:09 pm »
ah, here we go.. a variable. odd.. not a constant... but at least we know now.. looking around that area, we see:

Code: [Select]
        enum eInterruption {interuptAlways=0, /* always interupt his activity and change screens */
                interuptNever=1, /* never interupt, only change the screen if the system is idle */
                interuptNoVideo=2, /* will interrupt a web browser but not a movie */
                interuptOnlyAudio=3 /* will not interrupt a web browser, only when audio is playing */
        };


So there you go. Four values that you can put into interruption, to trigger how the alert is displayed.

This concludes tonight's lesson on code forensics and analysis.

-Thom

How does the above interact with the 'Alert Filter Level' field in the Device Data? This field accepts the values 'all' , 'none' or 'important'

Andrew
Andy Herron,
CHT Ltd

For Dianemo/LinuxMCE consulting advice;
@herron on Twitter, totallymaxed+inquiries@gmail.com via email or PM me here.

Get Dianemo-Rpi2 ARM Licenses http://forum.linuxmce.org/index.php?topic=14026.0

Get RaspSqueeze-CEC or Raspbmc-CEC for Dianemo/LinuxMCE: http://wp.me/P4KgIc-5P

Facebook: https://www.facebook.com/pages/Dianemo-Home-Automation/226019387454465

http://www.dianemo.co.uk

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: How to get a message in that pop-up status window
« Reply #13 on: October 22, 2008, 06:52:35 pm »
I will have to look at the code to be sure, BUT, I believe the Alert Filter Level is processed before the Interruption value is used.

-Thom

freymann

  • Douchebag
  • Guru
  • *
  • Posts: 380
    • View Profile
Re: How to get a message in that pop-up status window
« Reply #14 on: October 22, 2008, 06:55:00 pm »
I just had the program running and was watching a video on the living-room MD which uses UI2 and the pop ups appear fine on that set. The pop ups don't appear (when watching video) on my notebook MD which uses UI1.

That's not an issue for me, as I wanted to be aware of new emails when at the living-room or basement stations, so onwards and upwards.