Skip to content

Commit

Permalink
release 2.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
philsong authored and phil committed Oct 27, 2015
1 parent 91b8e95 commit 2062335
Show file tree
Hide file tree
Showing 18 changed files with 343 additions and 41 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ Simply place btcbar.app in your `/Applications` folder, and optionally add it to

The current version of btcbar (2.5.0) can be downloaded here:

https://github.com/philsong/btcbar/releases/download/2.5.0/btcbar.app.zip
https://github.com/philsong/btcbar/releases/download/2.6.0/btcbar.app.zip

It requires OS X 10.7+ and a 64-bit processor.

## Changelog

### 2.6.0
* Fixs Huobi, adds BTCC, OKCoin future, supports the k-line of sosobtc, removes btc38 and stock market.

### 2.5.0
* Adds HaobtcCNY

Expand Down
12 changes: 12 additions & 0 deletions btcbar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
4A5F94F11B0C54A00077BEBF /* HuobiCNYFetcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A5F94ED1B0C54A00077BEBF /* HuobiCNYFetcher.m */; };
4A5F94F21B0C54A00077BEBF /* WinkDexUSDFetcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A5F94EF1B0C54A00077BEBF /* WinkDexUSDFetcher.m */; };
4A5F94F51B0C56DA0077BEBF /* OKCoinCNYFetcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A5F94F31B0C56DA0077BEBF /* OKCoinCNYFetcher.m */; };
4AE253D91BDF8973002B8FDD /* BTCCCNYFetcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 4AE253D71BDF8973002B8FDD /* BTCCCNYFetcher.m */; settings = {ASSET_TAGS = (); }; };
4AE253DC1BDF8AED002B8FDD /* OKCoinFutureUSDFetcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 4AE253DA1BDF8AED002B8FDD /* OKCoinFutureUSDFetcher.m */; settings = {ASSET_TAGS = (); }; };
4AEFB3E11AE0C48D00D6BE3A /* AstockFetcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 4AEFB3DC1AE0C48D00D6BE3A /* AstockFetcher.m */; };
4AEFB3E21AE0C48D00D6BE3A /* Btc38.m in Sources */ = {isa = PBXBuildFile; fileRef = 4AEFB3DE1AE0C48D00D6BE3A /* Btc38.m */; };
830CE091171B6C3E00DDD525 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 830CE090171B6C3E00DDD525 /* Cocoa.framework */; };
Expand All @@ -37,6 +39,10 @@
4A5F94EF1B0C54A00077BEBF /* WinkDexUSDFetcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WinkDexUSDFetcher.m; path = Fetchers/WinkDexUSDFetcher.m; sourceTree = "<group>"; };
4A5F94F31B0C56DA0077BEBF /* OKCoinCNYFetcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OKCoinCNYFetcher.m; path = Fetchers/OKCoinCNYFetcher.m; sourceTree = "<group>"; };
4A5F94F41B0C56DA0077BEBF /* OKCoinCNYFetcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OKCoinCNYFetcher.h; path = Fetchers/OKCoinCNYFetcher.h; sourceTree = "<group>"; };
4AE253D71BDF8973002B8FDD /* BTCCCNYFetcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BTCCCNYFetcher.m; path = Fetchers/BTCCCNYFetcher.m; sourceTree = "<group>"; };
4AE253D81BDF8973002B8FDD /* BTCCCNYFetcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BTCCCNYFetcher.h; path = Fetchers/BTCCCNYFetcher.h; sourceTree = "<group>"; };
4AE253DA1BDF8AED002B8FDD /* OKCoinFutureUSDFetcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OKCoinFutureUSDFetcher.m; path = Fetchers/OKCoinFutureUSDFetcher.m; sourceTree = "<group>"; };
4AE253DB1BDF8AED002B8FDD /* OKCoinFutureUSDFetcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OKCoinFutureUSDFetcher.h; path = Fetchers/OKCoinFutureUSDFetcher.h; sourceTree = "<group>"; };
4AEFB3DA1AE0ADA800D6BE3A /* btcbar.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = btcbar.entitlements; sourceTree = "<group>"; };
4AEFB3DB1AE0C48D00D6BE3A /* AstockFetcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AstockFetcher.h; path = Fetchers/AstockFetcher.h; sourceTree = "<group>"; };
4AEFB3DC1AE0C48D00D6BE3A /* AstockFetcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AstockFetcher.m; path = Fetchers/AstockFetcher.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -153,6 +159,10 @@
838F4297182E5A5000B4FC58 /* Fetchers */ = {
isa = PBXGroup;
children = (
4AE253DA1BDF8AED002B8FDD /* OKCoinFutureUSDFetcher.m */,
4AE253DB1BDF8AED002B8FDD /* OKCoinFutureUSDFetcher.h */,
4AE253D71BDF8973002B8FDD /* BTCCCNYFetcher.m */,
4AE253D81BDF8973002B8FDD /* BTCCCNYFetcher.h */,
4A2F00531BCF40EA0069E7DC /* HaobtcCNYFetcher.m */,
4A2F00561BCF41500069E7DC /* HaobtcCNYFetcher.h */,
4A5F94F31B0C56DA0077BEBF /* OKCoinCNYFetcher.m */,
Expand Down Expand Up @@ -263,10 +273,12 @@
4AEFB3E11AE0C48D00D6BE3A /* AstockFetcher.m in Sources */,
4AEFB3E21AE0C48D00D6BE3A /* Btc38.m in Sources */,
83C3E7491859700100FA2921 /* BitStampUSDFetcher.m in Sources */,
4AE253D91BDF8973002B8FDD /* BTCCCNYFetcher.m in Sources */,
4A5F94F11B0C54A00077BEBF /* HuobiCNYFetcher.m in Sources */,
4A5F94F01B0C54A00077BEBF /* BitFinexUSDFetcher.m in Sources */,
830CE09D171B6C3E00DDD525 /* main.m in Sources */,
83C3E74B1859700100FA2921 /* CoinbaseUSDFetcher.m in Sources */,
4AE253DC1BDF8AED002B8FDD /* OKCoinFutureUSDFetcher.m in Sources */,
4A5F94F51B0C56DA0077BEBF /* OKCoinCNYFetcher.m in Sources */,
83C3E74A1859700100FA2921 /* BTCeUSDFetcher.m in Sources */,
4A2F00551BCF40EA0069E7DC /* HaobtcCNYFetcher.m in Sources */,
Expand Down
2 changes: 2 additions & 0 deletions btcbar/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#import "Btc38.h"
#import "AstockFetcher.h"
#import "HaobtcCNYFetcher.h"
#import "BTCCCNYFetcher.h"
#import "OKCoinFutureUSDFetcher.h"

@interface AppDelegate : NSObject <NSApplicationDelegate> {
NSMenu *btcbarMainMenu;
Expand Down
19 changes: 11 additions & 8 deletions btcbar/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ - (void)awakeFromNib
// Pass each ticker object into a dictionary, get first updates
tickers = [NSMutableArray arrayWithObjects:
[[HaobtcCNYFetcher alloc] init],
[[OKCoinCNYFetcher alloc] init],
[[HuobiCNYFetcher alloc] init],
[[OKCoinCNYFetcher alloc] init],
[[BTCCCNYFetcher alloc] init],
[[OKCoinFutureUSDFetcher alloc] init],
[[BitFinexUSDFetcher alloc] init],
[[CoinbaseUSDFetcher alloc] init],
[[BitStampUSDFetcher alloc] init],
[[BTCeUSDFetcher alloc] init],
[[CoinbaseUSDFetcher alloc] init],
[[BitFinexUSDFetcher alloc] init],
// [[WinkDexUSDFetcher alloc] init],
[[Btc38 alloc] init],
[[AstockFetcher alloc] init],
// [[Btc38 alloc] init],
// [[AstockFetcher alloc] init],
nil];


Expand All @@ -62,7 +64,7 @@ - (void)awakeFromNib

// Add the separator, Open in Browser, and Quit items to main menu
[btcbarMainMenu addItem:[NSMenuItem separatorItem]];
[btcbarMainMenu addItem:[[NSMenuItem alloc] initWithTitle:@"Open in Browser" action:@selector(menuActionBrowser:) keyEquivalent:@"o"]];
// [btcbarMainMenu addItem:[[NSMenuItem alloc] initWithTitle:@"Trade" action:@selector(menuActionBrowser:) keyEquivalent:@"o"]];
[btcbarMainMenu addItem:[[NSMenuItem alloc] initWithTitle:@"About" action:@selector(menuActionAbout:) keyEquivalent:@"a"]];
[btcbarMainMenu addItem:[[NSMenuItem alloc] initWithTitle:@"Quit" action:@selector(menuActionQuit:) keyEquivalent:@"q"]];

Expand Down Expand Up @@ -109,7 +111,8 @@ - (void)menuActionSetTicker:(id)sender

// Force the status item value to update
[[NSNotificationCenter defaultCenter] postNotificationName:@"btcbar_ticker_update" object:[tickers objectAtIndex:currentFetcherTag]];


[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[(id <Fetcher>)[tickers objectAtIndex:currentFetcherTag] url]]];
}

// "Open in Browser" action
Expand Down Expand Up @@ -170,7 +173,7 @@ - (void)updateDataTimerAction:(NSTimer *)timer
[ticker requestUpdate];
}

