Skip to content

Commit

Permalink
Merge branch 'withgod-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuke committed Dec 1, 2010
2 parents a4c9e62 + faaef1e commit 10263a5
Show file tree
Hide file tree
Showing 25 changed files with 1,377 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ statuses/*
target/*
twitter4j.properties
twitter4j-httpclient-support/target/*
twitter4j-media-support/target/*
twitter4j-core/target/*
twitter4j-core/src/test/resources/xauth-test.properties
twitter4j-examples/target/*
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
</profile>
</profiles>
<modules>
<module>twitter4j-media-support</module>
<module>twitter4j-httpclient-support</module>
<module>twitter4j-core</module>
<module>twitter4j-examples</module>
Expand Down
9 changes: 9 additions & 0 deletions twitter4j-core/src/main/java/twitter4j/TwitterBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ public boolean equals(Object o) {
return true;
}

/**
* Returns the configuration associated with this instance
* @return configuration associated with this instance
* @since Twitter4J 2.1.8
*/
public Configuration getConfiguration(){
return this.conf;
}

@Override
public int hashCode() {
return auth != null ? auth.hashCode() : 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,8 @@ public interface Configuration extends HttpClientConfiguration
boolean isIncludeRTsEnabled();

boolean isUserStreamRepliesAllEnabled();

String getMediaProvider();

String getMediaProviderAPIKey();
}
27 changes: 27 additions & 0 deletions twitter4j-core/src/main/java/twitter4j/conf/ConfigurationBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ class ConfigurationBase implements Configuration, java.io.Serializable {

private boolean userStreamRepliesAllEnabled;

private String mediaProvider;

private String mediaProviderAPIKey;

// hidden portion
private String clientVersion;
private String clientURL;
Expand Down Expand Up @@ -165,6 +169,9 @@ protected ConfigurationBase() {
isDalvik = dalvikDetected;
}
IS_DALVIK = Boolean.valueOf(isDalvik);

setMediaProvider("YFROG");
setMediaProviderAPIKey(null);
}


Expand Down Expand Up @@ -501,6 +508,22 @@ protected final void setUserStreamRepliesAllEnabled(boolean enabled) {
this.userStreamRepliesAllEnabled = enabled;
}

public String getMediaProvider(){
return this.mediaProvider;
}

protected final void setMediaProvider(String mediaProvider){
this.mediaProvider = mediaProvider;
}

public String getMediaProviderAPIKey(){
return this.mediaProviderAPIKey;
}

protected final void setMediaProviderAPIKey(String mediaProviderAPIKey){
this.mediaProviderAPIKey = mediaProviderAPIKey;
}

