text:
#include "dshow.h"

#include <stddef.h>
#define imemoffset offsetof(libAVPin, imemvtbl)

DECLARE_QUERYINTERFACE(libAVPin,
    { {&IID_IUnknown,0}, {&IID_IPin,0}, {&IID_IMemInputPin,imemoffset} })
DECLARE_ADDREF(libAVPin)
DECLARE_RELEASE(libAVPin)

long WINAPI
libAVPin_Connect(libAVPin *this, IPin *pin, const AM_MEDIA_TYPE *type)
{
    dshowdebug("libAVPin_Connect(%p, %p, %p)\n", this, pin, type);
    /* Input pins receive connections. */
    return S_FALSE;
}
long WINAPI
libAVPin_ReceiveConnection(libAVPin *this, IPin *pin,
                           const AM_MEDIA_TYPE *type)
{
    enum dshowDeviceType devtype = this->filter->type;
    dshowdebug("libAVPin_ReceiveConnection(%p)\n", this);

    if (!pin)
        return E_POINTER;
    if (this->connectedto)
        return VFW_E_ALREADY_CONNECTED;

    ff_print_AM_MEDIA_TYPE(type);
    if (devtype == VideoDevice) {
        if (!IsEqualGUID(&type->majortype, &MEDIATYPE_Video))
            return VFW_E_TYPE_NOT_ACCEPTED;
    } else {
        if (!IsEqualGUID(&type->majortype, &MEDIATYPE_Audio))
            return VFW_E_TYPE_NOT_ACCEPTED;
    }

    IPin_AddRef(pin);
    this->connectedto = pin;

    ff_copy_dshow_media_type(&this->type, type);

    return S_OK;
}
long WINAPI
libAVPin_Disconnect(libAVPin *this)
{
    dshowdebug("libAVPin_Disconnect(%p)\n", this);

    if (this->filter->state != State_Stopped)
        return VFW_E_NOT_STOPPED;
    if (!this->connectedto)
        return S_FALSE;
    this->connectedto = NULL;

    return S_OK;
}
long WINAPI
libAVPin_ConnectedTo(libAVPin *this, IPin **pin)
{
    dshowdebug("libAVPin_ConnectedTo(%p)\n", this);

    if (!pin)
        return E_POINTER;
    if (!this->connectedto)
        return VFW_E_NOT_CONNECTED;
    IPin_AddRef(this->connectedto);
    *pin = this->connectedto;

    return S_OK;
}
long WINAPI
libAVPin_ConnectionMediaType(libAVPin *this, AM_MEDIA_TYPE *type)
{
    dshowdebug("libAVPin_ConnectionMediaType(%p)\n", this);

    if (!type)
        return E_POINTER;
    if (!this->connectedto)
        return VFW_E_NOT_CONNECTED;

    return ff_copy_dshow_media_type(type, &this->type);
}
long WINAPI
libAVPin_QueryPinInfo(libAVPin *this, PIN_INFO *info)
{
    dshowdebug("libAVPin_QueryPinInfo(%p)\n", this);

    if (!info)
        return E_POINTER;

    if (this->filter)
        libAVFilter_AddRef(this->filter);

    info->pFilter = (IBaseFilter *) this->filter;
    info->dir     = PINDIR_INPUT;
    wcscpy(info->achName, L"Capture");

    return S_OK;
}
long WINAPI
libAVPin_QueryDirection(libAVPin *this, PIN_DIRECTION *dir)
{
    dshowdebug("libAVPin_QueryDirection(%p)\n", this);
    if (!dir)
        return E_POINTER;
    *dir = PINDIR_INPUT;
    return S_OK;
}
long WINAPI
libAVPin_QueryId(libAVPin *this, wchar_t **id)
{
    dshowdebug("libAVPin_QueryId(%p)\n", this);

    if (!id)
        return E_POINTER;

    *id = wcsdup(L"libAV Pin");

    return S_OK;
}
long WINAPI
libAVPin_QueryAccept(libAVPin *this, const AM_MEDIA_TYPE *type)
{
    dshowdebug("libAVPin_QueryAccept(%p)\n", this);
    return S_FALSE;
}
long WINAPI
libAVPin_EnumMediaTypes(libAVPin *this, IEnumMediaTypes **enumtypes)
{
    const AM_MEDIA_TYPE *type = NULL;
    libAVEnumMediaTypes *new;
    dshowdebug("libAVPin_EnumMediaTypes(%p)\n", this);

    if (!enumtypes)
        return E_POINTER;
    new = libAVEnumMediaTypes_Create(type);
    if (!new)
        return E_OUTOFMEMORY;

    *enumtypes = (IEnumMediaTypes *) new;
    return S_OK;
}
long WINAPI
libAVPin_QueryInternalConnections(libAVPin *this, IPin **pin,
                                  unsigned long *npin)
{
    dshowdebug("libAVPin_QueryInternalConnections(%p)\n", this);
    return E_NOTIMPL;
}
long WINAPI
libAVPin_EndOfStream(libAVPin *this)
{
    dshowdebug("libAVPin_EndOfStream(%p)\n", this);
    /* I don't care. */
    return S_OK;
}
long WINAPI
libAVPin_BeginFlush(libAVPin *this)
{
    dshowdebug("libAVPin_BeginFlush(%p)\n", this);
    /* I don't care. */
    return S_OK;
}
long WINAPI
libAVPin_EndFlush(libAVPin *this)
{
    dshowdebug("libAVPin_EndFlush(%p)\n", this);
    /* I don't care. */
    return S_OK;
}
long WINAPI
libAVPin_NewSegment(libAVPin *this, REFERENCE_TIME start, REFERENCE_TIME stop,
                    double rate)
{
    dshowdebug("libAVPin_NewSegment(%p)\n", this);
    /* I don't care. */
    return S_OK;
}

