[sip-comm-dev] GSoC Progress Report : Storing chat history in a DataBase (rather than a text file)


#1

Hi all

I have completed the implementation of the History Service using the
Database Service developed by me.

The implementation is able to pass all the unit tests associated with
the history service as well those associated with call history and
message history services with a minor modification of introducing a
small time delay(~2 milliseconds) between insertion of two records to
ensure that the time and date based functions can be tested correctly
(since the precision is 1 ms).

The prominent features of the implementation are:

1. There is no change at all in the interface so that the other
services (CallHistory and MsgHistory) can work as expected.

2. The individual records are not allowed to override the
HistoryRecordStructure of the history leading to a cleaner and faster
implementation .

3. Records are inserted and searched using precompiled SQL preventing
SQL injection.This also results in a big performance boost in
appending records to a history.

4. There is a large increase in performance compared to the previous
implementation ,especially in time taken for appending records to a
history, as desired.

I shall now begin with working on providing DB configuration options
in the config form.

Regards

Ajay

···

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#2

Hi all,

This is my first progress report on my project.

I have spent last week learning JNI and Growl Cocoa API. Then I developed a simple proof-of-concept test application that sends notification messages to Growl and gets an indication when user clicks on them.

Now I need to come up with OSGi service that acts as an interface between SC and Growl. Here are my thoughts and questions:

First of all, I am a bit unsure why we need OSGi service, that is used only as an API to Growl. Wouldn't it be enough to add this functionality to GrowlNotificationServiceImpl?

Secondly, I am struggling to decide what to use as a clickContext in the OSGi service. Growl distinguishes messages by using clickContext object, which must be a dictionary, array, string, data, or number object. Then if the message is clicked, Growl daemon calls back a growlNotificationWasClicked method and passes clickContext as an argument. If it was not clicked, it calls back growlNotificationTimedOut method and passes clickContext as an argument.

A logical candidate would be to use the tag object from PopupMessage, but I am not really sure what kind of object it is and that it is always set. Using some king of number or string would be much easier. In my opinion, some kind of timestamp would suit the task best. Then the GrowlNotificationServiceImpl could maintain pairs of timestamps and associated PopupMessages. If the user ignores the notification, the growlNotificationTimedOut will remove the related <timestamp,

pair. And if the user clicks the notification,

GrowlNotificationServiceImpl will get back a timestamp corresponding to PopupMessage that was clicked.

Now comes the part that I am confused about: How to show the chat window that is related to the popup message?

Currently, apart from GrowlNotificationServiceImpl there are 2 other classes that implement PopupMessageHandler interface - PopupMessageHandlerTrayIconImpl and PopupMessageHandlerSwingImpl. Following the code of these two classes, I assume that GrowlNotificationServiceImpl should do the same - construct and fire a SystrayPopupMessageEvent object, which will be used by some listener to bring the appropriate chat window to front.

Or maybe the GrowlNotificationServiceImpl should deal with showing chat windows itself? It looks like UI Service is designed for this task. There is an example in documentation how to obtain a chat window having a Contact object. Is it the case that tags in PopupMessage objects are Contacts? Or maybe the component variable in PopupMessage is all I need to show the chat window? I am really unsure what these two variables of PopupMessage are used for.

Thanks in advance for your comments,
Egidijus


#3

Am attaching here the code for my implementation

HistoryServiceImpl.zip (59.7 KB)

···

On Tue, Jun 9, 2009 at 11:45 PM, AJAY CHHATWAL<ajay.chhatwal.cse07@itbhu.ac.in> wrote:

Hi all

I have completed the implementation of the History Service using the
Database Service developed by me.

The implementation is able to pass all the unit tests associated with
the history service as well those associated with call history and
message history services with a minor modification of introducing a
small time delay(~2 milliseconds) between insertion of two records to
ensure that the time and date based functions can be tested correctly
(since the precision is 1 ms).

The prominent features of the implementation are:

1. There is no change at all in the interface so that the other
services (CallHistory and MsgHistory) can work as expected.

2. The individual records are not allowed to override the
HistoryRecordStructure of the history leading to a cleaner and faster
implementation .

3. Records are inserted and searched using precompiled SQL preventing
SQL injection.This also results in a big performance boost in
appending records to a history.

4. There is a large increase in performance compared to the previous
implementation ,especially in time taken for appending records to a
history, as desired.

I shall now begin with working on providing DB configuration options
in the config form.

Regards

Ajay


#4

Hey Ajay,

AJAY CHHATWAL wrote:

Hi all

I have completed the implementation of the History Service using the
Database Service developed by me.

Excellent! Would you like to have a branch so that you'd be able to commit?

The implementation is able to pass all the unit tests associated with
the history service as well those associated with call history and
message history services with a minor modification of introducing a
small time delay(~2 milliseconds) between insertion of two records to
ensure that the time and date based functions can be tested correctly
(since the precision is 1 ms).

Can you explain this a bit further. Is the modification in the tests or
the call history implementation? Why exactly is it necessary?

The prominent features of the implementation are:

1. There is no change at all in the interface so that the other
services (CallHistory and MsgHistory) can work as expected.

Excellent!

2. The individual records are not allowed to override the
HistoryRecordStructure of the history leading to a cleaner and faster
implementation .

A few more details here would also be nice.

3. Records are inserted and searched using precompiled SQL preventing
SQL injection.This also results in a big performance boost in
appending records to a history.

4. There is a large increase in performance compared to the previous
implementation ,especially in time taken for appending records to a
history, as desired.

This is _very_ important since it would determine whether or not we
actually replace the existing implementation with the new one. Do you
think you'd be able to provide a more complete performance evaluation?
It may make sense to do the testing with a minimal, average, and a
clearly bloated history size.

You'd have to ask around for the average size (my msg history directory
is 19 MB) and assume that the maximum size would be around ten times that.

Also, it would be important to have procedures in place that allow
migrating all history records from an XML based service to the new one.
  I realize this is not in your requirements list but it's very
important. Definitely more so than the config options.

I shall now begin with working on providing DB configuration options
in the config form.

This is a second term item so kudos for getting there so quickly! :slight_smile:

Good job, Ajay!

Cheers
Emil

···

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#5

Hello Egidijus,

Glad to hear from you!

Egidijus Jankauskas wrote:

Hi all,

This is my first progress report on my project.

I have spent last week learning JNI and Growl Cocoa API. Then I
developed a simple proof-of-concept test application that sends
notification messages to Growl and gets an indication when user clicks
on them.

Now I need to come up with OSGi service that acts as an interface
between SC and Growl. Here are my thoughts and questions:

First of all, I am a bit unsure why we need OSGi service, that is used
only as an API to Growl. Wouldn't it be enough to add this functionality
to /GrowlNotificationServiceImpl/?

Yes, indeed, you could do this.

Secondly, I am struggling to decide what to use as a /clickContext/ in
the OSGi service. Growl distinguishes messages by
using /clickContext/ object, which must be a dictionary, array, string,
data, or number object. Then if the message is clicked, Growl daemon
calls back a /growlNotificationWasClicked/ method and
passes /clickContext/ as an argument. If it was not clicked, it calls
back /growlNotificationTimedOut/ method and passes /clickContext/ as an
argument.

A logical candidate would be to use the /tag/ object
from /PopupMessage/, but I am not really sure what kind of object it is
and that it is always set.

Yes indeed. We use tags for pretty much the same purpose that growl use
the click context.

Using some king of number or string would be
much easier. In my opinion, some kind of timestamp would suit the task
best.

Right. You can use the current time millis and convert them to a String
or a Long. You could easily use this as a key for a Map and bind the tag
to it.

Then the GrowlNotificationServiceImpl could maintain pairs of
timestamps and associated /PopupMessages/. If the user ignores the
notification, the growlNotificationTimedOut will remove the related
<timestamp, PopupMessage> pair.

This is very important so I am glad you haven't missed it. Once you are
done with the implementation please make sure that after using SC for a
while, within different click/ignore/close scenarios of the Growl
popups, your clickcontext2tag map is still empty.

And if the user clicks the
notification, GrowlNotificationServiceImpl will get back a timestamp
corresponding to /PopupMessage /that was clicked.

Sounds like a plan.

Now comes the part that I am confused about: How to show the chat window
that is related to the popup message?

Currently, apart from /GrowlNotificationServiceImpl/ there are 2 other
classes that implement /PopupMessageHandler/ interface
- PopupMessageHandlerTrayIconImpl and PopupMessageHandlerSwingImpl. Following
the code of these two classes, I assume
that GrowlNotificationServiceImpl should do the same - construct and
fire a SystrayPopupMessageEvent object, which will be used by some
listener to bring the appropriate chat window to front.

Yes, exactly!

Or maybe the GrowlNotificationServiceImpl should deal with showing chat
windows itself? It looks like UI Service is designed for this task.
There is an example in documentation how to obtain a chat window having
a /Contact/ object. Is it the case
that /tags/ in /PopupMessage /objects are /Contacts/? Or maybe
the /component/ variable in /PopupMessage /is all I need to show the
chat window? I am really unsure what these two variables
of /PopupMessage/ are used for.

Simply mimic what the swing implementation does. The notification
service (which calls the popup message handlers) takes care of showing
message windows so you don't need to do this yourself.

Hope this helps
Emil

···

Thanks in advance for your comments,
Egidijus

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#6

Hi Emil,

Hey Ajay,

AJAY CHHATWAL wrote:

Hi all

I have completed the implementation of the History Service using the
Database Service developed by me.

Excellent! Would you like to have a branch so that you'd be able to commit?

I have asked for a branch in another thread.

The implementation is able to pass all the unit tests associated with
the history service as well those associated with call history and
message history services with a minor modification of introducing a
small time delay(~2 milliseconds) between insertion of two records to
ensure that the time and date based functions can be tested correctly
(since the precision is 1 ms).

Can you explain this a bit further. Is the modification in the tests or
the call history implementation? Why exactly is it necessary?

The modification is in the tests. Actually,the previous implementation
was a bit slow so there was no chance that two or more records were
never added within 1 millisecond of each other (and therefore have the
same timestamp ) which is quite possible in case of the database
implementation. Therefore the tests need to be changed accordingly to
ensure that the time and date based functions can be tested correctly.

The prominent features of the implementation are:

1. There is no change at all in the interface so that the other
services (CallHistory and MsgHistory) can work as expected.

Excellent!

2. The individual records are not allowed to override the
HistoryRecordStructure of the history leading to a cleaner and faster
implementation .

A few more details here would also be nice.

According to the documentation of the History Service, individual
history records in their structure. However, this is never used and
,as far as I understand, not implemented even in the previous XML
implementation.You may refer to my previous post on this topic on the
dev list for details on this.

3. Records are inserted and searched using precompiled SQL preventing
SQL injection.This also results in a big performance boost in
appending records to a history.

4. There is a large increase in performance compared to the previous
implementation ,especially in time taken for appending records to a
history, as desired.

This is _very_ important since it would determine whether or not we
actually replace the existing implementation with the new one. Do you
think you'd be able to provide a more complete performance evaluation?
It may make sense to do the testing with a minimal, average, and a
clearly bloated history size.

You'd have to ask around for the average size (my msg history directory
is 19 MB) and assume that the maximum size would be around ten times that.

I would try to provide a more complete comparison soon as it is also
on my requirement llist.

Also, it would be important to have procedures in place that allow
migrating all history records from an XML based service to the new one.
I realize this is not in your requirements list but it's very
important. Definitely more so than the config options.

I shall try to figure out a way to do that.

I shall now begin with working on providing DB configuration options
in the config form.

This is a second term item so kudos for getting there so quickly! :slight_smile:

Good job, Ajay!

Thanks

Cheers
Emil

Regards

Ajay

···

On Sat, Jun 13, 2009 at 6:13 PM, Emil Ivov<emcho@sip-communicator.org> wrote:

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#7

Hi Emil, Egidijus,

Sorry for the late reply, I've been busy lately but now I should be able to follow this work more closely! I think Emil answered most of your questions (thanks Emil!), so I only have one remaining comment:

Egidijus Jankauskas wrote:

I have spent last week learning JNI and Growl Cocoa API. Then I
developed a simple proof-of-concept test application that sends
notification messages to Growl and gets an indication when user clicks
on them.

Egidijus gave me the opportunity to test this application, and it sounded promising for the project. That's a good starting point!

Now I need to come up with OSGi service that acts as an interface
between SC and Growl. Here are my thoughts and questions:

First of all, I am a bit unsure why we need OSGi service, that is used
only as an API to Growl. Wouldn't it be enough to add this functionality
to /GrowlNotificationServiceImpl/?

Yes, indeed, you could do this.

My initial idea was to provide a more general library that would include the JNI plus a Java API. The goal would be that other people who develop Java application could use it in order to bypass the java bindings currently offered by Growl. But I don't know to what extent it is possible to make this generic, nor if this is really useful as the needs may vary from one application to another. Any thoughts on this subject?

By the way Egidijus, would you like a branch for your project? I think you will not have much conflict problems, so this could be a good way to backup your code and share it with me.

