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
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
//
// DO NOT EDIT.  THIS FILE IS GENERATED FROM ../../../dist/idl/nsILoginManagerPrompter.idl
//


/// `interface nsILoginManagerPrompter : nsISupports`
///


// The actual type definition for the interface. This struct has methods
// declared on it which will call through its vtable. You never want to pass
// this type around by value, always pass it behind a reference.

#[repr(C)]
pub struct nsILoginManagerPrompter {
    vtable: *const nsILoginManagerPrompterVTable,

    /// This field is a phantomdata to ensure that the VTable type and any
    /// struct containing it is not safe to send across threads, as XPCOM is
    /// generally not threadsafe.
    ///
    /// XPCOM interfaces in general are not safe to send across threads.
    __nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>,
}

// Implementing XpCom for an interface exposes its IID, which allows for easy
// use of the `.query_interface<T>` helper method. This also defines that
// method for nsILoginManagerPrompter.
unsafe impl XpCom for nsILoginManagerPrompter {
    const IID: nsIID = nsID(0x425f73b9, 0xb2db, 0x4e8a,
        [0x88, 0xc5, 0x9a, 0xc2, 0x51, 0x29, 0x34, 0xce]);
}

// We need to implement the RefCounted trait so we can be used with `RefPtr`.
// This trait teaches `RefPtr` how to manage our memory.
unsafe impl RefCounted for nsILoginManagerPrompter {
    #[inline]
    unsafe fn addref(&self) {
        self.AddRef();
    }
    #[inline]
    unsafe fn release(&self) {
        self.Release();
    }
}

// This trait is implemented on all types which can be coerced to from nsILoginManagerPrompter.
// It is used in the implementation of `fn coerce<T>`. We hide it from the
// documentation, because it clutters it up a lot.
#[doc(hidden)]
pub trait nsILoginManagerPrompterCoerce {
    /// Cheaply cast a value of this type from a `nsILoginManagerPrompter`.
    fn coerce_from(v: &nsILoginManagerPrompter) -> &Self;
}

// The trivial implementation: We can obviously coerce ourselves to ourselves.
impl nsILoginManagerPrompterCoerce for nsILoginManagerPrompter {
    #[inline]
    fn coerce_from(v: &nsILoginManagerPrompter) -> &Self {
        v
    }
}

impl nsILoginManagerPrompter {
    /// Cast this `nsILoginManagerPrompter` to one of its base interfaces.
    #[inline]
    pub fn coerce<T: nsILoginManagerPrompterCoerce>(&self) -> &T {
        T::coerce_from(self)
    }
}

// Every interface struct type implements `Deref` to its base interface. This
// causes methods on the base interfaces to be directly avaliable on the
// object. For example, you can call `.AddRef` or `.QueryInterface` directly
// on any interface which inherits from `nsISupports`.
impl ::std::ops::Deref for nsILoginManagerPrompter {
    type Target = nsISupports;
    #[inline]
    fn deref(&self) -> &nsISupports {
        unsafe {
            ::std::mem::transmute(self)
        }
    }
}

// Ensure we can use .coerce() to cast to our base types as well. Any type which
// our base interface can coerce from should be coercable from us as well.
impl<T: nsISupportsCoerce> nsILoginManagerPrompterCoerce for T {
    #[inline]
    fn coerce_from(v: &nsILoginManagerPrompter) -> &Self {
        T::coerce_from(v)
    }
}

// This struct represents the interface's VTable. A pointer to a statically
// allocated version of this struct is at the beginning of every nsILoginManagerPrompter
// object. It contains one pointer field for each method in the interface. In
// the case where we can't generate a binding for a method, we include a void
// pointer.
#[doc(hidden)]
#[repr(C)]
pub struct nsILoginManagerPrompterVTable {
    /// We need to include the members from the base interface's vtable at the start
    /// of the VTable definition.
    pub __base: nsISupportsVTable,