@Override
public int hashCode() {
int result = (debug ? 1 : 0);
Expand Down Expand Up @@ -540,6 +563,8 @@ public int hashCode() {
result = 31 * result + (clientURL != null ? clientURL.hashCode() : 0);
result = 31 * result + (IS_DALVIK ? 1 : 0);
result = 31 * result + (requestHeaders != null ? requestHeaders.hashCode() : 0);
result = 31 * result + (mediaProvider != null ? mediaProvider.hashCode() : 0);
result = 31 * result + (mediaProviderAPIKey != null ? mediaProviderAPIKey.hashCode() : 0);
return result;
}

Expand Down Expand Up @@ -583,6 +608,8 @@ public String toString() {
", clientURL='" + clientURL + '\'' +
", IS_DALVIK=" + IS_DALVIK +
", requestHeaders=" + requestHeaders +
", mediaProvider=" + mediaProvider +
", mediaProviderAPIKey=" + mediaProviderAPIKey +
'}';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,18 @@ public ConfigurationBuilder setUserStreamRepliesAllEnabled(boolean enabled) {
return this;
}

public ConfigurationBuilder setMediaProvider(String mediaProvider) {
checkNotBuilt();
configurationBean.setMediaProvider(mediaProvider);
return this;
}

public ConfigurationBuilder setMediaProviderAPIKey(String mediaProviderAPIKey) {
checkNotBuilt();
configurationBean.setMediaProviderAPIKey(mediaProviderAPIKey);
return this;
}

public Configuration build() {
checkNotBuilt();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ public final class PropertyConfiguration extends ConfigurationBase implements ja
public static final String INCLUDE_RTS = "includeRTs";
public static final String STREAM_USER_REPLIES_ALL = "stream.user.repliesAll";

public static final String MEDIA_PROVIDER = "media.provier";
public static final String MEDIA_PROVIDER_API_KEY = "media.provierAPIKey";

// hidden portion
public static final String CLIENT_VERSION = "clientVersion";
public static final String CLIENT_URL = "clientURL";
Expand Down Expand Up @@ -336,6 +339,12 @@ private void setFieldsWithPrefix(Properties props, String prefix) {
if (notNull(props, prefix, STREAM_USER_REPLIES_ALL)) {
setUserStreamRepliesAllEnabled(getBoolean(props, prefix, STREAM_USER_REPLIES_ALL));
}
if (notNull(props, prefix, MEDIA_PROVIDER)) {
setMediaProvider(getString(props, prefix, MEDIA_PROVIDER));
}
if (notNull(props, prefix, MEDIA_PROVIDER_API_KEY)) {
setMediaProviderAPIKey(getString(props, prefix, MEDIA_PROVIDER_API_KEY));
}
}

protected boolean getBoolean(Properties props, String prefix, String name) {
Expand Down
12 changes: 11 additions & 1 deletion twitter4j-core/src/main/java/twitter4j/util/ImageUpload.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
/**
* @author Rémy Rakic - remy.rakic at gmail.com
* @since Twitter4J 2.1.3
* @deprecated use {@link twitter4j.media.ImageUploader} and {@link twitter4j.media.ImageUploaderFactory#getInstance(twitter4j.Twitter)} instead
*/
public abstract class ImageUpload {
public static String DEFAULT_TWITPIC_API_KEY = null;
Expand All @@ -66,6 +67,7 @@ public abstract class ImageUpload {
* Returns an image uploader to Twitpic. Handles both BasicAuth and OAuth.
* Note: When using OAuth, the Twitpic API Key needs to be specified, either with the field ImageUpload.DEFAULT_TWITPIC_API_KEY,
* or using the getTwitpicUploader (String twitpicAPIKey, OAuthAuthorization auth) method
* @deprecated use {@link twitter4j.media.ImageUploaderFactory#getInstance(twitter4j.Twitter)} instead
*/
public static ImageUpload getTwitpicUploader(Twitter twitter) throws TwitterException {
Authorization auth = twitter.getAuthorization();
Expand All @@ -78,27 +80,31 @@ public static ImageUpload getTwitpicUploader(Twitter twitter) throws TwitterExce

/**
* Returns a BasicAuth image uploader to Twitpic
* @deprecated use {@link twitter4j.media.ImageUploaderFactory#getInstance(twitter4j.Twitter)} instead
*/
public static ImageUpload getTwitpicUploader(BasicAuthorization auth) {
return new TwitpicBasicAuthUploader(auth);
}

/**
* Returns an OAuth image uploader to Twitpic
* @deprecated use {@link twitter4j.media.ImageUploaderFactory#getInstance(twitter4j.Twitter)} instead
*/
public static ImageUpload getTwitpicUploader(String twitpicAPIKey, OAuthAuthorization auth) {
return new TwitpicOAuthUploader(twitpicAPIKey, auth);
}

/**
* Returns an OAuth image uploader to TweetPhoto
* @deprecated use {@link twitter4j.media.ImageUploaderFactory#getInstance(twitter4j.Twitter)} instead
*/
public static ImageUpload getTweetPhotoUploader(String tweetPhotoAPIKey, OAuthAuthorization auth) {
return new TweetPhotoOAuthUploader(tweetPhotoAPIKey, auth);
}

/**
* Returns an image uploader to YFrog. Handles both BasicAuth and OAuth
* @deprecated use {@link twitter4j.media.ImageUploaderFactory#getInstance(twitter4j.Twitter)} instead
*/
public static ImageUpload getYFrogUploader(Twitter twitter) throws TwitterException {
Authorization auth = twitter.getAuthorization();
Expand All @@ -111,40 +117,44 @@ public static ImageUpload getYFrogUploader(Twitter twitter) throws TwitterExcept

/**
* Returns a BasicAuth image uploader to YFrog
* @deprecated use {@link twitter4j.media.ImageUploaderFactory#getInstance(twitter4j.Twitter)} instead
*/
public static ImageUpload getYFrogUploader(BasicAuthorization auth) {
return new YFrogBasicAuthUploader(auth);
}

/**
* Returns an OAuth image uploader to YFrog
* @deprecated use {@link twitter4j.media.ImageUploaderFactory#getInstance(twitter4j.Twitter)} instead
*/
public static ImageUpload getYFrogUploader(String userId, OAuthAuthorization auth) {
return new YFrogOAuthUploader(userId, auth);
}

/**
* Returns an OAuth image uploader to img.ly
* @deprecated use {@link twitter4j.media.ImageUploaderFactory#getInstance(twitter4j.Twitter)} instead
*/
public static ImageUpload getImgLyUploader (OAuthAuthorization auth) {
return new ImgLyOAuthUploader (auth);
}

/**
* Returns an OAuth image uploader to Twitgoo
* @deprecated use {@link twitter4j.media.ImageUploaderFactory#getInstance(twitter4j.Twitter)} instead
*/
public static ImageUpload getTwitgooUploader(OAuthAuthorization auth) {
return new TwitgooOAuthUploader (auth);
}

/**
* Returns an OAuth image uploader to Twipple
* @deprecated use {@link twitter4j.media.ImageUploaderFactory#getInstance(twitter4j.Twitter)} instead
*/
public static ImageUpload getTwippleUploader (OAuthAuthorization auth) {
return new TwippleUploader(auth);
}


private static void ensureBasicEnabled(Authorization auth) {
if (!(auth instanceof BasicAuthorization)) {
throw new IllegalStateException(
Expand Down
3 changes: 0 additions & 3 deletions twitter4j-core/src/test/resources/test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,3 @@ browserConsumerKey=zQpyhhaSSwY61mxH9C8ojw
browserConsumerSecret=bAc1kurQZCdQzuAzVTFWj3HAprCn7aiNzErWGQa7lHk

#twit4jblock / twit4jblock twitter4j.test+twit4jblock@gmail.com

twitpic.apiKey=d414e7c05f440c867990fbb08286bdfd
tweetPhoto.apiKey=b30d6580-46ce-49a1-b469-31777a326938
Loading

0 comments on commit 10263a5

Please sign in to comment.