static int
libAVPin_Setup(libAVPin *this, libAVFilter *filter)
{
    IPinVtbl *vtbl = this->vtbl;
    IMemInputPinVtbl *imemvtbl;

    if (!filter)
        return 0;

    imemvtbl = av_malloc(sizeof(IMemInputPinVtbl));
    if (!imemvtbl)
        return 0;

    SETVTBL(imemvtbl, libAVMemInputPin, QueryInterface);
    SETVTBL(imemvtbl, libAVMemInputPin, AddRef);
    SETVTBL(imemvtbl, libAVMemInputPin, Release);
    SETVTBL(imemvtbl, libAVMemInputPin, GetAllocator);
    SETVTBL(imemvtbl, libAVMemInputPin, NotifyAllocator);
    SETVTBL(imemvtbl, libAVMemInputPin, GetAllocatorRequirements);
    SETVTBL(imemvtbl, libAVMemInputPin, Receive);
    SETVTBL(imemvtbl, libAVMemInputPin, ReceiveMultiple);
    SETVTBL(imemvtbl, libAVMemInputPin, ReceiveCanBlock);

    this->imemvtbl = imemvtbl;

    SETVTBL(vtbl, libAVPin, QueryInterface);
    SETVTBL(vtbl, libAVPin, AddRef);
    SETVTBL(vtbl, libAVPin, Release);
    SETVTBL(vtbl, libAVPin, Connect);
    SETVTBL(vtbl, libAVPin, ReceiveConnection);
    SETVTBL(vtbl, libAVPin, Disconnect);
    SETVTBL(vtbl, libAVPin, ConnectedTo);
    SETVTBL(vtbl, libAVPin, ConnectionMediaType);
    SETVTBL(vtbl, libAVPin, QueryPinInfo);
    SETVTBL(vtbl, libAVPin, QueryDirection);
    SETVTBL(vtbl, libAVPin, QueryId);
    SETVTBL(vtbl, libAVPin, QueryAccept);
    SETVTBL(vtbl, libAVPin, EnumMediaTypes);
    SETVTBL(vtbl, libAVPin, QueryInternalConnections);
    SETVTBL(vtbl, libAVPin, EndOfStream);
    SETVTBL(vtbl, libAVPin, BeginFlush);
    SETVTBL(vtbl, libAVPin, EndFlush);
    SETVTBL(vtbl, libAVPin, NewSegment);

    this->filter = filter;

    return 1;
}
DECLARE_CREATE(libAVPin, libAVPin_Setup(this, filter), libAVFilter *filter)
DECLARE_DESTROY(libAVPin, nothing)

/*****************************************************************************
 * libAVMemInputPin
 ****************************************************************************/