    /* void init (in nsIDOMWindow aWindow); */
    pub Init: unsafe extern "system" fn (this: *const nsILoginManagerPrompter, aWindow: *const nsIDOMWindow) -> nsresult,

    /* attribute nsIDOMElement browser; */
    pub GetBrowser: unsafe extern "system" fn (this: *const nsILoginManagerPrompter, aBrowser: *mut *const nsIDOMElement) -> nsresult,

    /* attribute nsIDOMElement browser; */
    pub SetBrowser: unsafe extern "system" fn (this: *const nsILoginManagerPrompter, aBrowser: *const nsIDOMElement) -> nsresult,

    /* attribute nsIDOMWindow opener; */
    pub GetOpener: unsafe extern "system" fn (this: *const nsILoginManagerPrompter, aOpener: *mut *const nsIDOMWindow) -> nsresult,

    /* attribute nsIDOMWindow opener; */
    pub SetOpener: unsafe extern "system" fn (this: *const nsILoginManagerPrompter, aOpener: *const nsIDOMWindow) -> nsresult,

    /* void promptToSavePassword (in nsILoginInfo aLogin); */
    pub PromptToSavePassword: unsafe extern "system" fn (this: *const nsILoginManagerPrompter, aLogin: *const nsILoginInfo) -> nsresult,

    /* void promptToChangePassword (in nsILoginInfo aOldLogin, in nsILoginInfo aNewLogin); */
    pub PromptToChangePassword: unsafe extern "system" fn (this: *const nsILoginManagerPrompter, aOldLogin: *const nsILoginInfo, aNewLogin: *const nsILoginInfo) -> nsresult,

    /* void promptToChangePasswordWithUsernames ([array, size_is (count)] in nsILoginInfo logins, in uint32_t count, in nsILoginInfo aNewLogin); */
    pub PromptToChangePasswordWithUsernames: unsafe extern "system" fn (this: *const nsILoginManagerPrompter, logins: *mut *const nsILoginInfo, count: uint32_t, aNewLogin: *const nsILoginInfo) -> nsresult,
}


// The implementations of the function wrappers which are exposed to rust code.
// Call these methods rather than manually calling through the VTable struct.
impl nsILoginManagerPrompter {

    /// ```text
    /// /**
    ///    * Initialize the prompter. Must be called before using other interfaces.
    ///    *
    ///    * @param aWindow
    ///    *        The window in which the user is doing some login-related action that's
    ///    *        resulting in a need to prompt them for something. The prompt
    ///    *        will be associated with this window (or, if a notification bar
        ///    *        is being used, topmost opener in some cases).
    ///    *
    ///    *        aWindow can be null if there is no associated window, e.g. in a JSM
    ///    *        or Sandbox. In this case there will be no checkbox to save the login
    ///    *        since the window is needed to know if this is a private context.
    ///    *
    ///    *        If this window is a content window, the corresponding window and browser
    ///    *        elements will be calculated. If this window is a chrome window, the
    ///    *        corresponding browser element needs to be set using setBrowser.
    ///    */
    /// ```
    ///

    /// `void init (in nsIDOMWindow aWindow);`
    #[inline]
    pub unsafe fn Init(&self, aWindow: *const nsIDOMWindow) -> nsresult {
        ((*self.vtable).Init)(self, aWindow)
    }


    /// ```text
    /// /**
    ///    * The browser this prompter is being created for.
    ///    * This is required if the init function received a chrome window as argument.
    ///    */
    /// ```
    ///

    /// `attribute nsIDOMElement browser;`
    #[inline]
    pub unsafe fn GetBrowser(&self, aBrowser: *mut *const nsIDOMElement) -> nsresult {
        ((*self.vtable).GetBrowser)(self, aBrowser)
    }


    /// ```text
    /// /**
    ///    * The browser this prompter is being created for.
    ///    * This is required if the init function received a chrome window as argument.
    ///    */
    /// ```
    ///

