about summary refs log tree commit diff stats
path: root/src/jid.c
Commit message (Expand)AuthorAgeFilesLines
* Added license exemption for OpenSSL to source headersJames Booth2014-08-241-0/+12
* Fixed cppcheck warningsJames Booth2014-04-261-52/+0
* Updated copyrightJames Booth2014-03-091-1/+1
* most FREE_SET_NULL replaced with freeDmitry Podgorny2013-08-031-7/+7
* separate glib allocator and stdlib malloc/freeDmitry Podgorny2013-07-311-6/+6
* fixed several memory leaks in command.c and jid.cDmitry Podgorny2013-07-311-22/+22
* Added assertsJames Booth2013-02-031-2/+2
* Tidied #include'sJames Booth2013-02-021-1/+2
* Renamed function in jidJames Booth2013-01-271-4/+4
* Renamed create jid function using barejid and resourceJames Booth2013-01-271-1/+1
* Handle NULL in jid_destroy()James Booth2013-01-261-7/+9
* Fixed jid handling to allow @ and / in resourceJames Booth2013-01-261-54/+45
* Removed jid_is_room()James Booth2013-01-131-11/+0
* Use Jid datatype in chat roomsJames Booth2013-01-131-0/+9
* Added jid_destroy()James Booth2013-01-131-0/+12
* fixed memory leak in parse_room_jidDmitry Podgorny2013-01-131-5/+8
* Added jid_create_room_jidJames Booth2013-01-131-0/+12
* Changed Jid typedef to be explicit pointerJames Booth2013-01-131-2/+2
* Added jid datatypeJames Booth2013-01-121-0/+199
revision' href='/akspecs/aerc/blame/worker/worker.go?id=ee73c419507ef74a78ddd6a3466b605cba140b68'>^
b5d5e0d ^
d24e471 ^
6394e38 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28


              

                                               

             
             
                 

 
                                                                       
                                                                          

                                   

                               
                                         
                         

                           
                     


                                                                      
         
                          
 
package worker

import (
	"git.sr.ht/~sircmpwn/aerc/worker/imap"
	"git.sr.ht/~sircmpwn/aerc/worker/types"

	"fmt"
	"log"
	"net/url"
)

// Guesses the appropriate worker type based on the given source string
func NewWorker(source string, logger *log.Logger) (*types.Worker, error) {
	u, err := url.Parse(source)
	if err != nil {
		return nil, err
	}
	worker := types.NewWorker(logger)
	switch u.Scheme {
	case "imap":
		fallthrough
	case "imaps":
		worker.Backend = imap.NewIMAPWorker(worker)
	default:
		return nil, fmt.Errorf("Unknown backend %s", u.Scheme)
	}
	return worker, nil
}