Cheers,
romain

···

On 2009/06/10, at 22:56, Emil Ivov wrote:

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#8

Hi all,

I have one question to more experienced SC developers:

How to bring a Chat window to front? By saying "to front" I mean in front of all applications?

Currently, SystrayPopupMessageListenerImpl invokes setChatVisible() method on Chat object to bring it to front. It works perfectly fine if Swing notifications are used. Because a user clicks on Swing notification that is one of SC windows, SC becomes the "currently focused application" and brings Chat window to front. However, when Growl notifications are used, user clicks on a notification, that is not one of SC windows. As a result of that, setChatVisible() method brings the Chat window in front of all windows that do not belong to currently focused application. So if I am using for example Safari and click on Growl notification, Chat window pops in front of all background applications, but does not "steal" the focus from Safari and stays behind it.

What would be the best way to overcome this?

Cheers,
Egidijus

···

On 10 Jun 2009, at 21:56, Emil Ivov wrote:

Currently, apart from /GrowlNotificationServiceImpl/ there are 2 other
classes that implement /PopupMessageHandler/ interface
- PopupMessageHandlerTrayIconImpl and PopupMessageHandlerSwingImpl. Following
the code of these two classes, I assume
that GrowlNotificationServiceImpl should do the same - construct and
fire a SystrayPopupMessageEvent object, which will be used by some
listener to bring the appropriate chat window to front.

Yes, exactly!

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#9

Hi Egidijus,

I remember that such focus issues have already been discussed here, but I can't find the thread in my archives. Your case however seems a bit different, because the original click is not performed on one of the SC window, but on a Growl popup. Can be handled by the JNI? Maybe the growl API has some functions that take cares of focusing on the application whose popup is intended?

Cheers,
romain

···

On 2009/06/18, at 21:16, Egidijus Jankauskas wrote:

Hi all,

I have one question to more experienced SC developers:

How to bring a Chat window to front? By saying "to front" I mean in front of all applications?

Currently, SystrayPopupMessageListenerImpl invokes setChatVisible() method on Chat object to bring it to front. It works perfectly fine if Swing notifications are used. Because a user clicks on Swing notification that is one of SC windows, SC becomes the "currently focused application" and brings Chat window to front. However, when Growl notifications are used, user clicks on a notification, that is not one of SC windows. As a result of that, setChatVisible() method brings the Chat window in front of all windows that do not belong to currently focused application. So if I am using for example Safari and click on Growl notification, Chat window pops in front of all background applications, but does not "steal" the focus from Safari and stays behind it.

What would be the best way to overcome this?

Cheers,
Egidijus

On 10 Jun 2009, at 21:56, Emil Ivov wrote:

Currently, apart from /GrowlNotificationServiceImpl/ there are 2 other
classes that implement /PopupMessageHandler/ interface
- PopupMessageHandlerTrayIconImpl and PopupMessageHandlerSwingImpl. Following
the code of these two classes, I assume
that GrowlNotificationServiceImpl should do the same - construct and
fire a SystrayPopupMessageEvent object, which will be used by some
listener to bring the appropriate chat window to front.

Yes, exactly!

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#10

I guess the task to be accomplished is to activate the application
(before or after setChatVisible). Should that be the case, then I
suppose NSWorkspace activateApplication will suffice if you've
collected the necessary NSDictionary data while you were still running
in the application using NSProcessInfo and maybe NSBundle.

···

2009/6/18 Egidijus Jankauskas <egidijus.jankauskas@email.lt>:

Hi all,

I have one question to more experienced SC developers:

How to bring a Chat window to front? By saying "to front" I mean in front of
all applications?

Currently, SystrayPopupMessageListenerImpl invokes setChatVisible() method
on Chat object to bring it to front. It works perfectly fine if Swing
notifications are used. Because a user clicks on Swing notification that is
one of SC windows, SC becomes the "currently focused application" and
brings Chat window to front. However, when Growl notifications are used,
user clicks on a notification, that is not one of SC windows. As a result of
that, setChatVisible() method brings the Chat window in front of all windows
that do not belong to currently focused application. So if I am using for
example Safari and click on Growl notification, Chat window pops in front of
all background applications, but does not "steal" the focus from Safari and
stays behind it.

What would be the best way to overcome this?

Cheers,
Egidijus

On 10 Jun 2009, at 21:56, Emil Ivov wrote:

Currently, apart from /GrowlNotificationServiceImpl/ there are 2 other
classes that implement /PopupMessageHandler/ interface
- PopupMessageHandlerTrayIconImpl and PopupMessageHandlerSwingImpl.
Following
the code of these two classes, I assume
that GrowlNotificationServiceImpl should do the same - construct and
fire a SystrayPopupMessageEvent object, which will be used by some
listener to bring the appropriate chat window to front.

Yes, exactly!

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#11

Hi Lubomir,

Thanks for your answer. There is no method "activateApplication" in NSWorkspace, but I will try to find a way to do the same.

Egidijus

···

On 23 Jun 2009, at 11:27, Lubomir Marinov wrote:

I guess the task to be accomplished is to activate the application
(before or after setChatVisible). Should that be the case, then I
suppose NSWorkspace activateApplication will suffice if you've
collected the necessary NSDictionary data while you were still running
in the application using NSProcessInfo and maybe NSBundle.

2009/6/18 Egidijus Jankauskas <egidijus.jankauskas@email.lt>:

Hi all,

I have one question to more experienced SC developers:

How to bring a Chat window to front? By saying "to front" I mean in front of
all applications?

Currently, SystrayPopupMessageListenerImpl invokes setChatVisible() method
on Chat object to bring it to front. It works perfectly fine if Swing
notifications are used. Because a user clicks on Swing notification that is
one of SC windows, SC becomes the "currently focused application" and
brings Chat window to front. However, when Growl notifications are used,
user clicks on a notification, that is not one of SC windows. As a result of
that, setChatVisible() method brings the Chat window in front of all windows
that do not belong to currently focused application. So if I am using for
example Safari and click on Growl notification, Chat window pops in front of
all background applications, but does not "steal" the focus from Safari and
stays behind it.

What would be the best way to overcome this?

Cheers,
Egidijus

On 10 Jun 2009, at 21:56, Emil Ivov wrote:

Currently, apart from /GrowlNotificationServiceImpl/ there are 2 other
classes that implement /PopupMessageHandler/ interface
- PopupMessageHandlerTrayIconImpl and PopupMessageHandlerSwingImpl.
Following
the code of these two classes, I assume
that GrowlNotificationServiceImpl should do the same - construct and
fire a SystrayPopupMessageEvent object, which will be used by some
listener to bring the appropriate chat window to front.