long WINAPI
libAVMemInputPin_QueryInterface(libAVMemInputPin *this, const GUID *riid,
                                void **ppvObject)
{
    libAVPin *pin = (libAVPin *) ((uint8_t *) this - imemoffset);
    dshowdebug("libAVMemInputPin_QueryInterface(%p)\n", this);
    return libAVPin_QueryInterface(pin, riid, ppvObject);
}
unsigned long WINAPI
libAVMemInputPin_AddRef(libAVMemInputPin *this)
{
    libAVPin *pin = (libAVPin *) ((uint8_t *) this - imemoffset);
    dshowdebug("libAVMemInputPin_AddRef(%p)\n", this);
    return libAVPin_AddRef(pin);
}
unsigned long WINAPI
libAVMemInputPin_Release(libAVMemInputPin *this)
{
    libAVPin *pin = (libAVPin *) ((uint8_t *) this - imemoffset);
    dshowdebug("libAVMemInputPin_Release(%p)\n", this);
    return libAVPin_Release(pin);
}
long WINAPI
libAVMemInputPin_GetAllocator(libAVMemInputPin *this, IMemAllocator **alloc)
{
    dshowdebug("libAVMemInputPin_GetAllocator(%p)\n", this);
    return VFW_E_NO_ALLOCATOR;
}
long WINAPI
libAVMemInputPin_NotifyAllocator(libAVMemInputPin *this, IMemAllocator *alloc,
                                 WINBOOL rdwr)
{
    dshowdebug("libAVMemInputPin_NotifyAllocator(%p)\n", this);
    return S_OK;
}
long WINAPI
libAVMemInputPin_GetAllocatorRequirements(libAVMemInputPin *this,
                                          ALLOCATOR_PROPERTIES *props)
{
    dshowdebug("libAVMemInputPin_GetAllocatorRequirements(%p)\n", this);
    return E_NOTIMPL;
}
long WINAPI
libAVMemInputPin_Receive(libAVMemInputPin *this, IMediaSample *sample)
{
    libAVPin *pin = (libAVPin *) ((uint8_t *) this - imemoffset);
    enum dshowDeviceType devtype = pin->filter->type;
    void *priv_data;
    uint8_t *buf;
    int buf_size;
    int index;
    int64_t curtime;

    dshowdebug("libAVMemInputPin_Receive(%p)\n", this);

    if (!sample)
        return E_POINTER;

    if (devtype == VideoDevice) {
        /* PTS from video devices is unreliable. */
        IReferenceClock *clock = pin->filter->clock;
        IReferenceClock_GetTime(clock, &curtime);
    } else {
        int64_t dummy;
        IMediaSample_GetTime(sample, &curtime, &dummy);
        curtime += pin->filter->start_time;
    }

    buf_size = IMediaSample_GetActualDataLength(sample);
    IMediaSample_GetPointer(sample, &buf);
    priv_data = pin->filter->priv_data;
    index = pin->filter->stream_index;

    pin->filter->callback(priv_data, index, buf, buf_size, curtime);

    return S_OK;
}
long WINAPI
libAVMemInputPin_ReceiveMultiple(libAVMemInputPin *this,
                                 IMediaSample **samples, long n, long *nproc)
{
    int i;
    dshowdebug("libAVMemInputPin_ReceiveMultiple(%p)\n", this);

    for (i = 0; i < n; i++)
        libAVMemInputPin_Receive(this, samples[i]);

    *nproc = n;
    return S_OK;
}
long WINAPI
libAVMemInputPin_ReceiveCanBlock(libAVMemInputPin *this)
{
    dshowdebug("libAVMemInputPin_ReceiveCanBlock(%p)\n", this);
    /* I swear I will not block. */
    return S_FALSE;
}

void
libAVMemInputPin_Destroy(libAVMemInputPin *this)
{
    libAVPin *pin = (libAVPin *) ((uint8_t *) this - imemoffset);
    dshowdebug("libAVMemInputPin_Destroy(%p)\n", this);
    return libAVPin_Destroy(pin);
}


text:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.messages = exports.ruleName = undefined;

