Changeset 5975
- Timestamp:
- May 30, 2008, 3:19:07 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gtk/tr-core.c
r5955 r5975 633 633 if( !isDisposed( core ) ) 634 634 { 635 tr_ torrentRates( core->priv->handle,636 &setme->clientDownloadSpeed,637 &setme->clientUploadSpeed );635 tr_sessionGetSpeed( core->priv->handle, 636 &setme->clientDownloadSpeed, 637 &setme->clientUploadSpeed ); 638 638 639 639 gtk_tree_model_foreach( core->priv->model, -
trunk/gtk/tr-window.c
r5908 r5975 650 650 tr_handle * handle = tr_core_handle( p->core ); 651 651 652 tr_ torrentRates( handle, &d, &u );652 tr_sessionGetSpeed( handle, &d, &u ); 653 653 tr_strlspeed( buf, d, sizeof( buf ) ); 654 654 gtk_label_set_text( GTK_LABEL( p->dl_lb ), buf ); -
trunk/libtransmission/session.c
r5913 r5975 382 382 383 383 void 384 tr_torrentRates( tr_handle * h, float * toClient, float * toPeer ) 385 { 386 if( h ) 387 { 388 tr_globalLock( h ); 389 390 if( toClient ) 391 *toClient = tr_rcRate( h->download ); 392 if( toPeer ) 393 *toPeer = tr_rcRate( h->upload ); 394 395 tr_globalUnlock( h ); 396 } 384 tr_sessionGetSpeed( const tr_handle * session, 385 float * toClient, 386 float * toPeer ) 387 { 388 if( session && toClient ) 389 *toClient = tr_rcRate( session->download ); 390 if( session && toPeer ) 391 *toPeer = tr_rcRate( session->upload ); 397 392 } 398 393 -
trunk/libtransmission/transmission.h
r5969 r5975 23 23 *****************************************************************************/ 24 24 25 /* 26 * This file defines the public API for the libtransmission library. 27 * 28 * Other headers suitable for public consumption are bencode.h 29 * and utils.h. Most of the remaining headers in libtransmission 30 * should be considered private to libtransmission. 31 */ 25 32 #ifndef TR_TRANSMISSION_H 26 33 #define TR_TRANSMISSION_H 1 … … 42 49 43 50 #define SHA_DIGEST_LENGTH 20 51 44 52 #ifdef __BEOS__ 45 53 # include <StorageDefs.h> … … 72 80 typedef struct tr_handle tr_handle; 73 81 typedef struct tr_info tr_info; 74 typedef struct tr_stat tr_stat;75 82 typedef struct tr_torrent tr_torrent; 76 83 … … 88 95 89 96 /** @see tr_sessionInitFull */ 90 #define TR_DEFAULT_CONFIG_DIR 97 #define TR_DEFAULT_CONFIG_DIR tr_getDefaultConfigDir() 91 98 /** @see tr_sessionInitFull */ 92 #define TR_DEFAULT_PEX_ENABLED 99 #define TR_DEFAULT_PEX_ENABLED 1 93 100 /** @see tr_sessionInitFull */ 94 #define TR_DEFAULT_PORT_FORWARDING_ENABLED 101 #define TR_DEFAULT_PORT_FORWARDING_ENABLED 0 95 102 /** @see tr_sessionInitFull */ 96 #define TR_DEFAULT_PORT 103 #define TR_DEFAULT_PORT 51413 97 104 /** @see tr_sessionInitFull */ 98 #define TR_DEFAULT_GLOBAL_PEER_LIMIT 105 #define TR_DEFAULT_GLOBAL_PEER_LIMIT 200 99 106 /** @see tr_sessionInitFull */ 100 #define TR_DEFAULT_PEER_SOCKET_TOS 107 #define TR_DEFAULT_PEER_SOCKET_TOS 8 101 108 /** @see tr_sessionInitFull */ 102 #define TR_DEFAULT_BLOCKLIST_ENABLED 109 #define TR_DEFAULT_BLOCKLIST_ENABLED 0 103 110 /** @see tr_sessionInitFull */ 104 #define TR_DEFAULT_RPC_ENABLED 111 #define TR_DEFAULT_RPC_ENABLED 0 105 112 /** @see tr_sessionInitFull */ 106 #define TR_DEFAULT_RPC_PORT 113 #define TR_DEFAULT_RPC_PORT 9091 107 114 /** @see tr_sessionInitFull */ 108 #define TR_DEFAULT_RPC_PORT_STR 115 #define TR_DEFAULT_RPC_PORT_STR "9091" 109 116 /** @see tr_sessionInitFull */ 110 #define TR_DEFAULT_RPC_ACL 117 #define TR_DEFAULT_RPC_ACL "+127.0.0.1" 111 118 112 119 /** … … 225 232 const char * rpcAccessControlList ); 226 233 227 /** 228 * @brief shorter form of tr_sessionInitFull() 229 * 230 * @deprecated Use tr_sessionInitFull() instead. 231 */ 234 /** @brief Shorter form of tr_sessionInitFull() 235 @deprecated Use tr_sessionInitFull() instead. */ 232 236 tr_handle * tr_sessionInit( const char * configDir, 233 237 const char * downloadDir, 234 238 const char * tag ); 235 239 236 /** 237 * @brief end a libtransmission session 238 * @see tr_sessionInitFull() 239 */ 240 /** @brief End a libtransmission session 241 @see tr_sessionInitFull() */ 240 242 void tr_sessionClose( tr_handle * ); 241 243 242 244 /** 243 * Returns the configuration directory passed into tr_sessionInitFull(). 245 * @brief Return the session's configuration directory 246 * 244 247 * This is where transmission stores its .torrent files, .resume files, 245 248 * blocklists, etc. … … 248 251 249 252 /** 250 * Set the per-session default download folder for new torrents.253 * @brief Set the per-session default download folder for new torrents. 251 254 * @see tr_sessionInitFull() 252 255 * @see tr_sessionGetDownloadDir() … … 255 258 void tr_sessionSetDownloadDir( tr_handle *, const char * downloadDir ); 256 259 257 /** 258 * Get the default download folder for new torrents.260 /** 261 * @brief Get the default download folder for new torrents. 259 262 * 260 263 * This is set by tr_sessionInitFull() or tr_sessionSetDownloadDir(), … … 324 327 tr_rpc_callback_type; 325 328 326 struct tr_torrent;327 328 329 typedef void ( *tr_rpc_func )( tr_handle * handle, 329 330 tr_rpc_callback_type type, … … 415 416 enum { TR_UP, TR_DOWN }; 416 417 418 void tr_sessionGetSpeed( const tr_handle * session, 419 float * overall_down_KiBs, 420 float * overall_up_KiBs ); 421 417 422 int tr_sessionIsSpeedLimitEnabled( const tr_handle * session, 418 423 int up_or_down ); … … 429 434 430 435 uint16_t tr_sessionGetPeerLimit( const tr_handle * handle ); 436 431 437 432 438 /** … … 674 680 @{ */ 675 681 676 /** Iterate through the torrents. 677 Pass in a NULL pointer to get the first torrent. */ 678 tr_torrent* tr_torrentNext( tr_handle *, tr_torrent * ); 679 680 /** Returns this torrent's unique ID. 681 IDs are good as simple lookup keys, but are not persistent 682 between sessions. If you need that, use tr_info.hash or 683 tr_info.hashString. */ 682 /** @brief Frees memory allocated by tr_torrentNew(). 683 Running torrents are stopped first. */ 684 void tr_torrentFree( tr_torrent * ); 685 686 /** @brief Removes our .torrent and .resume files for 687 this torrent, then calls tr_torrentFree(). */ 688 void tr_torrentRemove( tr_torrent * ); 689 690 /** @brief Start a torrent */ 691 void tr_torrentStart( tr_torrent * ); 692 693 /** @brief Stop (pause) a torrent */ 694 void tr_torrentStop( tr_torrent * ); 695 696 /** 697 * @brief Iterate through the torrents. 698 * 699 * Pass in a NULL pointer to get the first torrent. 700 */ 701 tr_torrent* tr_torrentNext( tr_handle * session, tr_torrent * ); 702 703 /** 704 * @brief Returns this torrent's unique ID. 705 * 706 * IDs are good as simple lookup keys, but are not persistent 707 * between sessions. If you need that, use tr_info.hash or 708 * tr_info.hashString. 709 */ 684 710 int tr_torrentId( const tr_torrent * ); 685 711 686 /**** *******************************************************************687 *** Speed Limits688 ** /712 /**** 713 ***** Speed Limits 714 ****/ 689 715 690 716 typedef enum … … 710 736 int up_or_down ); 711 737 712 713 /*********************************************************************** 714 *** Peer Limits 715 **/ 738 /**** 739 ***** Peer Limits 740 ****/ 716 741 717 742 void tr_torrentSetPeerLimit( tr_torrent * tor, … … 720 745 uint16_t tr_torrentGetPeerLimit( const tr_torrent * tor ); 721 746 722 723 /*********************************************************************** 724 * Torrent Priorities 725 **********************************************************************/ 747 /**** 748 ***** File Priorities 749 ****/ 726 750 727 751 enum … … 735 759 736 760 /** 737 * Set a batch of files to a particular priority. 738 * Priority must be one of TR_PRI_NORMAL, _HIGH, or _LOW 761 * @brief Set a batch of files to a particular priority. 762 * 763 * @param priority must be one of TR_PRI_NORMAL, _HIGH, or _LOW 739 764 */ 740 765 void tr_torrentSetFilePriorities( tr_torrent * tor, … … 744 769 745 770 /** 746 * Get this torrent's file priorities.771 * @brief Get this torrent's file priorities. 747 772 * 748 773 * @return A malloc()ed array of tor->info.fileCount items, 749 * each holding a value of TR_PRI_NORMAL, _HIGH, or_LOW.750 * The caller must free() the array when done.774 * each holding a TR_PRI_NORMAL, TR_PRI_HIGH, or TR_PRI_LOW. 775 * It's the caller's responsibility to free() this. 751 776 */ 752 777 tr_priority_t* tr_torrentGetFilePriorities( const tr_torrent * ); 753 778 754 779 /** 755 * Single-file form of tr_torrentGetFilePriorities.756 * returns one of TR_PRI_NORMAL, _HIGH, or_LOW.780 * @brief Single-file form of tr_torrentGetFilePriorities. 781 * @return TR_PRI_NORMAL, TR_PRI_HIGH, or TR_PRI_LOW. 757 782 */ 758 783 tr_priority_t tr_torrentGetFilePriority( const tr_torrent *, … … 760 785 761 786 /** 762 * Returns true if the file's `download' flag is set. 787 * @brief See if a file's `download' flag is set. 788 * @return true if the file's `download' flag is set. 763 789 */ 764 790 int tr_torrentGetFileDL( const tr_torrent *, tr_file_index_t file ); 765 791 766 /** 767 * Set a batch of files to be downloaded or not. 768 */ 792 /** @brief Set a batch of files to be downloaded or not. */ 769 793 void tr_torrentSetFileDLs ( tr_torrent * tor, 770 794 tr_file_index_t * files, … … 772 796 int do_download ); 773 797 774 /***********************************************************************775 * tr_torrentRates776 ***********************************************************************777 * Gets the total download and upload rates778 **********************************************************************/779 void tr_torrentRates( tr_handle *, float *, float * );780 781 782 798 783 799 const tr_info * tr_torrentInfo( const tr_torrent * ); … … 786 802 787 803 const char * tr_torrentGetDownloadDir( const tr_torrent * ); 788 789 void tr_torrentStart( tr_torrent * );790 791 void tr_torrentStop( tr_torrent * );792 804 793 805 … … 840 852 int tr_torrentCanManualUpdate( const tr_torrent * ); 841 853 842 /** Return a pointer to an tr_stat structure with updated information843 on the torrent. This is typically called by the GUI clients every844 second or so to get a new snapshot of the torrent's status. */845 const tr_stat * tr_torrentStat( tr_torrent * );846 847 /** Like tr_torrentStat(), but only recalculates the statistics if it's848 been longer than a second since they were last calculated. This can849 reduce the CPU load if you're calling tr_torrentStat() frequently. */850 const tr_stat * tr_torrentStatCached( tr_torrent * );851 852 854 /*********************************************************************** 853 855 * tr_torrentPeers 854 856 ***********************************************************************/ 855 typedef struct tr_peer_stat tr_peer_stat; 856 tr_peer_stat * tr_torrentPeers( const tr_torrent *, int * peerCount ); 857 void tr_torrentPeersFree( tr_peer_stat *, int peerCount ); 857 858 typedef struct tr_peer_stat 859 { 860 unsigned int isEncrypted : 1; 861 unsigned int isDownloadingFrom : 1; 862 unsigned int isUploadingTo : 1; 863 864 unsigned int peerIsChoked : 1; 865 unsigned int peerIsInterested : 1; 866 unsigned int clientIsChoked : 1; 867 unsigned int clientIsInterested : 1; 868 unsigned int isIncoming : 1; 869 870 uint8_t from; 871 uint16_t port; 872 873 char addr[16]; 874 char client[80]; 875 char flagStr[32]; 876 877 float progress; 878 float downloadFromRate; 879 float uploadToRate; 880 } 881 tr_peer_stat; 882 883 tr_peer_stat * tr_torrentPeers( const tr_torrent * torrent, 884 int * peerCount ); 885 886 void tr_torrentPeersFree( tr_peer_stat * peerStats, 887 int peerCount ); 858 888 859 889 typedef struct tr_file_stat … … 885 915 void tr_torrentVerify( tr_torrent * ); 886 916 887 /**888 * Frees memory allocated by tr_torrentNew().889 * Running torrents are stopped first.890 */891 void tr_torrentFree( tr_torrent * );892 893 /**894 * Removes our .torrent and .resume files for this895 * torrent, then calls tr_torrentFree()896 */897 void tr_torrentRemove( tr_torrent * );898 899 917 /*********************************************************************** 900 918 * tr_info … … 1021 1039 * @see tr_torrentStat() 1022 1040 */ 1023 struct tr_stat1041 typedef struct tr_stat 1024 1042 { 1025 1043 /** The torrent's unique Id. … … 1182 1200 /** The last time we uploaded or downloaded piece data on this torrent. */ 1183 1201 time_t activityDate; 1184 }; 1185 1186 struct tr_peer_stat 1187 { 1188 char addr[16]; 1189 char client[80]; 1190 1191 unsigned int isEncrypted : 1; 1192 unsigned int isDownloadingFrom : 1; 1193 unsigned int isUploadingTo : 1; 1194 1195 unsigned int peerIsChoked : 1; 1196 unsigned int peerIsInterested : 1; 1197 unsigned int clientIsChoked : 1; 1198 unsigned int clientIsInterested : 1; 1199 unsigned int isIncoming : 1; 1200 1201 char flagStr[32]; 1202 1203 uint8_t from; 1204 uint16_t port; 1205 1206 float progress; 1207 float downloadFromRate; 1208 float uploadToRate; 1209 }; 1202 } 1203 tr_stat; 1204 1205 /** Return a pointer to an tr_stat structure with updated information 1206 on the torrent. This is typically called by the GUI clients every 1207 second or so to get a new snapshot of the torrent's status. */ 1208 const tr_stat * tr_torrentStat( tr_torrent * ); 1209 1210 /** Like tr_torrentStat(), but only recalculates the statistics if it's 1211 been longer than a second since they were last calculated. This can 1212 reduce the CPU load if you're calling tr_torrentStat() frequently. */ 1213 const tr_stat * tr_torrentStatCached( tr_torrent * ); 1210 1214 1211 1215 /** @} */ -
trunk/macosx/Badger.m
r5693 r5975 91 91 badgeUpload = [[NSUserDefaults standardUserDefaults] boolForKey: @"BadgeUploadRate"]; 92 92 if (badgeDownload || badgeUpload) 93 tr_ torrentRates(fLib, badgeDownload ? &downloadRate : NULL, badgeUpload ? &uploadRate : NULL);93 tr_sessionGetSpeed(fLib, badgeDownload ? &downloadRate : NULL, badgeUpload ? &uploadRate : NULL); 94 94 95 95 //only update if the badged values change … … 155 155 156 156 float downloadRate, uploadRate; 157 tr_ torrentRates(fLib, &downloadRate, &uploadRate);157 tr_sessionGetSpeed(fLib, &downloadRate, &uploadRate); 158 158 159 159 if (checkDownload && downloadRate >= 0.1) -
trunk/macosx/Controller.m
r5973 r5975 1448 1448 //set rates 1449 1449 float downloadRate, uploadRate; 1450 tr_ torrentRates(fLib, & downloadRate, & uploadRate);1450 tr_sessionGetSpeed(fLib, & downloadRate, & uploadRate); 1451 1451 1452 1452 [fTotalDLField setStringValue: [NSString stringForSpeed: downloadRate]]; -
trunk/wx/speed-stats.cc
r3109 r5975 215 215 // add a new record 216 216 float allUp, allDown; 217 tr_ torrentRates( handle, &allDown, &allUp );217 tr_sessionGetSpeed( handle, &allDown, &allUp ); 218 218 Speed s; 219 219 s.time = time( NULL ); -
trunk/wx/xmission.cc
r5908 r5975 470 470 471 471 float down, up; 472 tr_ torrentRates( handle, &down, &up );472 tr_sessionGetSpeed( handle, &down, &up ); 473 473 wxString xstr = _("Total DL: "); 474 474 xstr += getReadableSpeed( down );
Note: See TracChangeset
for help on using the changeset viewer.