1 /**
2  * Copyright (C) Azureus Software, Inc, All Rights Reserved.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  *
16  */
17 
18 package com.aelitis.azureus.core.messenger;
19 
20 import java.util.Collection;
21 import java.util.Map;
22 
23 import com.aelitis.azureus.core.messenger.browser.BrowserMessageDispatcher;
24 import com.aelitis.azureus.core.messenger.browser.listeners.BrowserMessageListener;
25 
26 /**
27  * @author TuxPaper
28  * @created Oct 9, 2006
29  *
30  */
31 public interface ClientMessageContext
32 {
addMessageListener(BrowserMessageListener listener)33 	public abstract void addMessageListener(BrowserMessageListener listener);
34 
removeMessageListener(String listenerId)35 	public abstract void removeMessageListener(String listenerId);
36 
removeMessageListener(BrowserMessageListener listener)37 	public abstract void removeMessageListener(BrowserMessageListener listener);
38 
getBrowserData(String key)39 	public abstract Object getBrowserData(String key);
40 
setBrowserData(String key, Object value)41 	public abstract void setBrowserData(String key, Object value);
42 
43 	/**
44 	 * Sends a message to the JavaScript message dispatcher in the page.
45 	 *
46 	 * @param key identifies the listener to receive the message
47 	 * @param op identifies the operation to perform
48 	 */
sendBrowserMessage(String key, String op)49 	public abstract boolean sendBrowserMessage(String key, String op);
50 
51 	/**
52 	 * Sends a message to the JavaScript message dispatcher in the page.
53 	 *
54 	 * @param key identifies the listener to receive the message
55 	 * @param op identifies the operation to perform
56 	 * @param params optional message parameters
57 	 */
sendBrowserMessage(String key, String op, Map params)58 	public abstract boolean sendBrowserMessage(String key, String op, Map params);
59 
executeInBrowser(final String javascript)60 	public abstract boolean executeInBrowser(final String javascript);
61 
62 	/**
63 	 * Displays a debug message tagged with the context ID.
64 	 *
65 	 * @param message sent to the debug log
66 	 */
debug(String message)67 	public abstract void debug(String message);
68 
69 	/**
70 	 * Displays a debug message and exception tagged with the context ID.
71 	 *
72 	 * @param message sent to the debug log
73 	 * @param t exception to log with message
74 	 */
debug(String message, Throwable t)75 	public abstract void debug(String message, Throwable t);
76 
getDispatcher()77 	public BrowserMessageDispatcher getDispatcher();
78 
79 	/**
80 	 * @param key
81 	 * @param op
82 	 * @param params
83 	 * @return
84 	 *
85 	 * @since 3.0.1.5
86 	 */
sendBrowserMessage(String key, String op, Collection params)87 	boolean sendBrowserMessage(String key, String op, Collection params);
88 
89 	/**
90 	 * @param dispatcher
91 	 *
92 	 * @since 3.0.5.3
93 	 */
setMessageDispatcher(BrowserMessageDispatcher dispatcher)94 	void setMessageDispatcher(BrowserMessageDispatcher dispatcher);
95 
setTorrentURLHandler( torrentURLHandler handler )96 	void setTorrentURLHandler( torrentURLHandler handler );
97 
98 	public interface
99 	torrentURLHandler
100 	{
101 		public void
handleTorrentURL( String url )102 		handleTorrentURL(
103 			String		url );
104 	}
105 
106 	/**
107 	 * @param contentNetwork
108 	 *
109 	 * @since 4.0.0.5
110 	 */
setContentNetworkID(long id)111 	void setContentNetworkID(long id);
112 
113 	/**
114 	 * @return
115 	 *
116 	 * @since 4.0.0.5
117 	 */
getContentNetworkID()118 	long getContentNetworkID();
119 }