exports.default = function (expectation, options) {
  return function (root, result) {
    var validOptions = (0, _utils.validateOptions)(result, ruleName, {
      actual: expectation,
      possible: ["always", "never"]
    }, {
      actual: options,
      possible: {
        except: ["all-nested", "blockless-after-same-name-blockless", "blockless-group", "first-nested"],
        ignore: ["after-comment", "all-nested", "blockless-after-same-name-blockless", "blockless-group"],
        ignoreAtRules: [_lodash.isString]
      },
      optional: true
    });
    if (!validOptions) {
      return;
    }

    root.walkAtRules(function (atRule) {

      // Ignore the first node
      if (atRule === root.first) {
        return;
      }

      // Return early if at-rule is to be ignored
      if ((0, _utils.optionsHaveIgnoredAtRule)(options, atRule)) {
        return;
      }

      // Optionally ignore the expectation if the node is blockless
      if ((0, _utils.optionsHaveIgnored)(options, "blockless-group") && !(0, _utils.hasBlock)(atRule)) {
        return;
      }

      var isNested = atRule.parent !== root;
      var previousNode = atRule.prev();

      // Optionally ignore the expection if the node is blockless
      // and following another blockless at-rule with the same name
      if ((0, _utils.optionsHaveIgnored)(options, "blockless-after-same-name-blockless") && isBlocklessAfterSameNameBlockless()) {
        return;
      }

      // Optionally ignore the expectation if the node is nested
      if ((0, _utils.optionsHaveIgnored)(options, "all-nested") && isNested) {
        return;
      }

      // Optionally ignore the expectation if a comment precedes this node
      if ((0, _utils.optionsHaveIgnored)(options, "after-comment") && isAfterComment()) {
        return;
      }

      var hasEmptyLineBefore = (0, _utils.hasEmptyLine)(atRule.raw("before"));
      var expectEmptyLineBefore = expectation === "always" ? true : false;

      // Optionally reverse the expectation if any exceptions apply
      if ((0, _utils.optionsHaveException)(options, "all-nested") && isNested || (0, _utils.optionsHaveException)(options, "first-nested") && isFirstNested() || (0, _utils.optionsHaveException)(options, "blockless-group") && isBlocklessAfterBlockless() || (0, _utils.optionsHaveException)(options, "blockless-after-same-name-blockless") && isBlocklessAfterSameNameBlockless()) {
        expectEmptyLineBefore = !expectEmptyLineBefore;
      }

      // Return if the expectation is met
      if (expectEmptyLineBefore === hasEmptyLineBefore) {
        return;
      }

      var message = expectEmptyLineBefore ? messages.expected : messages.rejected;

      (0, _utils.report)({
        message: message,
        node: atRule,
        result: result,
        ruleName: ruleName
      });

      function isAfterComment() {
        return previousNode && previousNode.type === "comment";
      }

      function isBlocklessAfterBlockless() {
        return previousNode && previousNode.type === "atrule" && !(0, _utils.hasBlock)(previousNode) && !(0, _utils.hasBlock)(atRule);
      }

      function isBlocklessAfterSameNameBlockless() {
        return !(0, _utils.hasBlock)(atRule) && previousNode && !(0, _utils.hasBlock)(previousNode) && previousNode.type === "atrule" && previousNode.name == atRule.name;
      }

      function isFirstNested() {
        return isNested && atRule === atRule.parent.first;
      }
    });
  };
};

var _utils = require("../../utils");

var _lodash = require("lodash");

var ruleName = exports.ruleName = "at-rule-empty-line-before";

var messages = exports.messages = (0, _utils.ruleMessages)(ruleName, {
  expected: "Expected empty line before at-rule",
  rejected: "Unexpected empty line before at-rule"
});

redpajama_set_name: RedPajamaGithub


text:
import AppActions from "./RichAppActions";
import CarbonActions, { CarbonAction } from "./CarbonActions"
import { handles, CarbonStore, Dispatcher, dispatch } from './CarbonFlux';
import RichPanelConfig from './RichPanelConfig';
import LayoutActions from './layout/LayoutActions';
import { Selection, app, CommandManager, IDisposable, backend, WorkspaceTool, PreviewDisplayMode } from "carbon-core";
import { ProjectAvatars } from "./Constants";

type AppStoreState = {
    mainMenuVisible: boolean;
    frameVisible: boolean;
    activeTool: string;
    canUndo: boolean;
    canRedo: boolean;
    selectionCount: number;
    scale: number;
    activeMode: string;
    loaded: boolean;
    appName: string;
    appAvatar: string;
    prototypeMode:string;
}

class AppStore extends CarbonStore<AppStoreState> {
    private scaleChangedToken: IDisposable;

