Objectively 1.0.0
Ultra-lightweight object oriented framework for GNU C.
URLSessionTask.h
Go to the documentation of this file.
1/*
2 * Objectively: Ultra-lightweight object oriented framework for GNU C.
3 * Copyright (C) 2014 Jay Dolan <jay@jaydolan.com>
4 *
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 *
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
12 *
13 * 1. The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software
15 * in a product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
17 *
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
20 *
21 * 3. This notice may not be removed or altered from any source distribution.
22 */
23
24#pragma once
25
26#include <Objectively/Object.h>
27#include <Objectively/Thread.h>
28
34typedef struct URLSessionTask URLSessionTask;
35typedef struct URLSessionTaskInterface URLSessionTaskInterface;
36
42
48typedef void (*URLSessionTaskCompletion)(URLSessionTask *task, _Bool success);
49
53typedef enum {
62
69
74
79 URLSessionTaskInterface *interface;
80
84 struct {
89
94 } locals;
95
100
105
110
114 size_t bytesSent;
115
120
125
129 char *error;
130
135
140
145
150
155};
156
160struct URLSessionTaskInterface {
161
165 ObjectInterface objectInterface;
166
173 void (*cancel)(URLSessionTask *self);
174
182 void (*execute)(URLSessionTask *self);
183
194 URLSessionTask *(*initWithRequestInSession)(URLSessionTask *self, struct URLRequest *request,
195 struct URLSession *session, URLSessionTaskCompletion completion);
196
203 void (*resume)(URLSessionTask *self);
204
212 void (*setup)(URLSessionTask *self);
213
220 void (*suspend)(URLSessionTask *self);
221
229 void (*teardown)(URLSessionTask *self);
230};
231
static void teardown(void)
Called atexit to teardown Objectively.
Definition: Class.c:47
static void setup(void)
Called when initializing Object to setup Objectively.
Definition: Class.c:78
Object is the root Class of The Objectively Class hierarchy.
static void cancel(Operation *self)
Definition: Operation.c:74
POSIX Threads.
void * ident
The identity type, similar to Objective-C id.
Definition: Types.h:49
#define OBJECTIVELY_EXPORT
Definition: Types.h:36
static void resume(URLSessionTask *self)
static void execute(URLSessionTask *self)
static void suspend(URLSessionTask *self)
void(* URLSessionTaskProgress)(URLSessionTask *task)
A function pointer for URLSessionTask progress.
URLSessionTaskState
The various states a URLSessionTask may be in.
@ URLSESSIONTASK_RESUMING
@ URLSESSIONTASK_CANCELED
@ URLSESSIONTASK_SUSPENDING
@ URLSESSIONTASK_SUSPENDED
@ URLSESSIONTASK_COMPLETED
@ URLSESSIONTASK_RESUMED
@ URLSESSIONTASK_CANCELING
void(* URLSessionTaskCompletion)(URLSessionTask *task, _Bool success)
A function pointer for URLSessionTask completion.
The runtime representation of a Class.
Definition: Class.h:95
Object is the root Class of The Objectively Class hierarchy.
Definition: Object.h:46
A protocol-agnostic abstraction for requesting resources via URLs.
Definition: URLRequest.h:56
A protocol-agnostic abstraction for URLSessionTask responses.
Definition: URLResponse.h:42
A management context for loading resources via URLs.
Definition: URLSession.h:57
URL session tasks are handles to pending URL operations.
struct URLResponse * response
The response.
ident requestHeaders
HTTP headers, in libcurl list structure.
ident handle
The backing libcurl handle.
URLSessionTaskProgress progress
The progress function.
size_t bytesExpectedToSend
The count of bytes this task expects to send.
ident data
User data.
Object object
The superclass.
char * error
The error buffer.
Class * _URLSessionTask(void)
The URLSessionTask archetype.
struct URLRequest * request
The request.
size_t bytesReceived
The count of bytes received.
struct URLSession * session
The session.
URLSessionTaskInterface * interface
The interface.
URLSessionTaskState state
The state.
URLSessionTaskCompletion completion
The completion function.
size_t bytesSent
The count of bytes sent.
size_t bytesExpectedToReceive
The count of bytes this task expects to receive.