Yes, exactly!

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#12

Hi Romain,

Growl API does not have any functions that would help me in this situation. If user clicks on notification, it only calls growlNotificationWasClicked method if it is present and it is up to a developer to provide an implementation for it. But I will have a look in Lubomir's suggestion.

Egidijus

···

On 23 Jun 2009, at 11:04, Romain KUNTZ wrote:

Hi Egidijus,

I remember that such focus issues have already been discussed here, but I can't find the thread in my archives. Your case however seems a bit different, because the original click is not performed on one of the SC window, but on a Growl popup. Can be handled by the JNI? Maybe the growl API has some functions that take cares of focusing on the application whose popup is intended?

Cheers,
romain

On 2009/06/18, at 21:16, Egidijus Jankauskas wrote:

Hi all,

I have one question to more experienced SC developers:

How to bring a Chat window to front? By saying "to front" I mean in front of all applications?

Currently, SystrayPopupMessageListenerImpl invokes setChatVisible() method on Chat object to bring it to front. It works perfectly fine if Swing notifications are used. Because a user clicks on Swing notification that is one of SC windows, SC becomes the "currently focused application" and brings Chat window to front. However, when Growl notifications are used, user clicks on a notification, that is not one of SC windows. As a result of that, setChatVisible() method brings the Chat window in front of all windows that do not belong to currently focused application. So if I am using for example Safari and click on Growl notification, Chat window pops in front of all background applications, but does not "steal" the focus from Safari and stays behind it.

What would be the best way to overcome this?

Cheers,
Egidijus

On 10 Jun 2009, at 21:56, Emil Ivov wrote:

Currently, apart from /GrowlNotificationServiceImpl/ there are 2 other
classes that implement /PopupMessageHandler/ interface
- PopupMessageHandlerTrayIconImpl and PopupMessageHandlerSwingImpl. Following
the code of these two classes, I assume
that GrowlNotificationServiceImpl should do the same - construct and
fire a SystrayPopupMessageEvent object, which will be used by some
listener to bring the appropriate chat window to front.

Yes, exactly!

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#13

I'm sorry for the mistake.

The other solution I've found on the Internet seems to be very popular
and states to deal with the fact the NSWorkspace launchApplication
does not necessarily active the application but I don't know how
practical it is for SIP Communicator - execute the AppleScript "tell
application X to activate".

Anyway, I sincerely wish you success!

···

2009/6/23 Egidijus Jankauskas <egidijus.jankauskas@email.lt>:

Hi Lubomir,

Thanks for your answer. There is no method "activateApplication" in
NSWorkspace, but I will try to find a way to do the same.

Egidijus

On 23 Jun 2009, at 11:27, Lubomir Marinov wrote:

I guess the task to be accomplished is to activate the application
(before or after setChatVisible). Should that be the case, then I
suppose NSWorkspace activateApplication will suffice if you've
collected the necessary NSDictionary data while you were still running
in the application using NSProcessInfo and maybe NSBundle.

2009/6/18 Egidijus Jankauskas <egidijus.jankauskas@email.lt>:

Hi all,

I have one question to more experienced SC developers:

How to bring a Chat window to front? By saying "to front" I mean in front
of
all applications?

Currently, SystrayPopupMessageListenerImpl invokes setChatVisible()
method
on Chat object to bring it to front. It works perfectly fine if Swing
notifications are used. Because a user clicks on Swing notification that
is
one of SC windows, SC becomes the "currently focused application" and
brings Chat window to front. However, when Growl notifications are used,
user clicks on a notification, that is not one of SC windows. As a result
of
that, setChatVisible() method brings the Chat window in front of all
windows
that do not belong to currently focused application. So if I am using for
example Safari and click on Growl notification, Chat window pops in front
of
all background applications, but does not "steal" the focus from Safari
and
stays behind it.

What would be the best way to overcome this?

Cheers,
Egidijus

On 10 Jun 2009, at 21:56, Emil Ivov wrote:

Currently, apart from /GrowlNotificationServiceImpl/ there are 2 other
classes that implement /PopupMessageHandler/ interface
- PopupMessageHandlerTrayIconImpl and PopupMessageHandlerSwingImpl.
Following
the code of these two classes, I assume
that GrowlNotificationServiceImpl should do the same - construct and
fire a SystrayPopupMessageEvent object, which will be used by some
listener to bring the appropriate chat window to front.

Yes, exactly!

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#14

I am trying that one with AppleScript right now. It brings up the window to front but without the focus, so not what I really want. But maybe there is a way to set focus as well. I will have a look.

···

On 23 Jun 2009, at 13:22, Lubomir Marinov wrote:

I'm sorry for the mistake.

The other solution I've found on the Internet seems to be very popular
and states to deal with the fact the NSWorkspace launchApplication
does not necessarily active the application but I don't know how
practical it is for SIP Communicator - execute the AppleScript "tell
application X to activate".

Anyway, I sincerely wish you success!

2009/6/23 Egidijus Jankauskas <egidijus.jankauskas@email.lt>:

Hi Lubomir,

Thanks for your answer. There is no method "activateApplication" in
NSWorkspace, but I will try to find a way to do the same.

Egidijus

On 23 Jun 2009, at 11:27, Lubomir Marinov wrote:

I guess the task to be accomplished is to activate the application
(before or after setChatVisible). Should that be the case, then I
suppose NSWorkspace activateApplication will suffice if you've
collected the necessary NSDictionary data while you were still running
in the application using NSProcessInfo and maybe NSBundle.

2009/6/18 Egidijus Jankauskas <egidijus.jankauskas@email.lt>:

Hi all,

I have one question to more experienced SC developers:

How to bring a Chat window to front? By saying "to front" I mean in front
of
all applications?

Currently, SystrayPopupMessageListenerImpl invokes setChatVisible()
method
on Chat object to bring it to front. It works perfectly fine if Swing
notifications are used. Because a user clicks on Swing notification that
is
one of SC windows, SC becomes the "currently focused application" and
brings Chat window to front. However, when Growl notifications are used,
user clicks on a notification, that is not one of SC windows. As a result
of
that, setChatVisible() method brings the Chat window in front of all
windows
that do not belong to currently focused application. So if I am using for
example Safari and click on Growl notification, Chat window pops in front
of
all background applications, but does not "steal" the focus from Safari
and
stays behind it.

What would be the best way to overcome this?

Cheers,
Egidijus

On 10 Jun 2009, at 21:56, Emil Ivov wrote:

Currently, apart from /GrowlNotificationServiceImpl/ there are 2 other
classes that implement /PopupMessageHandler/ interface
- PopupMessageHandlerTrayIconImpl and PopupMessageHandlerSwingImpl.
Following
the code of these two classes, I assume
that GrowlNotificationServiceImpl should do the same - construct and
fire a SystrayPopupMessageEvent object, which will be used by some
listener to bring the appropriate chat window to front.

Yes, exactly!

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#15

Are we actually calling toFront() on the chat window? I just had a look
at ChatPanel and ChatWindowManager and I am not sure we are always doing
it. You may want to make sure it doesn't help before we go down that
script path.

Oh you may want to also have a look at what Adium are doing since it
seems to be working properly in their case.

Cheers
Emil

Egidijus Jankauskas wrote:

···

I am trying that one with AppleScript right now. It brings up the
window to front but without the focus, so not what I really want. But
maybe there is a way to set focus as well. I will have a look.

On 23 Jun 2009, at 13:22, Lubomir Marinov wrote:

I'm sorry for the mistake.

The other solution I've found on the Internet seems to be very popular
and states to deal with the fact the NSWorkspace launchApplication
does not necessarily active the application but I don't know how
practical it is for SIP Communicator - execute the AppleScript "tell
application X to activate".

Anyway, I sincerely wish you success!

2009/6/23 Egidijus Jankauskas <egidijus.jankauskas@email.lt>:

Hi Lubomir,

Thanks for your answer. There is no method "activateApplication" in
NSWorkspace, but I will try to find a way to do the same.

Egidijus

On 23 Jun 2009, at 11:27, Lubomir Marinov wrote:

I guess the task to be accomplished is to activate the application
(before or after setChatVisible). Should that be the case, then I
suppose NSWorkspace activateApplication will suffice if you've
collected the necessary NSDictionary data while you were still
running
in the application using NSProcessInfo and maybe NSBundle.

2009/6/18 Egidijus Jankauskas <egidijus.jankauskas@email.lt>:

Hi all,

I have one question to more experienced SC developers:

How to bring a Chat window to front? By saying "to front" I mean
in front
of
all applications?

Currently, SystrayPopupMessageListenerImpl invokes setChatVisible()
method
on Chat object to bring it to front. It works perfectly fine if
Swing
notifications are used. Because a user clicks on Swing
notification that
is
one of SC windows, SC becomes the "currently focused
application" and
brings Chat window to front. However, when Growl notifications
are used,
user clicks on a notification, that is not one of SC windows. As
a result
of
that, setChatVisible() method brings the Chat window in front of
all
windows
that do not belong to currently focused application. So if I am
using for
example Safari and click on Growl notification, Chat window pops
in front
of
all background applications, but does not "steal" the focus from
Safari
and
stays behind it.

What would be the best way to overcome this?

Cheers,
Egidijus

On 10 Jun 2009, at 21:56, Emil Ivov wrote:

Currently, apart from /GrowlNotificationServiceImpl/ there are
2 other
classes that implement /PopupMessageHandler/ interface
- PopupMessageHandlerTrayIconImpl and
PopupMessageHandlerSwingImpl.
Following
the code of these two classes, I assume
that GrowlNotificationServiceImpl should do the same -
construct and
fire a SystrayPopupMessageEvent object, which will be used by
some
listener to bring the appropriate chat window to front.

Yes, exactly!

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-
communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

--
Emil Ivov, Ph.D. 67000 Strasbourg,
Project Lead France
SIP Communicator
emcho@sip-communicator.org FAX: +33.1.77.62.47.31
http://sip-communicator.org PHONE: +33.1.77.62.43.30

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#16

Hi Emil, all,

I have checked possible solutions to my problem and came up with these options:

1) Try to solve it with Java. toFront() looks promising but I have read that it results in different and not guaranteed behavior on different operating systems. I might come up with changes to UIService that solve the problem on Mac OS X, but at the same time introduce undesired behavior on other platforms. In addition, it could be tricky to deal with focus correctly.

2) Use apple script. 'tell application "SIP Communicator" to activate' does the job and it is possible to call it programmatically, but it just doesn't feel right for me to use a script for such task.

3) Use Carbon in JNI. There is a function that does the job: SetFrontProcess(&psn). I don't want to use this approach since Apple is winding down Carbon and it doesn't look future proof.

4) Use Cocoa in JNI. I followed your advice to check Adium source code and found out that they are calling [NSApp activateIgnoringOtherApps:YES] to get their application to front. I didn't thing it would work in my case since Adium is written in Objective C. But later I actually tried it and it works perfectly fine. I don't know why everybody is suggesting apple script or Carbon approach instead of this one line solution. NSApp is a global variable that can be used to access NSApplication instance of your application. If java application is not console based, it has NSApplication instance related to it. I have built a simple test app to test this and later tried it in SIP Communicator.

So should I use the 4th option and activate SC in growl service when the notification is clicked, or try to find a working solution to 1st option?

Cheers,
Egidijus

···

On 23 Jun 2009, at 14:08, Emil Ivov wrote:

Are we actually calling toFront() on the chat window? I just had a look
at ChatPanel and ChatWindowManager and I am not sure we are always doing
it. You may want to make sure it doesn't help before we go down that
script path.

Oh you may want to also have a look at what Adium are doing since it
seems to be working properly in their case.

Cheers
Emil

Egidijus Jankauskas wrote:

I am trying that one with AppleScript right now. It brings up the
window to front but without the focus, so not what I really want. But
maybe there is a way to set focus as well. I will have a look.

On 23 Jun 2009, at 13:22, Lubomir Marinov wrote:

I'm sorry for the mistake.

The other solution I've found on the Internet seems to be very popular
and states to deal with the fact the NSWorkspace launchApplication
does not necessarily active the application but I don't know how
practical it is for SIP Communicator - execute the AppleScript "tell
application X to activate".

Anyway, I sincerely wish you success!

2009/6/23 Egidijus Jankauskas <egidijus.jankauskas@email.lt>:

Hi Lubomir,

Thanks for your answer. There is no method "activateApplication" in
NSWorkspace, but I will try to find a way to do the same.

Egidijus

On 23 Jun 2009, at 11:27, Lubomir Marinov wrote:

I guess the task to be accomplished is to activate the application
(before or after setChatVisible). Should that be the case, then I
suppose NSWorkspace activateApplication will suffice if you've
collected the necessary NSDictionary data while you were still
running
in the application using NSProcessInfo and maybe NSBundle.

2009/6/18 Egidijus Jankauskas <egidijus.jankauskas@email.lt>:

Hi all,