#define kWebAddress @"https://github.com/philsong/btcbar/ \nadd Haobtc/Btc38/Stockmarket support base on \nhttps://github.com/nearengine/btcbar"
#define kWebAddress @"https://github.com/philsong/btcbar/ \nadd Haobtc/Btc38/Stockmarket support base on \nhttps://github.com/nearengine/btcbar \n"

- (IBAction)menuActionAbout:(id)sender {
NSAlert *alert = [NSAlert alertWithMessageText:@"About."
Expand Down
20 changes: 20 additions & 0 deletions btcbar/Fetchers/BTCCCNYFetcher.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// HuobiCNYFetcher.h
// btcbar
//
// Created by lwei on 2/13/14.
// Copyright (c) 2014 nearengine. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Fetcher.h"

@interface BTCCCNYFetcher : NSObject<Fetcher, NSURLConnectionDelegate>

@property (nonatomic) NSString* ticker;
@property (nonatomic) NSString* ticker_menu;
@property (nonatomic) NSString* url;
@property (nonatomic) NSError* error;
@property (nonatomic) NSMutableData *responseData;

@end
123 changes: 123 additions & 0 deletions btcbar/Fetchers/BTCCCNYFetcher.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
//
// HuobiCNYFetcher.m
// btcbar
//
// Created by lwei on 2/13/14.
// Copyright (c) 2014 nearengine. All rights reserved.
//

#import "BTCCCNYFetcher.h"

@implementation BTCCCNYFetcher

- (id)init
{
if (self = [super init])
{
// Menu Item Name
self.ticker_menu = @"BTCC";

// Website location
self.url = @"http://k.sosobtc.com/btc_btcchina.html?from=1NDnnWCUu926z4wxA3sNBGYWNQD3mKyes8";

// Immediately request first update
[self requestUpdate];
}

return self;
}

// Override Ticker setter to trigger status item update
- (void)setTicker:(NSString *)tickerString
{
// Update the ticker value
_ticker = tickerString;

// Trigger notification to update ticker
[[NSNotificationCenter defaultCenter] postNotificationName:@"btcbar_ticker_update" object:self];
}

// Initiates an asyncronous HTTP connection
- (void)requestUpdate
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://data.btcchina.com/data/ticker?market=btccny"]];

// Set the request's user agent
[request addValue:@"btcbar/2.0 (BTCCCNYFetcher)" forHTTPHeaderField:@"User-Agent"];

// Initialize a connection from our request
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];

// Go go go
[connection start];
}

