├── README.md
├── note.txt
├── offlinemsg.jar
└── offlinemsg
├── changelog.html
├── logo_large.gif
├── logo_small.gif
├── plugin.xml
├── readme.html
└── src
└── java
└── org
└── jivesoftware
└── openfire
└── plugin
└── OfflineMsg.java
/README.md:
--------------------------------------------------------------------------------
1 | how to use:
2 |
3 | find the following code in offlinemsg\src\java\org\jivesoftware\openfire\plugin\OfflineMsg.java
4 |
5 | /*
6 | * add your code here to send offline msg
7 | * recipient.getNode() : receive's id,for example,if receive's jid is "23@localhost", receive's id is "23"
8 | * content: message content
9 | */
10 |
11 |
12 | add your code for send offline msg, usually is the queue to send msg
13 |
--------------------------------------------------------------------------------
/note.txt:
--------------------------------------------------------------------------------
1 | how to use:
2 |
3 | find the following code in offlinemsg\src\java\org\jivesoftware\openfire\plugin\OfflineMsg.java
4 |
5 | /*
6 | * add your code here to send offline msg
7 | * recipient.getNode() : receive's id,for example,if receive's jid is "23@localhost", receive's id is "23"
8 | * content: message content
9 | */
10 |
11 |
12 | add your code for send offline msg, usually is the queue to send msg
--------------------------------------------------------------------------------
/offlinemsg.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/newjueqi/sendOfflineMsg/5c57deb73a0e1eecef08fb71584a7208f6af6a69/offlinemsg.jar
--------------------------------------------------------------------------------
/offlinemsg/changelog.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Presence Plugin Changelog
6 |
40 |
41 |
42 |
43 |
44 | Presence Plugin Changelog
45 |
46 |
47 | 1.5.0 -- December 2, 2009
48 |
49 | - Now requires Openfire 3.7.0.
50 | - [OF-53] - Replace custom logging implementation with a third party library.
51 |
52 |
53 | 1.4.0 -- April 12, 2007
54 |
55 | - Now requires Openfire 3.3.0.
56 | - The administrator can now set custom values for the presence text.
57 | - Updated default presence images.
58 | - Added URL information to admin console page.
59 |
60 |
61 | 1.3.3 -- November 03, 2006
62 |
63 | - Fixed NPE when no target JID was found in HTTP request.
64 |
65 |
66 | 1.3.2 -- October 06, 2006
67 |
68 | - Updated to use compression offered by Openfire 3.1
69 |
70 |
71 | 1.3.1 -- July 19, 2006
72 |
73 | - Added support for retrieving the user's presence status as plain text.
74 |
75 |
76 | 1.3.0 -- July 10, 2006
77 |
78 | - Added support for probing presence of components.
79 |
- Fixed minor problem in readme.html -- the example Apache redirect was incorrect.
80 |
81 |
82 | 1.2.0 -- April 19, 2006
83 |
84 | - Added documentation for configuring the plugin to work well with firewalls.
85 | - [JM-602] - Presence plugin now handles HTTP redirection. (1 vote)
86 |
87 |
88 | 1.1.2 -- March 9, 2006
89 |
90 | - Now requires Openfire 2.5.1
91 |
92 |
93 | 1.1.1 -- December 15, 2005
94 |
95 | - Now requires Openfire 2.4.0
96 |
97 |
98 | 1.1 -- Jul 25, 2005
99 |
100 |
101 | - Large updates to documentation and protocol.
102 |
103 |
104 | 1.0 -- Jul 20, 2005
105 |
106 |
107 | - Initial release.
108 |
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/offlinemsg/logo_large.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/newjueqi/sendOfflineMsg/5c57deb73a0e1eecef08fb71584a7208f6af6a69/offlinemsg/logo_large.gif
--------------------------------------------------------------------------------
/offlinemsg/logo_small.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/newjueqi/sendOfflineMsg/5c57deb73a0e1eecef08fb71584a7208f6af6a69/offlinemsg/logo_small.gif
--------------------------------------------------------------------------------
/offlinemsg/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | org.jivesoftware.openfire.plugin.OfflineMsg
5 | Offline Msg
6 | send offline msg to other server
7 | newjueqi
8 | 1.0.0
9 | 12/20/2013
10 | 3.7.0
11 |
12 |
13 |
--------------------------------------------------------------------------------
/offlinemsg/readme.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Presence Plugin Readme
6 |
50 |
51 |
52 |
53 |
54 | Presence Plugin Readme
55 |
56 |
57 | Overview
58 |
59 |
60 | The presence plugin is a service that provides simple presence information over HTTP.
61 | It can be used to display an online status icon for a user or component on a web page or to
62 | poll for presence information from a web service.
63 |
64 |
65 | Installation
66 |
67 | Copy presence.jar into the plugins directory of your Openfire installation. The
68 | plugin will then be automatically deployed. To upgrade to a new version, copy the new
69 | presence.jar file over the existing file.
70 |
71 | Configuration
72 |
73 | The presence plugin can be configured via the Openfire Admin Console.
74 | Use the configuration page to specify whether presence information should be available
75 | to anyone or restricted to authorized users (users which have presence subscriptions).
76 | The status message for unavailable users can also be changed from the default of
77 | "Unavailable".
78 |
79 | Using the Plugin
80 |
81 | To get presence information for a user, submit HTTP requests to the presence
82 | service. The service address is [hostname]/plugins/presence/status. For example,
83 | if your server name is "example.com", the URL is http://example.com/plugins/presence/status.
84 |
85 | The following parameters can be passed into the request:
86 |
87 |
88 |
89 |
90 | Name | Description |
91 |
92 |
93 | jid | Required | The bare JID (address) of the user to get presence
94 | information for (e.g. "jsmith@example.com"). The address must be on the same
95 | server that the presence service is deployed on. |
96 |
97 |
98 | req_jid | Optional | The bare JID (address) of the user
99 | requesting presence information. This parameter may be required in order
100 | to have permission to get presence information. For example, the presence
101 | service can be configured to only allow presence requests from users that
102 | have a presence subscription to the requested jid. |
103 |
104 |
105 | type | Optional | The type of response to return. Valid values
106 | are image, text or xml. If this parameter is not specified, the
107 | default value is image, which will display an image representing the
108 | user's presence. If xml is specified, an XML representation of the
109 | user's presence will be returned. If text is specified, the status text of the
110 | user's presence will be returned. |
111 |
112 |
113 | images | Optional | The presence service includes a default
114 | set of images that will be returned for a user's presence. You can specify
115 | a custom set of images using this parameter. The value should be the URL
116 | to the images and should include an --IMAGE-- token. For example:
117 | "http://www.example.com/images/--IMAGE--.gif". The token will be dynamically
118 | replaced with one of the following values depending on the presence status:
119 | available, chat, away, xa, dnd,
120 | offline, or forbidden. If this option is used, the presence service
121 | will respond with an http redirect pointing to the supplied image url.
122 | |
123 |
124 |
125 | [image_type] | Optional | Instead of specifying a single
126 | location for all custom presence images, you can override each image location
127 | directly. The parameter name should be one of the following values:
128 | available, chat, away, xa, dnd,
129 | offline, or forbidden. The parameter value should be
130 | the full URL of the image, such as "http://www.example.com/images/dnd.png".
131 | These parameters can be used in combination with the "images" parameter to
132 | specify a base location for custom images but then to override specific
133 | images with different locations. |
134 |
135 |
136 |
137 |
138 |
Sample HTML
139 |
140 |
The following example is the simplest form of calling the service to display
141 | default presence images. The server name and user must be customized for your deployment:
142 |
143 |
148 |
149 |
150 |
This example requests a user's presence by the user "jsmith" and specifies
151 | custom images that should be used to display the user's presence:
152 |
153 |
159 |
160 |
161 |
This example requests the presence of a user in XML format:
162 |
163 |
168 |
169 |
170 |
This example requests the status text of the presence of a user in text format:
171 |
172 |
177 |
178 |
179 |
Working With Firewalls
180 |
181 |
Because the presence plugin runs within the Openfire admin console web container, users
182 | behind firewalls may have problems seeing the presence icons. For example, if the Openfire
183 | admin console runs on the default port of 9090 and a user is only allowed to receive HTTP traffic
184 | on port 80, then a web request like the following won't work:
185 |
186 | <img src="http://www.example.com:9090/plugins/presence/status?jid=jsmith@example.com">
187 |
188 |
189 |
One solution for Apache users is to use mod_rewrite, mod_proxy and mod_proxy_http to serve
190 | traffic for the plugin on port 80. Sample Apache configuration entries for performing this mapping
191 | are below. Essentially, we make Apache intercept all requests for the presence plugin on port 80 and
192 | then proxy a real connection to the HTTP server on port 9090.
193 |
194 |
195 |
196 |
197 | 1 2 3 4 5 6 7 8 9
|
198 | <virtualhost *:80>
199 |
200 | servername example.com
201 | ....
202 | ProxyVia On
203 | RewriteEngine On
204 | RewriteCond %{REQUEST_URI} ^/plugins/presence/status
205 | RewriteRule ^/(.*) http://example.com:9090/$1 [P]
206 | </virtualhost>
207 | |
208 |
209 |
210 |
211 |
212 |
--------------------------------------------------------------------------------
/offlinemsg/src/java/org/jivesoftware/openfire/plugin/OfflineMsg.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2004-2008 Jive Software. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.jivesoftware.openfire.plugin;
17 | import java.io.File;
18 | import java.io.IOException;
19 | import java.sql.Timestamp;
20 | import java.util.Date;
21 | import java.util.List;
22 |
23 |
24 | import org.jivesoftware.database.SequenceManager;
25 | import org.jivesoftware.openfire.PresenceManager;
26 | import org.jivesoftware.openfire.XMPPServer;
27 | import org.jivesoftware.openfire.container.Plugin;
28 | import org.jivesoftware.openfire.container.PluginManager;
29 | import org.jivesoftware.openfire.interceptor.InterceptorManager;
30 | import org.jivesoftware.openfire.interceptor.PacketInterceptor;
31 | import org.jivesoftware.openfire.interceptor.PacketRejectedException;
32 | import org.jivesoftware.openfire.session.Session;
33 | import org.jivesoftware.openfire.user.User;
34 | import org.jivesoftware.openfire.user.UserManager;
35 | import org.jivesoftware.openfire.user.UserNotFoundException;
36 | import org.slf4j.Logger;
37 | import org.slf4j.LoggerFactory;
38 | import org.xmpp.packet.IQ;
39 | import org.xmpp.packet.JID;
40 | import org.xmpp.packet.Message;
41 | import org.xmpp.packet.Packet;
42 | import org.xmpp.packet.Presence;
43 | import org.jivesoftware.openfire.XMPPServer;
44 | import org.jivesoftware.openfire.container.Plugin;
45 | import org.jivesoftware.openfire.container.PluginManager;
46 | import org.jivesoftware.openfire.user.User;
47 | import org.jivesoftware.openfire.user.UserManager;
48 | import org.jivesoftware.openfire.PresenceManager;
49 | import org.jivesoftware.util.JiveGlobals;
50 | import org.jivesoftware.util.Log;
51 |
52 |
53 | /**
54 | *
function: send offline msg plugin
55 | * @author newjueqi
56 | * @createDate 2013-12-19
57 | * @project OpenfirePlugin
58 | * @blog http://blog.csdn.net/newjueqi
59 | * @email h6k65@126.com
60 | * @version 1.0
61 | */
62 | public class OfflineMsg implements PacketInterceptor, Plugin {
63 |
64 | private static final Logger log = LoggerFactory.getLogger(OfflineMsg.class);
65 |
66 | //Hook for intercpetorn
67 | private InterceptorManager interceptorManager;
68 | private static PluginManager pluginManager;
69 | private UserManager userManager;
70 | private PresenceManager presenceManager;
71 |
72 | public OfflineMsg() {
73 |
74 | }
75 |
76 | public void debug(String str){
77 | if( true ){
78 | // System.out.println(str);
79 | }
80 | }
81 |
82 | public void initializePlugin(PluginManager manager, File pluginDirectory) {
83 | interceptorManager = InterceptorManager.getInstance();
84 | interceptorManager.addInterceptor(this);
85 |
86 | XMPPServer server = XMPPServer.getInstance();
87 | userManager = server.getUserManager();
88 | presenceManager = server.getPresenceManager();
89 |
90 | pluginManager = manager;
91 |
92 | this.debug("start offline 1640");
93 | }
94 |
95 | public void destroyPlugin() {
96 | this.debug("start offline 1640");
97 | }
98 |
99 | /**
100 | * intercept message
101 | */
102 | @Override
103 | public void interceptPacket(Packet packet, Session session, boolean incoming, boolean processed) throws PacketRejectedException {
104 |
105 |
106 | JID recipient = packet.getTo();
107 | if (recipient != null) {
108 |
109 | String username = recipient.getNode();
110 |
111 | // if broadcast message or user is not exist
112 | if (username == null || !UserManager.getInstance().isRegisteredUser(recipient)) {
113 |
114 | return;
115 |
116 | } else if (!XMPPServer.getInstance().getServerInfo().getXMPPDomain().equals(recipient.getDomain())) {
117 | //not from the same domain
118 |
119 | return;
120 |
121 | } else if ("".equals(recipient.getResource())) {
122 |
123 | }
124 |
125 | }
126 |
127 | this.doAction(packet, incoming, processed, session);
128 |
129 | }
130 |
131 |
132 | /**
133 | *
send offline msg from this function
134 | */
135 | private void doAction(Packet packet, boolean incoming, boolean processed, Session session) {
136 |
137 | Packet copyPacket = packet.createCopy();
138 | if (packet instanceof Message) {
139 |
140 | Message message = (Message) copyPacket;
141 |
142 | if (message.getType() == Message.Type.chat) {
143 |
144 | if (processed || !incoming) {
145 | return;
146 | }
147 |
148 | Message sendmessage = (Message) packet;
149 | String content= sendmessage.getBody();
150 | JID recipient = sendmessage.getTo();
151 |
152 | //get message
153 | try
154 | {
155 |
156 | if (recipient.getNode() == null ||
157 | !UserManager.getInstance().isRegisteredUser(recipient.getNode())) {
158 | // Sender is requesting presence information of an anonymous user
159 | throw new UserNotFoundException("Username is null");
160 | }
161 |
162 | Presence status=presenceManager.getPresence(userManager.getUser(recipient.getNode()));
163 |
164 | if( status!=null ){
165 | this.debug(recipient.getNode()+" online111"+",message: "+content);
166 | }else{
167 | this.debug(recipient.getNode()+" offline111"+",message: "+content);
168 |
169 | /*
170 | * add your code here to send offline msg
171 | * recipient.getNode() : receive's id,for example,if receive's jid is "23@localhost", receive's id is "23"
172 | * content: message content
173 | */
174 |
175 |
176 | }//end if
177 |
178 | }
179 | catch (UserNotFoundException e) {
180 | this.debug("exceptoin "+recipient.getNode()+" not find"+",full jid: "+recipient.toFullJID());
181 | }
182 |
183 | } else if (message.getType() == Message.Type.groupchat) {
184 |
185 | List> els = message.getElement().elements("x");
186 | if (els != null && !els.isEmpty()) {
187 |
188 | } else {
189 | }
190 | } else {
191 |
192 | }
193 |
194 | } else if (packet instanceof IQ) {
195 |
196 | IQ iq = (IQ) copyPacket;
197 |
198 | if (iq.getType() == IQ.Type.set && iq.getChildElement() != null && "session".equals(iq.getChildElement().getName())) {
199 |
200 | }
201 |
202 | } else if (packet instanceof Presence) {
203 |
204 | Presence presence = (Presence) copyPacket;
205 |
206 | if (presence.getType() == Presence.Type.unavailable) {
207 |
208 |
209 | }
210 |
211 | }
212 |
213 | }
214 |
215 | }
216 |
--------------------------------------------------------------------------------