### Eclipse Workspace Patch 1.0 #P org.eclipse.mylyn.commons.identity Index: src/org/eclipse/mylyn/commons/identity/gravatar/GravatarCallbackAdapter.java =================================================================== RCS file: src/org/eclipse/mylyn/commons/identity/gravatar/GravatarCallbackAdapter.java diff -N src/org/eclipse/mylyn/commons/identity/gravatar/GravatarCallbackAdapter.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/mylyn/commons/identity/gravatar/GravatarCallbackAdapter.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2011 GitHub Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Kevin Sawicki (GitHub Inc.) - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.commons.identity.gravatar; + +/** + * Base implementation of {@link IGravatarCallback} + * + * @author Kevin Sawicki (kevin@github.com) + */ +public abstract class GravatarCallbackAdapter implements IGravatarCallback { + + /** + * @see org.eclipse.mylyn.commons.identity.gravatar.IGravatarCallback#loaded(org.eclipse.mylyn.commons.identity.gravatar.Gravatar) + */ + public void loaded(Gravatar avatar) { + // Does nothing sub-clsases should override + } + + /** + * @see org.eclipse.mylyn.commons.identity.gravatar.IGravatarCallback#error(java.lang.Exception) + */ + public void error(Exception exception) { + // Does nothing sub-clsases should override + } + +} Index: src/org/eclipse/mylyn/commons/identity/gravatar/IGravatarCallback.java =================================================================== RCS file: src/org/eclipse/mylyn/commons/identity/gravatar/IGravatarCallback.java diff -N src/org/eclipse/mylyn/commons/identity/gravatar/IGravatarCallback.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/mylyn/commons/identity/gravatar/IGravatarCallback.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2011 GitHub Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Kevin Sawicki (GitHub Inc.) - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylyn.commons.identity.gravatar; + +/** + * Callback interface for when gravatar loading completes or fails. + * + * @author Kevin Sawicki (kevin@github.com) + */ +public interface IGravatarCallback { + + /** + * Gravatar loaded successfully + * + * @param avatar + */ + void loaded(Gravatar avatar); + + /** + * Gravatar loading failed + * + * @param exception + */ + void error(Exception exception); + +} Index: src/org/eclipse/mylyn/commons/identity/gravatar/IGravatarHashProvider.java =================================================================== RCS file: src/org/eclipse/mylyn/commons/identity/gravatar/IGravatarHashProvider.java diff -N src/org/eclipse/mylyn/commons/identity/gravatar/IGravatarHashProvider.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/mylyn/commons/identity/gravatar/IGravatarHashProvider.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2011 GitHub Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Kevin Sawicki (GitHub Inc.) - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylyn.commons.identity.gravatar; + +/** + * Interface for providing a gravatar hash. + * + * @author Kevin Sawicki (kevin@github.com) + */ +public interface IGravatarHashProvider { + + /** + * Get hash for gravatar lookup + * + * @return gravatar hash + */ + String getGravatarHash(); + +} Index: src/org/eclipse/mylyn/commons/identity/gravatar/IGravatarStore.java =================================================================== RCS file: src/org/eclipse/mylyn/commons/identity/gravatar/IGravatarStore.java diff -N src/org/eclipse/mylyn/commons/identity/gravatar/IGravatarStore.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/mylyn/commons/identity/gravatar/IGravatarStore.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,104 @@ +/******************************************************************************* + * Copyright (c) 2011 Kevin Sawicki + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ +package org.eclipse.mylyn.commons.identity.gravatar; + +import java.io.IOException; + +import org.eclipse.core.runtime.IProgressMonitor; + +/** + * Gravatar store interface. + * + * @author Kevin Sawicki (kevin@github.com) + */ +public interface IGravatarStore { + + /** + * Does this store contain a gravatar for the specified hash? + * + * @param hash + * @return true if store contains avatar, false otherwise + */ + boolean containsGravatar(String hash); + + /** + * Refresh all gravatars currently in the store + * + * @param monitor + * @return this store + */ + IGravatarStore refresh(IProgressMonitor monitor); + + /** + * Schedule refresh of gravatars asynchronously + * + * @return this store + */ + IGravatarStore scheduleRefresh(); + + /** + * Get last refresh time of store + * + * @return local refresh time + */ + long getRefreshTime(); + + /** + * Load gravatar by hash asynchronously + * + * @param hash + * @param callback + * @return this store + */ + IGravatarStore loadGravatarByHash(String hash, IGravatarCallback callback); + + /** + * Load latest gravatar by specified hash + * + * @param hash + * @return avatar or null if load fails + * @throws IOException + */ + Gravatar loadGravatarByHash(String hash) throws IOException; + + /** + * Load gravatar by e-mail address asynchronously + * + * @param email + * @param callback + * @return this store + */ + IGravatarStore loadGravatarByEmail(String email, IGravatarCallback callback); + + /** + * Load latest gravatar for specified e-mail address + * + * @param email + * @return gravatar or null if load fails + * @throws IOException + */ + Gravatar loadGravatarByEmail(String email) throws IOException; + + /** + * Get cached gravatar by hash + * + * @param hash + * @return gravatar or null if not in cache + */ + Gravatar getGravatarByHash(String hash); + + /** + * Get cached gravatar by e-mail address + * + * @param email + * @return gravatar or null if not in cache + */ + Gravatar getGravatarByEmail(String email); + +}