source: trunk/libtransmission/session.h @ 8132

Last change on this file since 8132 was 8132, checked in by charles, 13 years ago

(trunk)

  1. add to the "recently-changed" torrent a list of recently-removed torrent ids.
  2. make the day-of-week alt speed a bitfield of days or'ed together, so that you can have (say) speed limits on monday and wednesday
  • Property svn:keywords set to Date Rev Author Id
File size: 5.9 KB
Line 
1/******************************************************************************
2 * $Id: session.h 8132 2009-04-04 05:29:08Z charles $
3 *
4 * Copyright (c) 2005-2008 Transmission authors and contributors
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *****************************************************************************/
24
25#ifndef __TRANSMISSION__
26#error only libtransmission should #include this header.
27#endif
28
29#ifndef TR_INTERNAL_H
30#define TR_INTERNAL_H 1
31
32#define TR_NAME "Transmission"
33
34#ifndef UNUSED
35 #ifdef __GNUC__
36  #define UNUSED __attribute__ ( ( unused ) )
37 #else
38  #define UNUSED
39 #endif
40#endif
41
42#include "bencode.h"
43
44typedef enum { TR_NET_OK, TR_NET_ERROR, TR_NET_WAIT } tr_tristate_t;
45
46uint8_t*       tr_peerIdNew( void );
47
48const uint8_t* tr_getPeerId( void );
49
50struct tr_metainfo_lookup
51{
52    char    hashString[2 * SHA_DIGEST_LENGTH + 1];
53    char *  filename;
54};
55
56struct tr_address;
57struct tr_bandwidth;
58
59struct tr_session
60{
61    tr_bool                      isPortSet;
62    tr_bool                      isPortRandom;
63    tr_bool                      isPexEnabled;
64    tr_bool                      isBlocklistEnabled;
65    tr_bool                      isProxyEnabled;
66    tr_bool                      isProxyAuthEnabled;
67    tr_bool                      isClosed;
68    tr_bool                      isWaiting;
69    tr_bool                      useLazyBitfield;
70    tr_bool                      isRatioLimited;
71
72    tr_benc                      removedTorrents;
73   
74    int                          speedLimit[2];
75    tr_bool                      speedLimitEnabled[2];
76
77    int                          altSpeed[2];
78    tr_bool                      altSpeedEnabled;
79
80    int                          altSpeedTimeBegin;
81    int                          altSpeedTimeEnd;
82    tr_sched_day                 altSpeedTimeDay;
83    tr_bool                      altSpeedTimeEnabled;
84    tr_bool                      altSpeedChangedByUser;
85
86    tr_altSpeedFunc            * altCallback;
87    void                       * altCallbackUserData;
88
89
90    int                          magicNumber;
91
92    tr_encryption_mode           encryptionMode;
93
94    tr_preallocation_mode        preallocationMode;
95
96    struct tr_event_handle *     events;
97
98    uint16_t                     peerLimitPerTorrent;
99    uint16_t                     openFileLimit;
100
101    int                          uploadSlotsPerTorrent;
102
103    tr_port                      peerPort;
104    tr_port                      randomPortLow;
105    tr_port                      randomPortHigh;
106
107    int                          proxyPort;
108    int                          peerSocketTOS;
109
110    int                          torrentCount;
111    tr_torrent *                 torrentList;
112
113    char *                       tag;
114    char *                       configDir;
115    char *                       downloadDir;
116    char *                       resumeDir;
117    char *                       torrentDir;
118
119    tr_proxy_type                proxyType;
120    char *                       proxy;
121    char *                       proxyUsername;
122    char *                       proxyPassword;
123
124    struct tr_list *             blocklists;
125    struct tr_peerMgr *          peerMgr;
126    struct tr_shared *           shared;
127
128    struct tr_lock *             lock;
129
130    struct tr_web *              web;
131
132    struct tr_rpc_server *       rpcServer;
133    tr_rpc_func                  rpc_func;
134    void *                       rpc_func_user_data;
135
136    struct tr_stats_handle *     sessionStats;
137    struct tr_tracker_handle *   tracker;
138
139    struct tr_metainfo_lookup *  metainfoLookup;
140    int                          metainfoLookupCount;
141
142    struct event               * altTimer;
143
144    /* the size of the output buffer for peer connections */
145    int so_sndbuf;
146
147    /* the size of the input buffer for peer connections */
148    int so_rcvbuf;
149
150    /* monitors the "global pool" speeds */
151    struct tr_bandwidth        * bandwidth;
152
153    double                       desiredRatio;
154};
155
156tr_bool      tr_sessionGetActiveSpeedLimit( const tr_session  * session,
157                                            tr_direction        dir,
158                                            int               * setme );
159
160const char * tr_sessionFindTorrentFile( const tr_session * session,
161                                        const char *       hashString );
162
163void         tr_sessionSetTorrentFile( tr_session * session,
164                                       const char * hashString,
165                                       const char * filename );
166
167tr_bool      tr_sessionIsAddressBlocked( const tr_session        * session,
168                                         const struct tr_address * addr );
169
170void         tr_globalLock( tr_session * );
171
172void         tr_globalUnlock( tr_session * );
173
174tr_bool      tr_globalIsLocked( const tr_session * );
175
176enum
177{
178    SESSION_MAGIC_NUMBER = 3845
179};
180
181static inline tr_bool tr_isSession( const tr_session * session )
182{
183    return ( session != NULL ) && ( session->magicNumber == SESSION_MAGIC_NUMBER );
184}
185
186#endif
Note: See TracBrowser for help on using the repository browser.