    constructor() {
        super();

        this.state = {
            mainMenuVisible: false,
            frameVisible: false,
            activeTool: "pointerTool",
            canUndo: false,
            canRedo: false,
            selectionCount: 0,
            scale: 1,
            activeMode: 'edit',
            prototypeMode: "visual",
            loaded: false,
            appName: app.props.name,
            appAvatar: app.props.avatar
        };
    }

    onAction(action: CarbonAction) {
        super.onAction(action);

        switch (action.type) {
            case "Carbon_Selection":
                this.onSelectionChanged();
                return;
            case "Carbon_PrototypeMode":
                this.setState({prototypeMode:action.mode});
                return;
            case "Carbon_AppSettingsChanged":
                this.setState({ appName: action.settings.name, appAvatar: action.settings.avatar });
                return;
            case "Carbon_ScaleChanged":
                this.setState({ scale: action.scale });
                return;
            case "Carbon_AppUpdated":
                this.setState({ appName: app.name() });
                return;
        }
    }

    @handles(AppActions.canUndoRedo)
    onCanUndo({ canUndo, canRedo }) {
        this.setState({ canUndo, canRedo });
    }

    onSelectionChanged() {
        this.setState({ selectionCount: Selection.elements.length });
    }

    _switchMode(mode) {
        this.setState({ activeMode: mode });

        // if (mode === "edit") {
        //     Workspace.controller.resetCurrentTool();
        // }
        // else if (mode === "prototype") {
        //     app.actionManager.invoke("protoTool" as WorkspaceTool);
        // }

        dispatch(LayoutActions.setLayout(mode, RichPanelConfig[mode]));
    }

    @handles(CarbonActions.loaded)
    onLoaded(action) {
        if (app.props.avatar === null) {
            app.setProps({ avatar: this.getRandomAvatarUrl() });
        }

        this.setState({ loaded: true });
    }

    getRandomAvatarUrl() {
        let id = (Math.random() * ProjectAvatars) % ProjectAvatars | 0;
        return backend.cdnEndpoint + `/img/ava/project-${id}.png`;
    }

    @handles(CarbonActions.modeChanged)
    onModeChanged({ mode }) {
        this._switchMode(mode);
    }

    @handles(CarbonActions.toolChanged)
    onToolChanged({ tool }) {
        this.setState({ activeTool: tool });
    }

    // @handles(AppActions.showMainMenu)
    // onShowMenu() {
    //     this.setState({mainMenuVisible: true});
    // }
    //
    // @handles(AppActions.hideMainMenu)
    // onHideMenu() {
    //     this.setState({mainMenuVisible: false});
    // }

    @handles(AppActions.switchFrameState)
    switchFrameState({ frameVisible }) {
        // this.setState({frameVisible: frameVisible});
        // if (this.app) {
        //     this.app.activePage.isPhoneVisible(frameVisible);
        // }
    }
}

export default new AppStore();


text:
package com.thebluealliance.androidclient.fragments;

import com.google.android.gms.analytics.Tracker;
import com.thebluealliance.androidclient.BaseTestActivity;
import com.thebluealliance.androidclient.DefaultTestRunner;
import com.thebluealliance.androidclient.binders.NoDataBinder;
import com.thebluealliance.androidclient.datafeed.refresh.RefreshController;
import com.thebluealliance.androidclient.datafeed.status.TBAStatusController;
import com.thebluealliance.androidclient.fragments.framework.BaseFragmentTest;
import com.thebluealliance.androidclient.fragments.framework.DatafeedFragmentTestController;
import com.thebluealliance.androidclient.fragments.framework.FragmentTestDriver;
import com.thebluealliance.androidclient.fragments.framework.SimpleBinder;
import com.thebluealliance.androidclient.fragments.framework.SimpleDatafeedFragment;
import com.thebluealliance.androidclient.fragments.framework.SimpleSubscriber;

import org.greenrobot.eventbus.EventBus;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import rx.subjects.PublishSubject;
import rx.subjects.SerializedSubject;
import rx.subjects.Subject;

import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;

@RunWith(DefaultTestRunner.class)
public class TestDatafeedFragment extends BaseFragmentTest {

    private SimpleDatafeedFragment mFragment;
    private DatafeedFragmentTestController<SimpleDatafeedFragment> mController;
    private BaseTestActivity mActivity;
    private Subject<String, String> mSubject;

    private SimpleSubscriber mSubscriber;
    private SimpleBinder mBinder;
    private NoDataBinder mNoDataBinder;
    private RefreshController mRefreshController;
    private TBAStatusController mStatusController;
    private EventBus mEventBus;
    private Tracker mAnalyticsTracker;