// Initializes data storage on request response
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
self.responseData = [[NSMutableData alloc] init];
}

// Appends response data
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[self.responseData appendData:data];
}

// Indiciate no caching
- (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse
{
return nil;
}

// Parse data after load
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSString *responseStr = [[NSString alloc] initWithData:self.responseData encoding:NSUTF8StringEncoding];
if (!responseStr) {
return;
}

NSString *resultsStr = responseStr;

// Parse the JSON into results
NSError *jsonParsingError = nil;
id results = [NSJSONSerialization JSONObjectWithData:[resultsStr dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:&jsonParsingError];

// Results parsed successfully from JSON
if (results)
{
NSDictionary *ticker_resp = [results objectForKey:@"ticker"];
NSString *ticker = [ticker_resp objectForKey:@"last"];

if (ticker) {
// NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
NSString *resultsStatus = [[NSString alloc] init];
resultsStatus = [NSString stringWithFormat:@"¥%@", ticker];

self.error = nil;
self.ticker = resultsStatus;
}
// Otherwise log an error...
else
{
self.error = [NSError errorWithDomain:@"com.nearengine.btcbar" code:0 userInfo:[NSDictionary dictionaryWithObjectsAndKeys: @"API Error", NSLocalizedDescriptionKey, @"The JSON received did not contain a result or the API returned an error.", NSLocalizedFailureReasonErrorKey, nil]];
self.ticker = nil;
}
}
// JSON parsing failed
else
{
self.error = [NSError errorWithDomain:@"com.nearengine.btcbar" code:0 userInfo:[NSDictionary dictionaryWithObjectsAndKeys: @"JSON Error", NSLocalizedDescriptionKey, @"Could not parse the JSON returned.", NSLocalizedFailureReasonErrorKey, nil]];
self.ticker = nil;
}
}

// HTTP request failed
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
self.error = [NSError errorWithDomain:@"com.nearengine.btcbar" code:0 userInfo:[NSDictionary dictionaryWithObjectsAndKeys: @"Connection Error", NSLocalizedDescriptionKey, @"Could not connect to Huobi.", NSLocalizedFailureReasonErrorKey, nil]];
self.ticker = nil;
}