    /// `attribute nsIDOMElement browser;`
    #[inline]
    pub unsafe fn SetBrowser(&self, aBrowser: *const nsIDOMElement) -> nsresult {
        ((*self.vtable).SetBrowser)(self, aBrowser)
    }


    /// ```text
    /// /**
    ///    * The opener that was used to open the window passed to init.
    ///    * The opener can be used to determine in which window the prompt
    ///    * should be shown. Must be a content window that is not a frame window,
    ///    * make sure to pass the top window using e.g. window.top.
    ///    */
    /// ```
    ///

    /// `attribute nsIDOMWindow opener;`
    #[inline]
    pub unsafe fn GetOpener(&self, aOpener: *mut *const nsIDOMWindow) -> nsresult {
        ((*self.vtable).GetOpener)(self, aOpener)
    }


    /// ```text
    /// /**
    ///    * The opener that was used to open the window passed to init.
    ///    * The opener can be used to determine in which window the prompt
    ///    * should be shown. Must be a content window that is not a frame window,
    ///    * make sure to pass the top window using e.g. window.top.
    ///    */
    /// ```
    ///

    /// `attribute nsIDOMWindow opener;`
    #[inline]
    pub unsafe fn SetOpener(&self, aOpener: *const nsIDOMWindow) -> nsresult {
        ((*self.vtable).SetOpener)(self, aOpener)
    }


    /// ```text
    /// /**
    ///    * Ask the user if they want to save a login (Yes, Never, Not Now)
    ///    *
    ///    * @param aLogin
    ///    *        The login to be saved.
    ///    */
    /// ```
    ///

    /// `void promptToSavePassword (in nsILoginInfo aLogin);`
    #[inline]
    pub unsafe fn PromptToSavePassword(&self, aLogin: *const nsILoginInfo) -> nsresult {
        ((*self.vtable).PromptToSavePassword)(self, aLogin)
    }


    /// ```text
    /// /**
    ///    * Ask the user if they want to change a login's password or username.
    ///    * If the user consents, modifyLogin() will be called.
    ///    *
    ///    * @param aOldLogin
    ///    *        The existing login (with the old password).
    ///    * @param aNewLogin
    ///    *        The new login.
    ///    */
    /// ```
    ///

    /// `void promptToChangePassword (in nsILoginInfo aOldLogin, in nsILoginInfo aNewLogin);`
    #[inline]
    pub unsafe fn PromptToChangePassword(&self, aOldLogin: *const nsILoginInfo, aNewLogin: *const nsILoginInfo) -> nsresult {
        ((*self.vtable).PromptToChangePassword)(self, aOldLogin, aNewLogin)
    }


    /// ```text
    /// /**
    ///    * Ask the user if they want to change the password for one of
    ///    * multiple logins, when the caller can't determine exactly which
    ///    * login should be changed. If the user consents, modifyLogin() will
    ///    * be called.
    ///    *
    ///    * @param logins
    ///    *        An array of existing logins.
    ///    * @param count
    ///    *        (length of the array)
    ///    * @param aNewLogin
    ///    *        The new login.
    ///    *
    ///    * Note: Because the caller does not know the username of the login
    ///    *       to be changed, aNewLogin.username and aNewLogin.usernameField
    ///    *       will be set (using the user's selection) before modifyLogin()
    ///    *       is called.
    ///    */
    /// ```
    ///

    /// `void promptToChangePasswordWithUsernames ([array, size_is (count)] in nsILoginInfo logins, in uint32_t count, in nsILoginInfo aNewLogin);`
    #[inline]
    pub unsafe fn PromptToChangePasswordWithUsernames(&self, logins: *mut *const nsILoginInfo, count: uint32_t, aNewLogin: *const nsILoginInfo) -> nsresult {
        ((*self.vtable).PromptToChangePasswordWithUsernames)(self, logins, count, aNewLogin)
    }


}