    @Before
    public void setUp() {
        mFragment = spy(new SimpleDatafeedFragment());
        mSubject = spy(new SerializedSubject<>(PublishSubject.create()));
        mFragment.setObservable(mSubject);
        mController = FragmentTestDriver.getController(mFragment)
                .makeTestActivityController()
                .makeActivity();
        mActivity = mController.getActivity();

        mRefreshController = mActivity.getRefreshController();
        mStatusController = mActivity.getStatusController();
        mEventBus = mActivity.getEventBus();
    }

    @Test
    public void testLifecycle() {
        // Activity has already been created, we've called up through onResume
        verify(mRefreshController).reset();
        verify(mEventBus).register(mActivity);
        verify(mStatusController).fetchApiStatus();

        mController.attach();
        getInjectedFragmentParams();
        verifyFragmentAttach();

        mController.pause();
        verify(mRefreshController).unregisterRefreshable("SimpleTest");
        verify(mEventBus).unregister(mActivity);
        verify(mEventBus, never()).unregister(mSubscriber);

        mController.stop();
        verify(mSubscriber).onParentStop();

        mController.destroy();
        verify(mBinder).unbind(true);
    }

    private void verifyFragmentAttach() {
        verify(mSubscriber).setConsumer(mBinder);
        verify(mSubscriber).setRefreshController(mRefreshController);
        verify(mSubscriber).setRefreshTag("SimpleTest");
        verify(mSubscriber).setTracker(mAnalyticsTracker);
        verify(mBinder).setActivity(mActivity);
        verify(mBinder).setNoDataBinder(mNoDataBinder);
        verify(mBinder).setNoDataParams(null);
        verify(mSubscriber).onRefreshStart(RefreshController.NOT_REQUESTED_BY_USER);
        verify(mRefreshController).registerRefreshable("SimpleTest", mFragment);
        verify(mEventBus, never()).register(mSubscriber);

    }

    // TODO push something to subject and test subscriber receives
    // TODO test commonStatus update when things are down
    // TODO test setting shouldRegisterSubscriberToEventBus
    // TODO test instance saving

    private void getInjectedFragmentParams() {
        mSubscriber = mFragment.getSubscriber();
        mBinder = mFragment.getBinder();
        mNoDataBinder = mFragment.getNoDataBinder();
        mAnalyticsTracker = mFragment.getAnalyticsTracker();
    }
}


