From 9256299117f116296df8e1334a0f7215e9bdfac0 Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Wed, 28 Feb 2007 14:34:17 +0000 Subject: [PATCH] Fix history searching in multiline messages. Add ExtendedAuthorization implementation. --- .../impl/history/HistoryReaderImpl.java | 4 +- ...ationSetExtendedAuthorizationsIcqImpl.java | 107 ++++++++++++++++++ .../icq/ProtocolProviderServiceIcqImpl.java | 15 +-- 3 files changed, 115 insertions(+), 11 deletions(-) create mode 100644 src/net/java/sip/communicator/impl/protocol/icq/OperationSetExtendedAuthorizationsIcqImpl.java diff --git a/src/net/java/sip/communicator/impl/history/HistoryReaderImpl.java b/src/net/java/sip/communicator/impl/history/HistoryReaderImpl.java index d572dffaa..4d99f4ca3 100644 --- a/src/net/java/sip/communicator/impl/history/HistoryReaderImpl.java +++ b/src/net/java/sip/communicator/impl/history/HistoryReaderImpl.java @@ -28,8 +28,8 @@ public class HistoryReaderImpl // regexp used for index of case(in)sensitive impl private static String REGEXP_END = ".*$"; - private static String REGEXP_SENSITIVE_START = "^.*"; - private static String REGEXP_INSENSITIVE_START = "^(?i).*"; + private static String REGEXP_SENSITIVE_START = "(?s)^.*"; + private static String REGEXP_INSENSITIVE_START = "(?si)^.*"; protected HistoryReaderImpl(HistoryImpl historyImpl) { diff --git a/src/net/java/sip/communicator/impl/protocol/icq/OperationSetExtendedAuthorizationsIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/OperationSetExtendedAuthorizationsIcqImpl.java new file mode 100644 index 000000000..e3a363582 --- /dev/null +++ b/src/net/java/sip/communicator/impl/protocol/icq/OperationSetExtendedAuthorizationsIcqImpl.java @@ -0,0 +1,107 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.impl.protocol.icq; + +import net.java.sip.communicator.service.protocol.*; +import net.java.sip.communicator.util.*; +import net.kano.joustsim.Screenname; + +/** + * Contains methods that would allow service users to re-request authorizations + * to add a contact to their contact list or, send them an authorization before + * having been asked. + * + * @author Damian Minkov + */ +public class OperationSetExtendedAuthorizationsIcqImpl + implements OperationSetExtendedAuthorizations +{ + private static final Logger logger = + Logger.getLogger(OperationSetExtendedAuthorizationsIcqImpl.class); + + /** + * A callback to the ICQ provider that created us. + */ + private ProtocolProviderServiceIcqImpl icqProvider = null; + + + /** + * Creates a new instance of OperationSetExtendedAuthorizationsIcqImpl + * @param icqProvider IcqProtocolProviderServiceImpl + */ + public OperationSetExtendedAuthorizationsIcqImpl( + ProtocolProviderServiceIcqImpl icqProvider) + { + this.icqProvider = icqProvider; + } + + /** + * Send an authorization request, requesting contact to add them + * to our contact list? + * + * @param request the AuthorizationRequest that we'd like the + * protocol provider to send to contact. + * @param contact the Contact who we'd be asking for an + * authorization. + * @throws OperationFailedException if we fail sending the authorization + * request. + */ + public void reRequestAuthorization(AuthorizationRequest request, Contact contact) + throws OperationFailedException + { + assertConnected(); + + if(! (contact instanceof ContactIcqImpl) ) + throw new IllegalArgumentException( + "Argument is not an icq contact (contact=" + contact + ")"); + + icqProvider.getAimConnection().getSsiService().requestBuddyAuthorization( + new Screenname(contact.getAddress()), + request.getReason()); + } + + /** + * Send a positive authorization to contact thus allowing them to + * add us to their contact list without needing to first request an + * authorization. + * + * @param contact the Contact whom we're granting authorization + * prior to receiving a request. + * @throws OperationFailedException if we fail sending the authorization. + */ + public void explicitAuthorize(Contact contact) + throws OperationFailedException + { + assertConnected(); + + if(! (contact instanceof ContactIcqImpl) ) + throw new IllegalArgumentException( + "Argument is not an icq contact (contact=" + contact + ")"); + + icqProvider.getAimConnection().getSsiService().sendFutureBuddyAuthorization( + new Screenname(contact.getAddress()), + ""); + } + + /** + * Utility method throwing an exception if the icq stack is not properly + * initialized. + * @throws java.lang.IllegalStateException if the underlying ICQ stack is + * not registered and initialized. + */ + private void assertConnected() throws IllegalStateException + { + if (icqProvider == null) + throw new IllegalStateException( + "The icq provider must be non-null and signed on the ICQ " + +"service before being able to communicate."); + if (!icqProvider.isRegistered()) + throw new IllegalStateException( + "The icq provider must be signed on the ICQ service before " + +"being able to communicate."); + } +} \ No newline at end of file diff --git a/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java index bcfdcdfe8..ecc842d7c 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java @@ -440,6 +440,12 @@ protected void initialize(String screenname, OperationSetWebContactInfo.class.getName(), webContactInfo); + OperationSetExtendedAuthorizationsIcqImpl extendedAuth = + new OperationSetExtendedAuthorizationsIcqImpl(this); + supportedOperationSets.put( + OperationSetExtendedAuthorizations.class.getName(), + extendedAuth); + isInitialized = true; } } @@ -664,15 +670,6 @@ public void handleStateChange(StateEvent event) icbmService = conn.getIcbmService(); icbmService.addIcbmListener(aimIcbmListener); - //set our own cmd factory as we'd like some extra control on - //outgoing commands. - - /** @todo */ -// conn.getInfoService(). -// getOscarConnection().getSnacProcessor(). -// getCmdFactoryMgr().getDefaultFactoryList(). -// registerAll(new DefaultCmdFactory()); - conn.getInfoService(). getOscarConnection().getSnacProcessor(). getFlapProcessor().addPacketListener(