github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/protocol/keybase1/incoming-share.go (about)

     1  // Auto-generated to Go types and interfaces using avdl-compiler v1.4.10 (https://github.com/keybase/node-avdl-compiler)
     2  //   Input file: avdl/keybase1/incoming-share.avdl
     3  
     4  package keybase1
     5  
     6  import (
     7  	"fmt"
     8  	"github.com/keybase/go-framed-msgpack-rpc/rpc"
     9  	context "golang.org/x/net/context"
    10  	"time"
    11  )
    12  
    13  type IncomingShareType int
    14  
    15  const (
    16  	IncomingShareType_FILE  IncomingShareType = 0
    17  	IncomingShareType_TEXT  IncomingShareType = 1
    18  	IncomingShareType_IMAGE IncomingShareType = 2
    19  	IncomingShareType_VIDEO IncomingShareType = 3
    20  )
    21  
    22  func (o IncomingShareType) DeepCopy() IncomingShareType { return o }
    23  
    24  var IncomingShareTypeMap = map[string]IncomingShareType{
    25  	"FILE":  0,
    26  	"TEXT":  1,
    27  	"IMAGE": 2,
    28  	"VIDEO": 3,
    29  }
    30  
    31  var IncomingShareTypeRevMap = map[IncomingShareType]string{
    32  	0: "FILE",
    33  	1: "TEXT",
    34  	2: "IMAGE",
    35  	3: "VIDEO",
    36  }
    37  
    38  func (e IncomingShareType) String() string {
    39  	if v, ok := IncomingShareTypeRevMap[e]; ok {
    40  		return v
    41  	}
    42  	return fmt.Sprintf("%v", int(e))
    43  }
    44  
    45  type IncomingShareItem struct {
    46  	Type          IncomingShareType `codec:"type" json:"type"`
    47  	OriginalPath  *string           `codec:"originalPath,omitempty" json:"originalPath,omitempty"`
    48  	OriginalSize  *int              `codec:"originalSize,omitempty" json:"originalSize,omitempty"`
    49  	ScaledPath    *string           `codec:"scaledPath,omitempty" json:"scaledPath,omitempty"`
    50  	ScaledSize    *int              `codec:"scaledSize,omitempty" json:"scaledSize,omitempty"`
    51  	ThumbnailPath *string           `codec:"thumbnailPath,omitempty" json:"thumbnailPath,omitempty"`
    52  	Content       *string           `codec:"content,omitempty" json:"content,omitempty"`
    53  }
    54  
    55  func (o IncomingShareItem) DeepCopy() IncomingShareItem {
    56  	return IncomingShareItem{
    57  		Type: o.Type.DeepCopy(),
    58  		OriginalPath: (func(x *string) *string {
    59  			if x == nil {
    60  				return nil
    61  			}
    62  			tmp := (*x)
    63  			return &tmp
    64  		})(o.OriginalPath),
    65  		OriginalSize: (func(x *int) *int {
    66  			if x == nil {
    67  				return nil
    68  			}
    69  			tmp := (*x)
    70  			return &tmp
    71  		})(o.OriginalSize),
    72  		ScaledPath: (func(x *string) *string {
    73  			if x == nil {
    74  				return nil
    75  			}
    76  			tmp := (*x)
    77  			return &tmp
    78  		})(o.ScaledPath),
    79  		ScaledSize: (func(x *int) *int {
    80  			if x == nil {
    81  				return nil
    82  			}
    83  			tmp := (*x)
    84  			return &tmp
    85  		})(o.ScaledSize),
    86  		ThumbnailPath: (func(x *string) *string {
    87  			if x == nil {
    88  				return nil
    89  			}
    90  			tmp := (*x)
    91  			return &tmp
    92  		})(o.ThumbnailPath),
    93  		Content: (func(x *string) *string {
    94  			if x == nil {
    95  				return nil
    96  			}
    97  			tmp := (*x)
    98  			return &tmp
    99  		})(o.Content),
   100  	}
   101  }
   102  
   103  type IncomingShareCompressPreference int
   104  
   105  const (
   106  	IncomingShareCompressPreference_ORIGINAL   IncomingShareCompressPreference = 0
   107  	IncomingShareCompressPreference_COMPRESSED IncomingShareCompressPreference = 1
   108  )
   109  
   110  func (o IncomingShareCompressPreference) DeepCopy() IncomingShareCompressPreference { return o }
   111  
   112  var IncomingShareCompressPreferenceMap = map[string]IncomingShareCompressPreference{
   113  	"ORIGINAL":   0,
   114  	"COMPRESSED": 1,
   115  }
   116  
   117  var IncomingShareCompressPreferenceRevMap = map[IncomingShareCompressPreference]string{
   118  	0: "ORIGINAL",
   119  	1: "COMPRESSED",
   120  }
   121  
   122  func (e IncomingShareCompressPreference) String() string {
   123  	if v, ok := IncomingShareCompressPreferenceRevMap[e]; ok {
   124  		return v
   125  	}
   126  	return fmt.Sprintf("%v", int(e))
   127  }
   128  
   129  type IncomingSharePreference struct {
   130  	CompressPreference IncomingShareCompressPreference `codec:"compressPreference" json:"compressPreference"`
   131  }
   132  
   133  func (o IncomingSharePreference) DeepCopy() IncomingSharePreference {
   134  	return IncomingSharePreference{
   135  		CompressPreference: o.CompressPreference.DeepCopy(),
   136  	}
   137  }
   138  
   139  type GetIncomingShareItemsArg struct {
   140  }
   141  
   142  type GetPreferenceArg struct {
   143  }
   144  
   145  type SetPreferenceArg struct {
   146  	Preference IncomingSharePreference `codec:"preference" json:"preference"`
   147  }
   148  
   149  type IncomingShareInterface interface {
   150  	GetIncomingShareItems(context.Context) ([]IncomingShareItem, error)
   151  	GetPreference(context.Context) (IncomingSharePreference, error)
   152  	SetPreference(context.Context, IncomingSharePreference) error
   153  }
   154  
   155  func IncomingShareProtocol(i IncomingShareInterface) rpc.Protocol {
   156  	return rpc.Protocol{
   157  		Name: "keybase.1.incomingShare",
   158  		Methods: map[string]rpc.ServeHandlerDescription{
   159  			"getIncomingShareItems": {
   160  				MakeArg: func() interface{} {
   161  					var ret [1]GetIncomingShareItemsArg
   162  					return &ret
   163  				},
   164  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   165  					ret, err = i.GetIncomingShareItems(ctx)
   166  					return
   167  				},
   168  			},
   169  			"getPreference": {
   170  				MakeArg: func() interface{} {
   171  					var ret [1]GetPreferenceArg
   172  					return &ret
   173  				},
   174  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   175  					ret, err = i.GetPreference(ctx)
   176  					return
   177  				},
   178  			},
   179  			"setPreference": {
   180  				MakeArg: func() interface{} {
   181  					var ret [1]SetPreferenceArg
   182  					return &ret
   183  				},
   184  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
   185  					typedArgs, ok := args.(*[1]SetPreferenceArg)
   186  					if !ok {
   187  						err = rpc.NewTypeError((*[1]SetPreferenceArg)(nil), args)
   188  						return
   189  					}
   190  					err = i.SetPreference(ctx, typedArgs[0].Preference)
   191  					return
   192  				},
   193  			},
   194  		},
   195  	}
   196  }
   197  
   198  type IncomingShareClient struct {
   199  	Cli rpc.GenericClient
   200  }
   201  
   202  func (c IncomingShareClient) GetIncomingShareItems(ctx context.Context) (res []IncomingShareItem, err error) {
   203  	err = c.Cli.Call(ctx, "keybase.1.incomingShare.getIncomingShareItems", []interface{}{GetIncomingShareItemsArg{}}, &res, 0*time.Millisecond)
   204  	return
   205  }
   206  
   207  func (c IncomingShareClient) GetPreference(ctx context.Context) (res IncomingSharePreference, err error) {
   208  	err = c.Cli.Call(ctx, "keybase.1.incomingShare.getPreference", []interface{}{GetPreferenceArg{}}, &res, 0*time.Millisecond)
   209  	return
   210  }
   211  
   212  func (c IncomingShareClient) SetPreference(ctx context.Context, preference IncomingSharePreference) (err error) {
   213  	__arg := SetPreferenceArg{Preference: preference}
   214  	err = c.Cli.Call(ctx, "keybase.1.incomingShare.setPreference", []interface{}{__arg}, nil, 0*time.Millisecond)
   215  	return
   216  }