text:
const Util = {
  post(url, data, callback) {
    const fetchOptions = {
      method: 'POST',
      headers: {
        Accept: 'application/json',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify(data),
    };
    fetch(url, fetchOptions)
      .then(response => response.text())
      .then((text) => {
        callback(JSON.parse(text));
      });
  },
  key: 'HSHHSGSGGSTWSYWSYUSUWSHWBS-REACT-NATIVE',
};

export default Util;


text:
<?php

namespace Jb\Bundle\SimplePageBundle\Entity;

use Jb\Bundle\SimplePageBundle\Model\Page as BasePage;

/**
 * Description of Page
 *
 * @author Jonathan Bouzekri <jonathan.bouzekri@gmail.com>
 */
class Page extends BasePage
{
}


text: /*# sourceMappingURL=ChooseMethod.css.map */


text:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package bingo;

import bingo.network.ClientManager;
import bingo.responses.AssignUserRoomResponse;
import bingo.responses.CreateRoomResponse;
import java.util.ArrayList;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import models.Room;
import models.User;

/**
 *
 * @author 14023691
 */
public class TelaSalas extends bingo.MyJFrame implements Tela {

    private String ra;
    private ArrayList<Room> rooms;
    private ClientManager clientManager;
    private DefaultListModel roomsModel = new DefaultListModel();
    private DefaultListModel usersModel = new DefaultListModel();

    public TelaSalas(ClientManager clientManager, String ra) {
        initComponents();
        this.setLocationRelativeTo(null);
        this.ra = ra;
        this.setTitle(ra);
        this.clientManager = clientManager;

        LIST_Rooms.setModel(roomsModel);
    }

    private void clearAvailableRooms() {
        roomsModel.removeAllElements();
    }
    private void clearUsersInRoom() {
        usersModel.removeAllElements();
    }

    public void addItensToAvailableRooms(ArrayList<Room> rooms) {
        this.clearAvailableRooms();
        this.rooms = rooms;
        for(Room r : rooms) {
            roomsModel.addElement(r);
        }
    }

    public void showRoomIsFull() {
        JOptionPane.showMessageDialog(null, "Está sala está cheia, tente novamente em outra sala ou crie uma sala!");
        this.hideLoaders();
    }

    @Override
    public void showGenericError() {
        JOptionPane.showMessageDialog(null, "Algo muito errado deu errado!");
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        PN_LSTSala = new javax.swing.JScrollPane();
        LIST_Users = new javax.swing.JList<>();
        PN_LSTJgd = new javax.swing.JScrollPane();
        LIST_Rooms = new javax.swing.JList<>();
        LBL_Salas = new javax.swing.JLabel();
        LBL_Jgd = new javax.swing.JLabel();
        BUT_AssignToRoom = new bingo.ButtonWithLoader();
        BTN_CreateRoom = new bingo.ButtonWithLoader();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        LIST_Users.setEnabled(false);
        LIST_Users.setSelectedIndex(0);
        PN_LSTSala.setViewportView(LIST_Users);

        LIST_Rooms.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        LIST_Rooms.setSelectedIndex(0);
        LIST_Rooms.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                LIST_RoomsValueChanged(evt);
            }
        });
        PN_LSTJgd.setViewportView(LIST_Rooms);

        LBL_Salas.setFont(new java.awt.Font("Century Gothic", 0, 18)); // NOI18N
        LBL_Salas.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        LBL_Salas.setText("Salas Disponíveis");
        LBL_Salas.setToolTipText("");

        LBL_Jgd.setFont(new java.awt.Font("Century Gothic", 0, 18)); // NOI18N
        LBL_Jgd.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        LBL_Jgd.setText("Jogadores em Sala");

        BUT_AssignToRoom.setText("Entrar na Sala");
        BUT_AssignToRoom.setToolTipText("");
        BUT_AssignToRoom.setFont(new java.awt.Font("Century Gothic", 1, 18)); // NOI18N
        BUT_AssignToRoom.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BUT_AssignToRoomActionPerformed(evt);
            }
        });

        BTN_CreateRoom.setLabel("Criar Nova Sala");
        BTN_CreateRoom.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BTN_CreateRoomActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(PN_LSTSala)
                        .addComponent(PN_LSTJgd)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(BTN_CreateRoom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(188, 188, 188)
                            .addComponent(BUT_AssignToRoom, javax.swing.GroupLayout.DEFAULT_SIZE, 345, Short.MAX_VALUE)))
                    .addComponent(LBL_Jgd)
                    .addComponent(LBL_Salas))
                .addContainerGap(28, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(22, Short.MAX_VALUE)
                .addComponent(LBL_Salas)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(PN_LSTJgd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(LBL_Jgd)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(PN_LSTSala, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(37, 37, 37)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(BUT_AssignToRoom, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(BTN_CreateRoom, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void LIST_RoomsValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_LIST_RoomsValueChanged
        this.clearUsersInRoom();
        int index = LIST_Rooms.getSelectedIndex();

        try {
            if(index >= 0) {
                Room room =  (Room) roomsModel.get(index);
                ArrayList<User> users = room.getUsers();
                for(User u : users) {
                    this.usersModel.addElement(u);
                }
                LIST_Users.setModel(usersModel);
            }
        }
        catch(ArrayIndexOutOfBoundsException e) {
            e.printStackTrace();
        }
    }//GEN-LAST:event_LIST_RoomsValueChanged

    private void BTN_CreateRoomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BTN_CreateRoomActionPerformed
        CreateRoomResponse createRequest = new CreateRoomResponse();
        this.clientManager.sendMessage(createRequest);
        BTN_CreateRoom.showLoader();
    }//GEN-LAST:event_BTN_CreateRoomActionPerformed

    private void BUT_AssignToRoomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BUT_AssignToRoomActionPerformed
        try {
            int idSala = ((Room)this.roomsModel.get(LIST_Rooms.getSelectedIndex())).getId();
            AssignUserRoomResponse assignResponse = new AssignUserRoomResponse(idSala);
            this.clientManager.sendMessage(assignResponse);
            BUT_AssignToRoom.showLoader();
        }
        catch(ArrayIndexOutOfBoundsException e) {
            e.getStackTrace();
        }
    }//GEN-LAST:event_BUT_AssignToRoomActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private bingo.ButtonWithLoader BTN_CreateRoom;
    private bingo.ButtonWithLoader BUT_AssignToRoom;
    private javax.swing.JLabel LBL_Jgd;
    private javax.swing.JLabel LBL_Salas;
    private javax.swing.JList<String> LIST_Rooms;
    private javax.swing.JList<String> LIST_Users;
    private javax.swing.JScrollPane PN_LSTJgd;
    private javax.swing.JScrollPane PN_LSTSala;
    // End of variables declaration//GEN-END:variables
}


text:
package com.mindforger.shiftsolver.shared.model;

import java.io.Serializable;

public class DayPreference implements Serializable {
	private static final long serialVersionUID = 1302160963964962116L;

	private String key;

	private int year;
	private int month;
	private int day;

	// three state preferences: NO, I CANNOT MAKE IT (bool) / YES PLEASE, I WANT IT (bool) / I DONT CARE (nothing)

	private boolean isHoliDay;

	private boolean noDay;
	private boolean noMorning6; // 6 AM or entire day
	private boolean noMorning7;
	private boolean noMorning8;
	private boolean noAfternoon;
	private boolean noNight;

	private boolean yesDay;
	private boolean yesMorning6;
	private boolean yesMorning7;
	private boolean yesMorning8;
	private boolean yesAfternoon;
	private boolean yesNight;

	public DayPreference() {
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public int getYear() {
		return year;
	}

	public void setYear(int year) {
		this.year = year;
	}

	public int getMonth() {
		return month;
	}

	public void setMonth(int month) {
		this.month = month;
	}

	public int getDay() {
		return day;
	}

	public void setDay(int day) {
		this.day = day;
	}

	public boolean isNoDay() {
		return noDay;
	}

	public void setNoDay(boolean noDay) {
		this.noDay = noDay;
	}

	public boolean isNoMorning6() {
		return noMorning6 || noDay;
	}

	public void setNoMorning6(boolean noMorning6) {
		this.noMorning6 = noMorning6;
	}

	public boolean isNoMorning7() {
		return noMorning7 || noDay;
	}

	public void setNoMorning7(boolean noMorning7) {
		this.noMorning7 = noMorning7;
	}

	public boolean isNoMorning8() {
		return noMorning8 || noDay;
	}

	public void setNoMorning8(boolean noMorning8) {
		this.noMorning8 = noMorning8;
	}

	public boolean isNoAfternoon() {
		return noAfternoon || noDay;
	}

	public void setNoAfternoon(boolean noAfternoon) {
		this.noAfternoon = noAfternoon;
	}

	public boolean isYesNight() {
		return yesNight;
	}

	public void setYesNight(boolean yesNight) {
		this.yesNight = yesNight;
	}

	public boolean isNoNight() {
		return noNight || noDay;
	}

	public void setNoNight(boolean noNight) {
		this.noNight = noNight;
	}

	public boolean isYesDay() {
		return yesDay;
	}

	public void setYesDay(boolean yesDay) {
		this.yesDay = yesDay;
	}

	public boolean isYesMorning6() {
		return yesMorning6;
	}

	public void setYesMorning6(boolean yesMorning6) {
		this.yesMorning6 = yesMorning6;
	}

	public boolean isYesMorning7() {
		return yesMorning7;
	}

	public void setYesMorning7(boolean yesMorning7) {
		this.yesMorning7 = yesMorning7;
	}

	public boolean isYesMorning8() {
		return yesMorning8;
	}

	public void setYesMorning8(boolean yesMorning8) {
		this.yesMorning8 = yesMorning8;
	}

	public boolean isYesAfternoon() {
		return yesAfternoon;
	}

	public void setYesAfternoon(boolean yesAfternoon) {
		this.yesAfternoon = yesAfternoon;
	}

	public boolean isHoliDay() {
		return isHoliDay;
	}

	public void setHoliDay(boolean isHoliDay) {
		this.isHoliDay = isHoliDay;
		if(isHoliDay) setNoDay(true);
	}
}


text:
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".

Replace this with more appropriate tests for your application.
"""

from django.test import TestCase

class SimpleTest():
    def test_basic_addition(self):
        """
        Tests that 1 + 1 always equals 2.
        """
        self.assertEqual(4, 2)

    def test_create_pages_codes(self):
        pass