@end
4 changes: 2 additions & 2 deletions btcbar/Fetchers/BTCeUSDFetcher.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ - (id)init
if (self = [super init])
{
// Menu Item Name
self.ticker_menu = @"BTCeBTC";
self.ticker_menu = @"BTCe";

// Website location
self.url = @"https://btc-e.com/";
self.url = @"http://k.sosobtc.com/btc_btce.html?from=1NDnnWCUu926z4wxA3sNBGYWNQD3mKyes8";

// Immediately request first update
[self requestUpdate];
Expand Down
4 changes: 2 additions & 2 deletions btcbar/Fetchers/BitFinexUSDFetcher.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ - (id)init
if (self = [super init])
{
// Menu Item Name
self.ticker_menu = @"BitFinexBTC";
self.ticker_menu = @"BitFinex";

// Website location
self.url = @"https://www.bitfinex.com/";
self.url = @"http://k.sosobtc.com/btc_bitfinex.html?from=1NDnnWCUu926z4wxA3sNBGYWNQD3mKyes8";

// Immediately request first update
[self requestUpdate];
Expand Down
4 changes: 2 additions & 2 deletions btcbar/Fetchers/BitStampUSDFetcher.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ - (id)init
if (self = [super init])
{
// Menu Item Name
self.ticker_menu = @"BitStampBTC";
self.ticker_menu = @"BitStamp";

// Website location
self.url = @"https://www.bitstamp.net/";
self.url = @"http://k.sosobtc.com/btc_bitstamp.html?from=1NDnnWCUu926z4wxA3sNBGYWNQD3mKyes8";

// Immediately request first update
[self requestUpdate];
Expand Down
2 changes: 1 addition & 1 deletion btcbar/Fetchers/Btc38.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ - (id)init
self.ticker_menu = @"BTC38";

// Website location
self.url = @"http://btc38.com";
self.url = @"http://btc38.com?from=1NDnnWCUu926z4wxA3sNBGYWNQD3mKyes8";

// Immediately request first update
[self requestUpdate];
Expand Down
4 changes: 2 additions & 2 deletions btcbar/Fetchers/CoinbaseUSDFetcher.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ - (id)init
if (self = [super init])
{
// Menu Item Name
self.ticker_menu = @"CoinbaseBTC";
self.ticker_menu = @"Coinbase";

// Website location
self.url = @"https://coinbase.com/";
self.url = @"http://k.sosobtc.com/btc_coinbase.html?from=1NDnnWCUu926z4wxA3sNBGYWNQD3mKyes8";

// Immediately request first update
[self requestUpdate];
Expand Down
4 changes: 2 additions & 2 deletions btcbar/Fetchers/HaobtcCNYFetcher.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ - (id)init
if (self = [super init])
{
// Menu Item Name
self.ticker_menu = @"HaobtcBTC";
self.ticker_menu = @"Haobtc";

// Website location
self.url = @"http://www.haobtc.com";
self.url = @"https://haobtc.com/wallet?from=1NDnnWCUu926z4wxA3sNBGYWNQD3mKyes8";

// Immediately request first update
[self requestUpdate];
Expand Down
22 changes: 8 additions & 14 deletions btcbar/Fetchers/HuobiCNYFetcher.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ - (id)init
if (self = [super init])
{
// Menu Item Name
self.ticker_menu = @"HuobiBTC";
self.ticker_menu = @"Huobi";

// Website location
self.url = @"http://www.huobi.com";
self.url = @"http://k.sosobtc.com/btc_huobi.html?from=1NDnnWCUu926z4wxA3sNBGYWNQD3mKyes8";

// Immediately request first update
[self requestUpdate];
Expand All @@ -40,7 +40,7 @@ - (void)setTicker:(NSString *)tickerString
// Initiates an asyncronous HTTP connection
- (void)requestUpdate
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://market.huobi.com/staticmarket/detail.html"]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://api.huobi.com/staticmarket/ticker_btc_json.js"]];

// Set the request's user agent
[request addValue:@"btcbar/2.0 (HuobiCNYFetcher)" forHTTPHeaderField:@"User-Agent"];
Expand Down Expand Up @@ -78,16 +78,7 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)connection
return;
}

NSRange range = [responseStr rangeOfString:@"(?<=\\().*(?=\\))" options:NSRegularExpressionSearch];
if (range.location > responseStr.length || range.location + range.length > responseStr.length) {
return;
}

NSString *resultsStr = [responseStr substringWithRange:range];

if (!resultsStr) {
return;
}
NSString *resultsStr = responseStr;

// Parse the JSON into results
NSError *jsonParsingError = nil;
Expand All @@ -96,9 +87,12 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)connection
// Results parsed successfully from JSON
if (results)
{
NSNumber *ticker = [results objectForKey:@"p_new"];
NSDictionary *ticker_resp = [results objectForKey:@"ticker"];
NSNumber *ticker = [ticker_resp objectForKey:@"last"];

if (ticker) {
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
NSString *resultsStatus = [numberFormatter stringFromNumber:ticker];
resultsStatus = [NSString stringWithFormat:@"¥%@", resultsStatus];

Expand Down
Loading

0 comments on commit 2062335

Please sign in to comment.