I have one question to more experienced SC developers:

How to bring a Chat window to front? By saying "to front" I mean
in front
of
all applications?

Currently, SystrayPopupMessageListenerImpl invokes setChatVisible()
method
on Chat object to bring it to front. It works perfectly fine if
Swing
notifications are used. Because a user clicks on Swing
notification that
is
one of SC windows, SC becomes the "currently focused
application" and
brings Chat window to front. However, when Growl notifications
are used,
user clicks on a notification, that is not one of SC windows. As
a result
of
that, setChatVisible() method brings the Chat window in front of
all
windows
that do not belong to currently focused application. So if I am
using for
example Safari and click on Growl notification, Chat window pops
in front
of
all background applications, but does not "steal" the focus from
Safari
and
stays behind it.

What would be the best way to overcome this?

Cheers,
Egidijus

On 10 Jun 2009, at 21:56, Emil Ivov wrote:

Currently, apart from /GrowlNotificationServiceImpl/ there are
2 other
classes that implement /PopupMessageHandler/ interface
- PopupMessageHandlerTrayIconImpl and
PopupMessageHandlerSwingImpl.
Following
the code of these two classes, I assume
that GrowlNotificationServiceImpl should do the same -
construct and
fire a SystrayPopupMessageEvent object, which will be used by
some
listener to bring the appropriate chat window to front.

Yes, exactly!

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-
communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

--
Emil Ivov, Ph.D. 67000 Strasbourg,
Project Lead France
SIP Communicator
emcho@sip-communicator.org FAX: +33.1.77.62.47.31
http://sip-communicator.org PHONE: +33.1.77.62.43.30

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#17

Hi Egidijus,

Solution 4 seems the best way to handle it : it's elegant and will not cause unexpected behaviour on other OS, as it is implemented directly in the JNI. I've just tested it from your branch, it works pretty fine! Nice work!

Cheers,
romain

···

On 2009/06/24, at 2:46, Egidijus Jankauskas wrote:

Hi Emil, all,

I have checked possible solutions to my problem and came up with these options:

1) Try to solve it with Java. toFront() looks promising but I have read that it results in different and not guaranteed behavior on different operating systems. I might come up with changes to UIService that solve the problem on Mac OS X, but at the same time introduce undesired behavior on other platforms. In addition, it could be tricky to deal with focus correctly.

2) Use apple script. 'tell application "SIP Communicator" to activate' does the job and it is possible to call it programmatically, but it just doesn't feel right for me to use a script for such task.

3) Use Carbon in JNI. There is a function that does the job: SetFrontProcess(&psn). I don't want to use this approach since Apple is winding down Carbon and it doesn't look future proof.

4) Use Cocoa in JNI. I followed your advice to check Adium source code and found out that they are calling [NSApp activateIgnoringOtherApps:YES] to get their application to front. I didn't thing it would work in my case since Adium is written in Objective C. But later I actually tried it and it works perfectly fine. I don't know why everybody is suggesting apple script or Carbon approach instead of this one line solution. NSApp is a global variable that can be used to access NSApplication instance of your application. If java application is not console based, it has NSApplication instance related to it. I have built a simple test app to test this and later tried it in SIP Communicator.

So should I use the 4th option and activate SC in growl service when the notification is clicked, or try to find a working solution to 1st option?

Cheers,
Egidijus

On 23 Jun 2009, at 14:08, Emil Ivov wrote:

Are we actually calling toFront() on the chat window? I just had a look
at ChatPanel and ChatWindowManager and I am not sure we are always doing
it. You may want to make sure it doesn't help before we go down that
script path.

Oh you may want to also have a look at what Adium are doing since it
seems to be working properly in their case.

Cheers
Emil

Egidijus Jankauskas wrote:

I am trying that one with AppleScript right now. It brings up the
window to front but without the focus, so not what I really want. But
maybe there is a way to set focus as well. I will have a look.

On 23 Jun 2009, at 13:22, Lubomir Marinov wrote:

I'm sorry for the mistake.

The other solution I've found on the Internet seems to be very popular
and states to deal with the fact the NSWorkspace launchApplication
does not necessarily active the application but I don't know how
practical it is for SIP Communicator - execute the AppleScript "tell
application X to activate".

Anyway, I sincerely wish you success!

2009/6/23 Egidijus Jankauskas <egidijus.jankauskas@email.lt>:

Hi Lubomir,

Thanks for your answer. There is no method "activateApplication" in
NSWorkspace, but I will try to find a way to do the same.

Egidijus

On 23 Jun 2009, at 11:27, Lubomir Marinov wrote:

I guess the task to be accomplished is to activate the application
(before or after setChatVisible). Should that be the case, then I
suppose NSWorkspace activateApplication will suffice if you've
collected the necessary NSDictionary data while you were still
running
in the application using NSProcessInfo and maybe NSBundle.

2009/6/18 Egidijus Jankauskas <egidijus.jankauskas@email.lt>:

Hi all,

I have one question to more experienced SC developers:

How to bring a Chat window to front? By saying "to front" I mean
in front
of
all applications?

Currently, SystrayPopupMessageListenerImpl invokes setChatVisible()
method
on Chat object to bring it to front. It works perfectly fine if
Swing
notifications are used. Because a user clicks on Swing
notification that
is
one of SC windows, SC becomes the "currently focused
application" and
brings Chat window to front. However, when Growl notifications
are used,
user clicks on a notification, that is not one of SC windows. As
a result
of
that, setChatVisible() method brings the Chat window in front of
all
windows
that do not belong to currently focused application. So if I am
using for
example Safari and click on Growl notification, Chat window pops
in front
of
all background applications, but does not "steal" the focus from
Safari
and
stays behind it.

What would be the best way to overcome this?

Cheers,
Egidijus

On 10 Jun 2009, at 21:56, Emil Ivov wrote:

Currently, apart from /GrowlNotificationServiceImpl/ there are
2 other
classes that implement /PopupMessageHandler/ interface
- PopupMessageHandlerTrayIconImpl and
PopupMessageHandlerSwingImpl.
Following
the code of these two classes, I assume
that GrowlNotificationServiceImpl should do the same -
construct and
fire a SystrayPopupMessageEvent object, which will be used by
some
listener to bring the appropriate chat window to front.

Yes, exactly!

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-
communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

--
Emil Ivov, Ph.D. 67000 Strasbourg,
Project Lead France
SIP Communicator
emcho@sip-communicator.org FAX: +33.1.77.62.47.31
http://sip-communicator.org PHONE: +33.1.77.62.43.30

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#18

Hi all,

Here is my midterm progress report:

The goal for the first term was to create a Java API for the Mac OS X Growl notification daemon. API should allow SIP Communicator to:

1) Display messages with Growl
2) Set a message image through a byte array
3) Receive notifications for clicks on the growl popups
4) Determine exactly which message was a mouse click pertaining to.

I started my GSoC project by creating a dirty JNI test that allowed all of the above and added the code to growlnotification bundle in my SIP Communicator branch to test it. The next step was to develop a generic API that could be used in other Java projects. It turned out to be a bit harder that I thought in the beginning, but I have a reasonably working generic API. You can check a screenshot attached that shows a console app using it.

Most of the problems I had writing the API were because Growl framework is intended to be used in properly bundled Mac OS X applications and not in some dynamic library which acts as an intermediary between an application and Growl daemon. Because of that there are some issues/limitations:

1) Growl uses a registration dictionary to register an application with it. Documentation says that you must provide three keys in the registration dictionary: GROWL_NOTIFICATIONS_ALL, GROWL_NOTIFICATIONS_DEFAULT and GROWL_TICKET_VERSION. However, when registration happens from dylib, Growl also requires a GROWL_APP_ID to be provided. Since GROWL_APP_ID is a bundle identifier of your app, I guess that Growl checks this ID itself, but in our case the dylib does not have an associated bundle and Growl cannot find one. I provide an empty string instead, which works fine, but I don't know what side effects this could have.

2) If Growl API is used in a Java application that uses AWT and is run in headless mode, it works, but Growl Daemon complains in the console with the following message "in copyCurrentProcessURL in CFGrowlAdditions: Could not get application location, because GetProcessBundleLocation returned -606".

3) The most bizarre thing is that the order of the keys in the registration dictionary actually matters. I don't know why, but I had situations when my Java test application was not properly registered because its name entry in the registration dictionary was one of the last. I also had a similar issue with application icon. Now it works in all cases I could think of, but I can't be sure that there are no situations that would require a different order in registration dictionary.

I tried to make sure there are no memory leaks in the library. I used Apple Instruments to track object allocations and memory usage. I am total newbie in memory management issues, so I might have misinterpreted something. :slight_smile:

Regards,
Egidijus


#19

Agreed!

Romain KUNTZ wrote:

···

Hi Egidijus,

Solution 4 seems the best way to handle it : it's elegant and will not
cause unexpected behaviour on other OS, as it is implemented directly
in the JNI. I've just tested it from your branch, it works pretty
fine! Nice work!

Cheers,
romain

On 2009/06/24, at 2:46, Egidijus Jankauskas wrote:

Hi Emil, all,

I have checked possible solutions to my problem and came up with
these options:

1) Try to solve it with Java. toFront() looks promising but I have
read that it results in different and not guaranteed behavior on
different operating systems. I might come up with changes to
UIService that solve the problem on Mac OS X, but at the same time
introduce undesired behavior on other platforms. In addition, it
could be tricky to deal with focus correctly.

2) Use apple script. 'tell application "SIP Communicator" to
activate' does the job and it is possible to call it
programmatically, but it just doesn't feel right for me to use a
script for such task.

3) Use Carbon in JNI. There is a function that does the job:
SetFrontProcess(&psn). I don't want to use this approach since Apple
is winding down Carbon and it doesn't look future proof.

4) Use Cocoa in JNI. I followed your advice to check Adium source
code and found out that they are calling [NSApp
activateIgnoringOtherApps:YES] to get their application to front. I
didn't thing it would work in my case since Adium is written in
Objective C. But later I actually tried it and it works perfectly
fine. I don't know why everybody is suggesting apple script or
Carbon approach instead of this one line solution. NSApp is a global
variable that can be used to access NSApplication instance of your
application. If java application is not console based, it has
NSApplication instance related to it. I have built a simple test app
to test this and later tried it in SIP Communicator.

So should I use the 4th option and activate SC in growl service when
the notification is clicked, or try to find a working solution to
1st option?

Cheers,
Egidijus

On 23 Jun 2009, at 14:08, Emil Ivov wrote:

Are we actually calling toFront() on the chat window? I just had a
look
at ChatPanel and ChatWindowManager and I am not sure we are always
doing
it. You may want to make sure it doesn't help before we go down that
script path.

Oh you may want to also have a look at what Adium are doing since it
seems to be working properly in their case.

Cheers
Emil

Egidijus Jankauskas wrote:

I am trying that one with AppleScript right now. It brings up the
window to front but without the focus, so not what I really want.
But
maybe there is a way to set focus as well. I will have a look.

On 23 Jun 2009, at 13:22, Lubomir Marinov wrote:

I'm sorry for the mistake.

The other solution I've found on the Internet seems to be very
popular
and states to deal with the fact the NSWorkspace launchApplication
does not necessarily active the application but I don't know how
practical it is for SIP Communicator - execute the AppleScript
"tell
application X to activate".

Anyway, I sincerely wish you success!

2009/6/23 Egidijus Jankauskas <egidijus.jankauskas@email.lt>:

Hi Lubomir,

Thanks for your answer. There is no method "activateApplication"
in
NSWorkspace, but I will try to find a way to do the same.

Egidijus

On 23 Jun 2009, at 11:27, Lubomir Marinov wrote:

I guess the task to be accomplished is to activate the
application
(before or after setChatVisible). Should that be the case, then I
suppose NSWorkspace activateApplication will suffice if you've
collected the necessary NSDictionary data while you were still
running
in the application using NSProcessInfo and maybe NSBundle.

2009/6/18 Egidijus Jankauskas <egidijus.jankauskas@email.lt>:

Hi all,

I have one question to more experienced SC developers:

How to bring a Chat window to front? By saying "to front" I mean
in front
of
all applications?

Currently, SystrayPopupMessageListenerImpl invokes
setChatVisible()
method
on Chat object to bring it to front. It works perfectly fine if
Swing
notifications are used. Because a user clicks on Swing
notification that
is
one of SC windows, SC becomes the "currently focused
application" and
brings Chat window to front. However, when Growl notifications
are used,
user clicks on a notification, that is not one of SC windows. As
a result
of
that, setChatVisible() method brings the Chat window in front of
all
windows
that do not belong to currently focused application. So if I am
using for
example Safari and click on Growl notification, Chat window pops
in front
of
all background applications, but does not "steal" the focus from
Safari
and
stays behind it.

What would be the best way to overcome this?

Cheers,
Egidijus

On 10 Jun 2009, at 21:56, Emil Ivov wrote:

Currently, apart from /GrowlNotificationServiceImpl/ there are
2 other
classes that implement /PopupMessageHandler/ interface
- PopupMessageHandlerTrayIconImpl and
PopupMessageHandlerSwingImpl.
Following
the code of these two classes, I assume
that GrowlNotificationServiceImpl should do the same -
construct and
fire a SystrayPopupMessageEvent object, which will be used by
some
listener to bring the appropriate chat window to front.

Yes, exactly!

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-
communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-
communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

--
Emil Ivov, Ph.D. 67000 Strasbourg,
Project Lead France
SIP Communicator
emcho@sip-communicator.org FAX:
+33.1.77.62.47.31
http://sip-communicator.org PHONE:
+33.1.77.62.43.30

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-
communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

--
Emil Ivov, Ph.D. 67000 Strasbourg,
Project Lead France
SIP Communicator
emcho@sip-communicator.org FAX: +33.1.77.62.47.31
http://sip-communicator.org PHONE: +33.1.77.62.43.30

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#20

Hi Egidijus,

Some feedback on your developments. I've tested multiple cases, when the chat window has multiple tabs, have the focus or not, etc. and it behaves perfectly in all cases, that's a pretty good job!

I've noticed a problem though: it seems that I don't get any "pro-active" growl notifications (when pro-active notifications are displayed but the chat window is not focused, a growl popup is supposed to display the pro-active notification - this is the behaviour in the previous growl notification implementation).

Could you test on your side if it behaves correctly? Note that pro-active growl notifications only work when the chat window is not in the focus, and that the rate of pro-active notifications are limited to one every 30 sec.

Also, some other messages such as the "welcome" message is not displayed either (it is supposed to appear on startup).

Cheers,
romain

···

On 2009/06/24, at 10:42, Romain KUNTZ wrote:

Hi Egidijus,

Solution 4 seems the best way to handle it : it's elegant and will not cause unexpected behaviour on other OS, as it is implemented directly in the JNI. I've just tested it from your branch, it works pretty fine! Nice work!

Cheers,
romain

On 2009/06/24, at 2:46, Egidijus Jankauskas wrote:

Hi Emil, all,

I have checked possible solutions to my problem and came up with these options:

1) Try to solve it with Java. toFront() looks promising but I have read that it results in different and not guaranteed behavior on different operating systems. I might come up with changes to UIService that solve the problem on Mac OS X, but at the same time introduce undesired behavior on other platforms. In addition, it could be tricky to deal with focus correctly.

2) Use apple script. 'tell application "SIP Communicator" to activate' does the job and it is possible to call it programmatically, but it just doesn't feel right for me to use a script for such task.

3) Use Carbon in JNI. There is a function that does the job: SetFrontProcess(&psn). I don't want to use this approach since Apple is winding down Carbon and it doesn't look future proof.

4) Use Cocoa in JNI. I followed your advice to check Adium source code and found out that they are calling [NSApp activateIgnoringOtherApps:YES] to get their application to front. I didn't thing it would work in my case since Adium is written in Objective C. But later I actually tried it and it works perfectly fine. I don't know why everybody is suggesting apple script or Carbon approach instead of this one line solution. NSApp is a global variable that can be used to access NSApplication instance of your application. If java application is not console based, it has NSApplication instance related to it. I have built a simple test app to test this and later tried it in SIP Communicator.

So should I use the 4th option and activate SC in growl service when the notification is clicked, or try to find a working solution to 1st option?

Cheers,
Egidijus

On 23 Jun 2009, at 14:08, Emil Ivov wrote:

Are we actually calling toFront() on the chat window? I just had a look
at ChatPanel and ChatWindowManager and I am not sure we are always doing
it. You may want to make sure it doesn't help before we go down that
script path.

Oh you may want to also have a look at what Adium are doing since it
seems to be working properly in their case.

Cheers
Emil

Egidijus Jankauskas wrote:

I am trying that one with AppleScript right now. It brings up the
window to front but without the focus, so not what I really want. But
maybe there is a way to set focus as well. I will have a look.

On 23 Jun 2009, at 13:22, Lubomir Marinov wrote:

I'm sorry for the mistake.

The other solution I've found on the Internet seems to be very popular
and states to deal with the fact the NSWorkspace launchApplication
does not necessarily active the application but I don't know how
practical it is for SIP Communicator - execute the AppleScript "tell
application X to activate".

Anyway, I sincerely wish you success!

2009/6/23 Egidijus Jankauskas <egidijus.jankauskas@email.lt>:

Hi Lubomir,

Thanks for your answer. There is no method "activateApplication" in
NSWorkspace, but I will try to find a way to do the same.

Egidijus

On 23 Jun 2009, at 11:27, Lubomir Marinov wrote:

I guess the task to be accomplished is to activate the application
(before or after setChatVisible). Should that be the case, then I
suppose NSWorkspace activateApplication will suffice if you've
collected the necessary NSDictionary data while you were still
running
in the application using NSProcessInfo and maybe NSBundle.

2009/6/18 Egidijus Jankauskas <egidijus.jankauskas@email.lt>:

Hi all,

I have one question to more experienced SC developers:

How to bring a Chat window to front? By saying "to front" I mean
in front
of
all applications?

Currently, SystrayPopupMessageListenerImpl invokes setChatVisible()
method
on Chat object to bring it to front. It works perfectly fine if
Swing
notifications are used. Because a user clicks on Swing
notification that
is
one of SC windows, SC becomes the "currently focused
application" and
brings Chat window to front. However, when Growl notifications
are used,
user clicks on a notification, that is not one of SC windows. As
a result
of
that, setChatVisible() method brings the Chat window in front of
all
windows
that do not belong to currently focused application. So if I am
using for
example Safari and click on Growl notification, Chat window pops
in front
of
all background applications, but does not "steal" the focus from
Safari
and
stays behind it.

What would be the best way to overcome this?

Cheers,
Egidijus

On 10 Jun 2009, at 21:56, Emil Ivov wrote:

Currently, apart from /GrowlNotificationServiceImpl/ there are
2 other
classes that implement /PopupMessageHandler/ interface
- PopupMessageHandlerTrayIconImpl and
PopupMessageHandlerSwingImpl.
Following
the code of these two classes, I assume
that GrowlNotificationServiceImpl should do the same -
construct and
fire a SystrayPopupMessageEvent object, which will be used by
some
listener to bring the appropriate chat window to front.

Yes, exactly!

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-
communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

--
Emil Ivov, Ph.D. 67000 Strasbourg,
Project Lead France
SIP Communicator
emcho@sip-communicator.org FAX: +33.1.77.62.47.31
http://sip-communicator.org PHONE: +33.1.77.62.43.30

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net